Skip to content

Commit 9793554

Browse files
committed
commands: Allow public roomstaff to check alts
1 parent 325e3bf commit 9793554

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/ps/commands/alts.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import { ChatError } from '@/utils/chatError';
44

55
import type { PSCommand } from '@/types/chat';
66

7+
function isPublicStaff([room, { isPrivate }]: [string, { isPrivate?: boolean }]): boolean {
8+
if (isPrivate) return false;
9+
return /^[%@*#]/.test(room);
10+
}
11+
712
export const command: PSCommand = {
813
name: 'alts',
914
help: "Lists a user's alts. Requires trusted perms to view beyond your own.",
@@ -14,8 +19,10 @@ export const command: PSCommand = {
1419
async run({ message, arg, $T, checkPermissions }) {
1520
let lookup = message.author.userid;
1621
if (arg) {
17-
// TODO: Change this to use _any_ room
18-
if (!checkPermissions(['room', 'driver']) && !checkPermissions(['global', 'voice'])) throw new ChatError($T('ACCESS_DENIED'));
22+
if (!checkPermissions(['room', 'driver']) && !checkPermissions(['global', 'voice'])) {
23+
const isPublicRoomStaff = message.author.rooms && Object.entries(message.author.rooms).some(isPublicStaff);
24+
if (!isPublicRoomStaff) throw new ChatError($T('ACCESS_DENIED'));
25+
}
1926
lookup = toId(arg);
2027
}
2128
const altsList = await getAlts(lookup);

0 commit comments

Comments
 (0)