Filtering out unavailable commands from help.
This commit is contained in:
parent
98c5335bc2
commit
f9708a1a77
|
@ -4,8 +4,13 @@ const config = require('config');
|
|||
const { version } = require('../../package.json');
|
||||
|
||||
function onCommand(args, context) {
|
||||
const commandsByGame = Object.entries(context.games).reduce((acc, [command, game]) => ({ ...acc, [game.name]: [...(acc[game.name] || []), command] }), {});
|
||||
const commands = Object.entries(commandsByGame).map(([gameName, gameCommands]) => `${gameName.slice(0, 1).toUpperCase()}${gameName.slice(1)}: ${gameCommands.map((command) => `${config.prefix}${command}`).join(', ')}`).join(' | ');
|
||||
const commandsByGame = Object.entries(context.games)
|
||||
.filter(([command, game]) => !command.includes('-') && !game.restricted)
|
||||
.reduce((acc, [command, game]) => ({ ...acc, [game.name]: [...(acc[game.name] || []), command] }), {});
|
||||
|
||||
const commands = Object.entries(commandsByGame)
|
||||
.map(([gameName, gameCommands]) => `${gameName.slice(0, 1).toUpperCase()}${gameName.slice(1)}: ${gameCommands.map((command) => `${config.prefix}${command}`).join(', ')}`)
|
||||
.join(' | ');
|
||||
|
||||
context.sendMessage(`${commands}`, context.room.id, { styleCommands: true });
|
||||
context.sendMessage(`Try ${config.prefix}game:help for more info, ${config.prefix}game:score [username] and ${config.prefix}game:lead for scores. | ${config.user.username} v${version} `, context.room.id, { styleCommands: true });
|
||||
|
|
|
@ -39,4 +39,5 @@ function onCommand(args, context) {
|
|||
module.exports = {
|
||||
name: 'Say',
|
||||
onCommand,
|
||||
restricted: true,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue