From 1ebdcc420a218c827c9338698f443161b7ada271 Mon Sep 17 00:00:00 2001 From: Loic Bersier Date: Fri, 30 Nov 2018 02:33:00 +0100 Subject: [PATCH] delete the previous message --- commands/fun/sayd.js | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 commands/fun/sayd.js diff --git a/commands/fun/sayd.js b/commands/fun/sayd.js new file mode 100644 index 00000000..ab4a988f --- /dev/null +++ b/commands/fun/sayd.js @@ -0,0 +1,52 @@ +const { Command } = require('discord.js-commando'); +const SelfReloadJSON = require('self-reload-json'); +const blacklist = require('../../blacklist'); +module.exports = class saydCommand extends Command { + constructor(client) { + super(client, { + name: 'sayd', + aliases: ['repeatd'], + group: 'fun', + memberName: 'sayd', + description: `Repeat the text you send and delete it( can also use [verb] [noun] [adverb] [adjective] [member] and [number] to get random thing )`, + args: [ + { + key: 'text', + prompt: 'What do you want me to say', + type: 'string', + } + ] + }); + } + + async run(message, { text }) { + let blacklistJson = new SelfReloadJSON('json/blacklist.json'); + if(blacklistJson[message.author.id]) + return blacklist(blacklistJson[message.author.id] , message) + + +// Load all the different files + const verb = require('../../dictionary/verbs.json') + const noun = require('../../dictionary/nouns.json') + const adverb = require('../../dictionary/adjectives.json') + const adjective = require('../../dictionary/adverbs.json') +// Generate a random number + function randNumber(file) { + let Rand = Math.floor((Math.random() * file.length) + 1); + return Rand; + } +// Replace with a random word from the json + do { + text = text.replace(/\[verb\]/, verb[randNumber(verb)]) + text = text.replace(/\[adverb\]/, adverb[randNumber(adverb)]) + text = text.replace(/\[noun\]/, noun[randNumber(noun)]) + text = text.replace(/\[adjective\]/, adjective[randNumber(adjective)]) + text = text.replace(/\[member\]/, message.guild.members.random().user.username) + text = text.replace(/\[number\]/, Math.floor((Math.random() * 9) + 1)) + } while( text.includes('[verb]') || text.includes('[adverb]') || text.includes('[noun]') || text.includes('[adjective]') || text.includes('[member]') || text.includes('[number]') ) + +// Send the final text + message.delete(); + message.say(text); + } +}; \ No newline at end of file