From fa9f2437ed704f536ee62af3888445e424c0a54f Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sun, 22 Mar 2020 20:18:40 +0100 Subject: [PATCH] choose one random word --- commands/general/randomizer.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 commands/general/randomizer.js diff --git a/commands/general/randomizer.js b/commands/general/randomizer.js new file mode 100644 index 00000000..e44e3471 --- /dev/null +++ b/commands/general/randomizer.js @@ -0,0 +1,34 @@ +const { Command } = require('discord-akairo'); + +class randomizerCommand extends Command { + constructor() { + super('randomizer', { + aliases: ['randomizer'], + category: 'general', + clientPermissions: ['SEND_MESSAGES'], + args: [ + { + id: 'text', + type: 'string', + prompt: { + start: 'Need words to randomize', + }, + match: 'rest' + } + ], + description: { + content: 'Choose one random word', + usage: '[multiples words]', + examples: ['Hello bye'] + } + }); + } + + async exec(message, args) { + let words = args.text.split(' '); + + return message.channel.send(words[Math.floor((Math.random() * words.length))]); + } +} + +module.exports = randomizerCommand; \ No newline at end of file