Added boundaries to Trivia rounds and timeout.
This commit is contained in:
@@ -182,7 +182,19 @@ function onCommand(args, context) {
|
||||
|
||||
if (subcommand && settings[subcommand]) {
|
||||
if (args[0]) {
|
||||
settings[subcommand] = typeof settings[subcommand] === 'number' ? (Number(args[0]) || settings[subcommand]) : args[0];
|
||||
const bounds = config.trivia.bounds[subcommand];
|
||||
const curatedSetting = typeof settings[subcommand] === 'number' ? Number(args[0]) : args[0];
|
||||
|
||||
if (Number.isNaN(curatedSetting)) {
|
||||
context.sendMessage(`${subcommand} must be a valid number`, context.room.id);
|
||||
}
|
||||
|
||||
if (Array.isArray(bounds) && typeof settings[subcommand] === 'number' && (curatedSetting < bounds[0] || curatedSetting > bounds[1])) {
|
||||
context.sendMessage(`${subcommand} must be between ${bounds[0]} and ${bounds[1]}`, context.room.id);
|
||||
return;
|
||||
}
|
||||
|
||||
settings[subcommand] = curatedSetting;
|
||||
|
||||
context.sendMessage(`${subcommand} set to ${settings[subcommand]}`, context.room.id);
|
||||
} else if (help[subcommand]) {
|
||||
|
||||
Reference in New Issue
Block a user