Skip to content

Commit a8df834

Browse files
feildmasterclaude
andcommitted
feat: staff chat commands in autocomplete
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent a23ac41 commit a8df834

4 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎changelog.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
### Features
55
1. Added a search bar and status filters to the community plugins list, which is now sorted by name
66
1. The battle log can now be resized by dragging its bottom-left corner, and minimized with the button in its header
7+
1. Staff chat commands now show up in chat autocomplete for users with permission to use them
78
### Fixes
89
1. Fixed some settings pages showing an extra scrollbar when they didn't need one
910
1. Fixed setting notes and other hover text going off the screen

‎lang/en/command.json‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
{
2+
"ban": {
3+
"~": "Ban a user from public chat",
4+
"usage": "<username>"
5+
},
6+
"broadcast": {
7+
"~": "Send an announcement to all connected users",
8+
"usage": "<message>"
9+
},
210
"gg": "Wish your opponent a good game",
311
"scroll": "Scroll the chat back to the bottom",
412
"spectate": {
513
"~": "Share a spectate link for your current game",
614
"usage": "[text (optional)]",
715
"note": "/spectate [text (optional)]<br/>Output:<br/>You vs Enemy: url [text]"
16+
},
17+
"to": {
18+
"~": "Temporarily mute a user and delete their messages",
19+
"usage": "<username> <seconds>"
20+
},
21+
"unban": {
22+
"~": "Remove a public chat ban",
23+
"usage": "<username>"
24+
},
25+
"unto": {
26+
"~": "Remove a temporary mute",
27+
"usage": "<username>"
828
}
929
}

‎src/base/vanilla/commands.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { isPriority, self } from 'src/utils/user.js';
2+
import { register } from 'src/utils/chatCommands.js';
3+
import Translation from 'src/structures/constants/translation.js';
4+
5+
function moderation(command, priority, usage) {
6+
register({
7+
command,
8+
usage: usage && Translation.Command(`${command}.usage`),
9+
enabled: () => isPriority(self(), priority),
10+
});
11+
}
12+
13+
moderation('broadcast', 3, true);
14+
moderation('to', 4, true);
15+
moderation('unto', 4, true);
16+
moderation('ban', 3, true);
17+
moderation('unban', 3, true);

‎src/utils/user.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function isStaff(user) {
2828
return isPriority(user, 6);
2929
}
3030

31-
function isPriority(user, priority) {
31+
export function isPriority(user, priority) {
3232
if (typeof user?.mainGroup?.priority !== 'number') throw new Error('Invalid user');
3333
return user.mainGroup.priority <= priority;
3434
}

0 commit comments

Comments
 (0)