Added missing timeout commands and help.
This commit is contained in:
+24
-1
@@ -64,6 +64,24 @@ function playWord(rawWord, context) {
|
||||
context.sendMessage(`${context.user.username} played ${style.bold(style.pink(word))} for ${style.bold(word.length)} points!`, context.room.id);
|
||||
}
|
||||
|
||||
function setTimeout(timeout, context) {
|
||||
if (!timeout) {
|
||||
context.sendMessage(`Timeout is set to ${style.bold(settings.timeout)}`, context.room.id);
|
||||
return;
|
||||
}
|
||||
|
||||
const parsedTimeout = Number(timeout);
|
||||
|
||||
if (Number.isNaN(parsedTimeout) || parsedTimeout < 10 || parsedTimeout > 300) {
|
||||
context.sendMessage('Timeout must be a number between 10 and 300', context.room.id);
|
||||
return;
|
||||
}
|
||||
|
||||
settings.timeout = parsedTimeout;
|
||||
|
||||
context.sendMessage(`Timeout set to ${style.bold(settings.timeout)} by ${context.user.prefixedUsername}`, context.room.id);
|
||||
}
|
||||
|
||||
function stop(context, aborted) {
|
||||
const game = games.get(context.room.id);
|
||||
|
||||
@@ -163,6 +181,11 @@ function onCommand(args, context) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.subcommand === 'timeout') {
|
||||
setTimeout(args[0], context);
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.command === 'letsgo' || ['start', 'go', 'auto', 'random'].includes(context.subcommand)) {
|
||||
start(context, Array.from({ length: config.letters.length }, () => (Math.random() < config.letters.consonantBias ? 'c' : 'v')).join('')); // a slight bias towards consonants seems to give better boards
|
||||
return;
|
||||
@@ -206,7 +229,7 @@ function onMessage(message, context) {
|
||||
|
||||
module.exports = {
|
||||
name: 'Letters',
|
||||
help: `Make the longest word from the ${config.letters.length} letters on the board. Quick-start with ${config.prefix}letsgo, or use ${config.prefix}letters to fill the board by manually selecting a vow(el), a con(sonant), or multiple at once like CCVVCCVVC.`,
|
||||
help: `Make the longest word from the ${config.letters.length} letters on the board. Quick-start with ${config.prefix}letsgo, or use ${config.prefix}letters to fill the board by manually selecting a vow(el), a con(sonant), or multiple at once like CCVVCCVVC. Change the time limit with ${config.prefix}letters:timeout [10-300].`,
|
||||
commands: ['letsgo'],
|
||||
onCommand,
|
||||
onMessage,
|
||||
|
||||
Reference in New Issue
Block a user