add pronouns, add nicks (kinda)

This commit is contained in:
Vendicated 2024-07-03 17:24:29 +02:00
parent 1a2033e137
commit 3a7499644e
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18
2 changed files with 32 additions and 0 deletions

View file

@ -20,6 +20,7 @@ export interface UserOverride {
username: string;
avatarUrl: string;
bannerUrl: string;
pronouns: string;
flags: OverrideFlags;
}
@ -27,6 +28,7 @@ export const emptyOverride: UserOverride = Object.freeze({
username: "",
avatarUrl: "",
bannerUrl: "",
pronouns: "",
flags: OverrideFlags.None,
});

View file

@ -66,14 +66,33 @@ export default definePlugin({
{
match: /(?<=:).{0,10}\(\{id:this\.userId,banner/,
replace: "$self.getBannerUrl(this.userId)||$&"
},
{
match: /isUsingGuildMemberPronouns\(\)\{/,
replace:
"set pronouns(v){this._vcPronouns=v}" +
"get pronouns(){return $self.getPronouns(this.userId)||this._vcPronouns}" +
"isUsingGuildMemberPronouns(){"
},
{
match: /\i\(this,"pronouns",void 0\),/,
replace: ""
}
]
},
{
find: '"GuildMemberStore"',
replacement: {
match: /getNick\(\i,(\i)\)\{/,
replace: "$& if ($self.shouldIgnoreNick($1)) return null;"
}
}
],
getUsername: (user: User) => getUserOverride(user.id).username,
getAvatarUrl: (user: User) => getUserOverride(user.id).avatarUrl,
getBannerUrl: (userId: string) => getUserOverride(userId).bannerUrl,
getPronouns: (userId: string) => getUserOverride(userId).pronouns,
shouldIgnoreGuildAvatar(user: User) {
const { avatarUrl, flags } = getUserOverride(user.id);
@ -91,5 +110,16 @@ export default definePlugin({
return true;
return hasFlag(flags, OverrideFlags.DisableServerBanners);
},
shouldIgnoreNick(userId?: string) {
if (!userId) return false;
const { username, flags } = getUserOverride(userId);
if (username && !hasFlag(flags, OverrideFlags.PreferServerNicks))
return true;
return hasFlag(flags, OverrideFlags.DisableNicks);
}
});