Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ShowMeYourName): Nick, Display, Username Permutations; Streamer Mode; Mentions; Affixes; Colors #3107

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ec07ba2
Added streamer mode detection, 15 name combinations, custom colors & …
EtorixDev Nov 28, 2024
8a871f9
Remove inconsistent reply prefix, update name priority, rearrange.
EtorixDev Nov 29, 2024
c106d02
Also truncate nick and display in streamer mode if they are equivalen…
EtorixDev Nov 29, 2024
2b44e3d
Nick/display duo fallback, username final fallback, + code refactor.
EtorixDev Nov 29, 2024
be2f1ce
Modify how overlap between nick, display, and usernames are handled.
EtorixDev Nov 29, 2024
38acfe3
Remove username override & add removeDuplicates setting.
EtorixDev Nov 29, 2024
05d2307
Make replacing dupes optional, conditionally prioritize username on x…
EtorixDev Nov 30, 2024
af953af
Merge remote-tracking branch 'upstream/main' into showMeYourNameStrea…
EtorixDev Nov 30, 2024
2d1edd7
Fix prefix/suffix color of first name if alwaysShow enabled.
EtorixDev Nov 30, 2024
4cf8626
Merge branch 'main' into showMeYourNameStreamerMode
EtorixDev Dec 10, 2024
2f53f15
Merge branch 'main' into showMeYourNameStreamerMode
EtorixDev Dec 26, 2024
a8866cd
Add setting to overwrite first name color + modify defaults.
EtorixDev Dec 26, 2024
e774de2
Borrow sadan's mention feature + fix affix oversight.
EtorixDev Dec 26, 2024
af1b757
Remove mysterious userOverride.
EtorixDev Dec 26, 2024
d8f21f8
Reword plugin description.
EtorixDev Dec 26, 2024
d0e259d
Fix global name overwriting nickname bug + update mention symbol hand…
EtorixDev Dec 26, 2024
0025e4c
Fix some typing and typos.
EtorixDev Dec 26, 2024
5f53f85
Reduce niche settings + switch to string format over dropdown for per…
EtorixDev Dec 27, 2024
d85ad71
Merge branch 'main' into showMeYourNameStreamerMode
EtorixDev Dec 31, 2024
0ad98f7
Fix: Readd userOverride, present for interactions.
EtorixDev Dec 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Nick/display duo fallback, username final fallback, + code refactor.
  • Loading branch information
EtorixDev committed Nov 29, 2024
commit 2b44e3dba25d8de6cfd2f9d05e3b5acb0378b13e
78 changes: 39 additions & 39 deletions src/plugins/showMeYourName/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const settings = definePluginSettings({
},
includedNames: {
type: OptionType.SELECT,
description: "The order to display usernames, nicknames, and display names. If any overlap or do not exist, they will be omitted.",
description: "The order to display usernames, nicknames, and display names. If any overlap or do not exist, they will be omitted. Regardless of your selection below, if nickname or display name are missing, the other will be used. If both are missing, username will be used.",
default: "nick_user",
options: [
{ label: "Nickname", value: "nick" },
Expand Down Expand Up @@ -225,77 +225,77 @@ export default definePlugin({
settings,

renderUsername: ErrorBoundary.wrap(({ author, message, isRepliedMessage, userOverride }: UsernameProps) => {
const user = userOverride ?? message.author;
const user: any = userOverride ?? message.author;
const username = StreamerModeStore.enabled && settings.store.respectStreamerMode ? user.username[0] + "..." : user.username;
const nick = StreamerModeStore.enabled && settings.store.respectStreamerMode && author?.nick?.toLowerCase() === user.username.toLowerCase() ? author.nick[0] + "..." : author?.nick || "";
const display = StreamerModeStore.enabled && settings.store.respectStreamerMode && (user as any).globalName?.toLowerCase() === user.username.toLowerCase() ? (user as any).globalName[0] + "..." : (user as any).globalName || "";
const display = StreamerModeStore.enabled && settings.store.respectStreamerMode && user.globalName?.toLowerCase() === user.username.toLowerCase() ? user.globalName[0] + "..." : user.globalName || "";
const nick = StreamerModeStore.enabled && settings.store.respectStreamerMode && author?.nick?.toLowerCase() === user.username.toLowerCase() ? author.nick[0] + "..." : author?.nick === display ? "" : author?.nick || "";

try {
if (isRepliedMessage && !settings.store.replies) {
return <>{nick || display || username}</>;
}

const textMutedValue = getComputedStyle(document.documentElement)?.getPropertyValue("--text-muted")?.trim() || "#72767d";
const { alwaysShowUsernameSymbols, alwaysShowNicknameSymbols, alwaysShowDisplaySymbols } = settings.store;
const usernamePrefix = settings.store.usernamePrefix === "none" ? "" : settings.store.usernamePrefix;
const usernameSuffix = settings.store.usernameSuffix === "none" ? "" : settings.store.usernameSuffix;
const usernameColor = resolveColor(message.channel_id, user.id, settings.store.usernameColor.trim(), textMutedValue);
const usernameSymbolColor = resolveColor(message.channel_id, user.id, settings.store.usernameSymbolColor.trim(), textMutedValue);
const nicknamePrefix = settings.store.nicknamePrefix === "none" ? "" : settings.store.nicknamePrefix;
const nicknameSuffix = settings.store.nicknameSuffix === "none" ? "" : settings.store.nicknameSuffix;
const nicknameColor = resolveColor(message.channel_id, user.id, settings.store.nicknameColor.trim(), textMutedValue);
const nicknameSymbolColor = resolveColor(message.channel_id, user.id, settings.store.nicknameSymbolColor.trim(), textMutedValue);
const displayNamePrefix = settings.store.displayNamePrefix === "none" ? "" : settings.store.displayNamePrefix;
const displayNameSuffix = settings.store.displayNameSuffix === "none" ? "" : settings.store.displayNameSuffix;
const displayNameColor = resolveColor(message.channel_id, user.id, settings.store.displayNameColor.trim(), textMutedValue);
const displayNameSymbolColor = resolveColor(message.channel_id, user.id, settings.store.displayNameSymbolColor.trim(), textMutedValue);

const values = {
"nick": { "value": nick, "prefix": nicknamePrefix, "suffix": nicknameSuffix, "alwaysShow": alwaysShowNicknameSymbols },
"display": { "value": display, "prefix": displayNamePrefix, "suffix": displayNameSuffix, "alwaysShow": alwaysShowDisplaySymbols },
"user": { "value": username, "prefix": usernamePrefix, "suffix": usernameSuffix, "alwaysShow": alwaysShowUsernameSymbols }
"user": { "value": username, "prefix": usernamePrefix, "suffix": usernameSuffix, "alwaysShow": alwaysShowUsernameSymbols, "color": usernameColor, "symbolColor": usernameSymbolColor },
"display": { "value": display, "prefix": displayNamePrefix, "suffix": displayNameSuffix, "alwaysShow": alwaysShowDisplaySymbols, "color": displayNameColor, "symbolColor": displayNameSymbolColor },
"nick": { "value": nick, "prefix": nicknamePrefix, "suffix": nicknameSuffix, "alwaysShow": alwaysShowNicknameSymbols, "color": nicknameColor, "symbolColor": nicknameSymbolColor }
};
const order = settings.store.includedNames.split("_");
const first = order[0] || order[1] || order[2];
const second = first === order[0] ? order[1] || order[2] || "" : first === order[1] ? order[2] : "";
const third = second === order[1] ? order[2] || "" : "";
second && values[second].value.toLowerCase() === values[first].value.toLowerCase() ? values[second].value = "" : null;
third && values[third].value.toLowerCase() === values[first].value.toLowerCase() ? values[third].value = "" : third && values[third].value.toLowerCase() === values[second].value.toLowerCase() ? values[third].value = "" : null;

const textMutedValue = getComputedStyle(document.documentElement)?.getPropertyValue("--text-muted")?.trim() || "#72767d";
const usernameColor = resolveColor(message.channel_id, user.id, settings.store.usernameColor.trim(), textMutedValue);
const usernameSymbolColor = resolveColor(message.channel_id, user.id, settings.store.usernameSymbolColor.trim(), textMutedValue);
const nicknameColor = resolveColor(message.channel_id, user.id, settings.store.nicknameColor.trim(), textMutedValue);
const nicknameSymbolColor = resolveColor(message.channel_id, user.id, settings.store.nicknameSymbolColor.trim(), textMutedValue);
const displayNameColor = resolveColor(message.channel_id, user.id, settings.store.displayNameColor.trim(), textMutedValue);
const displayNameSymbolColor = resolveColor(message.channel_id, user.id, settings.store.displayNameSymbolColor.trim(), textMutedValue);
const secondColor = second && values[second].value === nick ? nicknameColor : second && values[second].value === username ? usernameColor : displayNameColor;
const secondSymbolColor = second && values[second].value === nick ? nicknameSymbolColor : second && values[second].value === username ? usernameSymbolColor : displayNameSymbolColor;
const thirdColor = third && values[third].value === nick ? nicknameColor : third && values[third].value === username ? usernameColor : displayNameColor;
const thirdSymbolColor = third && values[third].value === nick ? nicknameSymbolColor : third && values[third].value === username ? usernameSymbolColor : displayNameSymbolColor;
let order = settings.store.includedNames.split("_");
order.includes("nick") && !values.nick.value && !order.includes("display") && values.display.value ? order[order.indexOf("nick")] = "display" : null;
order.includes("display") && !values.display.value && !order.includes("user") && values.user.value ? order[order.indexOf("display")] = "user" : null;
order = order.filter((name: string) => values[name].value);

const first = order.shift() || "user";
let second = order.shift() || null;
let third = order.shift() || null;
second && third && values[third].value.toLowerCase() === values[second].value.toLowerCase() ? third = null : null;
second && values[second].value.toLowerCase() === values[first].value.toLowerCase() ? second = null : null;

return (
<>
{values[first].value && (
{(
<span>
{values[first].alwaysShow ? values[first].prefix : ""}
{values[first].value}
{values[first].alwaysShow ? values[first].suffix : ""}
</span>
)}
{second && values[second].value && (
{second && (
<span>
{(values[first].value) ? <span>&nbsp;</span> : ""}
<span style={secondSymbolColor}>
{values[second].alwaysShow || values[first].value ? values[second].prefix : ""}</span>
<span style={secondColor}>
<span>&nbsp;</span>
<span style={values[second].symbolColor}>
{values[second].prefix}</span>
<span style={values[second].color}>
{values[second].value}</span>
<span style={secondSymbolColor}>
{values[second].alwaysShow || values[first].value ? values[second].suffix : ""}</span>
<span style={values[second].symbolColor}>
{values[second].suffix}</span>
</span>
)}
{third && values[third].value && (
{third && (
<span>
{values[first].value || values[second].value ? <span>&nbsp;</span> : ""}
<span style={thirdSymbolColor}>
{values[third].alwaysShow || (values[first].value || values[second].value) ? values[third].prefix : ""}</span>
<span style={thirdColor}>
<span>&nbsp;</span>
<span style={values[third].symbolColor}>
{values[third].prefix}</span>
<span style={values[third].color}>
{values[third].value}</span>
<span style={thirdSymbolColor}>
{values[third].alwaysShow || (values[first].value || values[second].value) ? values[third].suffix : ""}</span>
<span style={values[third].symbolColor}>
{values[third].suffix}</span>
</span>
)}
</>
Expand Down