Skip to content

Commit 7279f81

Browse files
WifiLatencyKrisXV
andauthored
Allow users to broadcast !avatar (smogon#10961)
* command properly functions when duplicated but cant broadcast with the normal name. * Prevent users from providing no argument. * Removed extraneous null check and ternary assignment. * Remove extraneous newline. * Update server/chat-commands/avatars.tsx --------- Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
1 parent 0f3eaaf commit 7279f81

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

server/chat-commands/avatars.tsx

+15-9
Original file line numberDiff line numberDiff line change
@@ -686,15 +686,18 @@ export const commands: Chat.ChatCommands = {
686686
return false;
687687
}
688688

689-
user.avatar = avatar;
690-
if (user.id in customAvatars && !avatar.endsWith('xmas')) {
691-
Avatars.setDefault(user.id, avatar);
689+
this.runBroadcast();
690+
if (!this.broadcasting) {
691+
user.avatar = avatar;
692+
if (user.id in customAvatars && !avatar.endsWith('xmas')) {
693+
Avatars.setDefault(user.id, avatar);
694+
}
692695
}
693-
if (!silent) {
694-
this.sendReply(
695-
`${this.tr`Avatar changed to:`}\n` +
696-
Chat.html`|raw|${Avatars.img(avatar)}`
697-
);
696+
if (!silent || this.broadcasting) {
697+
if (!this.broadcasting) {
698+
this.sendReply(`${this.tr`Avatar changed to:`}`);
699+
}
700+
this.sendReply(Chat.html`|raw|${Avatars.img(avatar)}`);
698701
if (OFFICIAL_AVATARS_BELIOT419.has(avatar)) {
699702
this.sendReply(`|raw|(${this.tr`Artist: `}<a href="https://www.deviantart.com/beliot419">Beliot419</a>)`);
700703
}
@@ -727,7 +730,10 @@ export const commands: Chat.ChatCommands = {
727730
}
728731
}
729732
},
730-
avatarhelp: [`/avatar [avatar name or number] - Change your trainer sprite.`],
733+
avatarhelp: [
734+
`/avatar [avatar name or number] - Change your trainer sprite.`,
735+
`!avatar [avatar name or number] - Show the specified trainer sprite and credits. Requires: + % @ # ~`,
736+
],
731737

732738
avatars(target, room, user) {
733739
this.runBroadcast();

0 commit comments

Comments
 (0)