Skip to content

Commit c81074d

Browse files
committed
games: Make stash multi-only, and add closepage
1 parent 5f17e44 commit c81074d

1 file changed

Lines changed: 24 additions & 14 deletions

File tree

src/ps/commands/games/core.tsx

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -451,22 +451,32 @@ export const command: PSCommand[] = Object.entries(Games).map(([_gameId, Game]):
451451
message.target.sendHTML(staffHTML, { ...opts, rank: '%' });
452452
},
453453
},
454-
stash: {
455-
name: 'stash',
456-
aliases: ['yeet'],
457-
help: 'Stashes a game to store it for later.',
458-
perms: Symbol.for('games.create'),
459-
syntax: 'CMD [game ref]',
460-
async run({ message, arg, $T }) {
461-
const { game } = getGame(arg, { action: 'any' }, { room: message.target, $T });
462-
delete PSGames[gameId]?.[game.id];
463-
game.pokeTimer?.cancel();
464-
game.timer?.cancel();
465-
message.reply($T('GAME.STASHED', { id: game.id }));
466-
},
467-
},
468454
...conditionalCommand(
469455
Game.meta.players === 'many',
456+
{
457+
name: 'closepage',
458+
help: 'Closes a page without leaving the game.',
459+
syntax: 'CMD [game ref]',
460+
async run({ message, arg, $T }) {
461+
const { game } = getGame(arg, { action: 'leave', user: message.author.id }, { room: message.target, $T });
462+
if (!game.getPlayer(message.author)) throw new ChatError($T('GAME.INVALID_INPUT'));
463+
message.reply(`/closehtmlpage ${message.author.id}, ${game.id}` as NoTranslate);
464+
},
465+
},
466+
{
467+
name: 'stash',
468+
aliases: ['yeet'],
469+
help: 'Stashes a game to store it for later.',
470+
perms: Symbol.for('games.create'),
471+
syntax: 'CMD [game ref]',
472+
async run({ message, arg, $T }) {
473+
const { game } = getGame(arg, { action: 'any' }, { room: message.target, $T });
474+
delete PSGames[gameId]?.[game.id];
475+
game.pokeTimer?.cancel();
476+
game.timer?.cancel();
477+
message.reply($T('GAME.STASHED', { id: game.id }));
478+
},
479+
},
470480
{
471481
name: 'backups',
472482
aliases: ['bu', 'b'],

0 commit comments

Comments
 (0)