Added boundaries to Trivia rounds and timeout.
This commit is contained in:
parent
6831330e35
commit
2daf52477d
|
@ -24,6 +24,10 @@ module.exports = {
|
||||||
mode: 'first', // first or timeout
|
mode: 'first', // first or timeout
|
||||||
rounds: 10,
|
rounds: 10,
|
||||||
timeout: 60,
|
timeout: 60,
|
||||||
|
bounds: {
|
||||||
|
rounds: [1, 30],
|
||||||
|
timeout: [5, 300],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
duck: {
|
duck: {
|
||||||
interval: [10, 3600], // seconds
|
interval: [10, 3600], // seconds
|
||||||
|
|
|
@ -182,7 +182,19 @@ function onCommand(args, context) {
|
||||||
|
|
||||||
if (subcommand && settings[subcommand]) {
|
if (subcommand && settings[subcommand]) {
|
||||||
if (args[0]) {
|
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);
|
context.sendMessage(`${subcommand} set to ${settings[subcommand]}`, context.room.id);
|
||||||
} else if (help[subcommand]) {
|
} else if (help[subcommand]) {
|
||||||
|
|
Loading…
Reference in New Issue