2018-12-30 01:20:24 +01:00
|
|
|
const { Command } = require('discord-akairo');
|
2018-12-05 00:52:21 +01:00
|
|
|
|
2018-12-30 01:20:24 +01:00
|
|
|
class SayCommand extends Command {
|
|
|
|
constructor() {
|
|
|
|
super('sayd', {
|
|
|
|
aliases: ['sayd'],
|
|
|
|
category: 'general',
|
|
|
|
split: 'none',
|
|
|
|
clientPermissions: 'MANAGE_MESSAGES',
|
|
|
|
args: [
|
|
|
|
{
|
|
|
|
id: 'text',
|
|
|
|
type: 'string'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
description: {
|
|
|
|
content: 'Repeat what you say but delete the text you sent',
|
|
|
|
usage: '[text]',
|
|
|
|
examples: ['[member] is a big [adverbs] [verb]']
|
|
|
|
}
|
2018-09-18 15:35:06 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-12-30 01:20:24 +01:00
|
|
|
async exec(message, args) {
|
|
|
|
let text = args.text;
|
2018-11-28 20:27:29 +01:00
|
|
|
|
2018-12-30 01:20:24 +01:00
|
|
|
// Load all the different files
|
2018-11-28 20:27:29 +01:00
|
|
|
const verb = require('../../dictionary/verbs.json')
|
2018-12-01 02:41:38 +01:00
|
|
|
const noun = require('../../dictionary/noun.json')
|
2018-12-03 03:45:03 +01:00
|
|
|
const adverbs = require('../../dictionary/adjectives.json')
|
2018-12-03 03:50:33 +01:00
|
|
|
const adjective = require('../../dictionary/adverbs.json')
|
2018-12-01 02:41:38 +01:00
|
|
|
const activities = require('../../dictionary/activities.json')
|
|
|
|
const celebreties = require('../../dictionary/celebreties.json')
|
|
|
|
const countries = require('../../dictionary/countries.json')
|
|
|
|
const diseases = require('../../dictionary/diseases.json')
|
|
|
|
const elements = require('../../dictionary/elements.json')
|
|
|
|
const hobbies = require('../../dictionary/hobbies.json')
|
|
|
|
const music = require('../../dictionary/music.json')
|
|
|
|
const prefixes = require('../../dictionary/prefixes.json')
|
|
|
|
const pronouns = require('../../dictionary/pronouns.json')
|
|
|
|
const states = require('../../dictionary/states.json')
|
|
|
|
const titles = require('../../dictionary/titles.json')
|
|
|
|
const units = require('../../dictionary/units.json')
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-11-28 20:27:29 +01:00
|
|
|
// 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)])
|
2018-12-03 03:45:03 +01:00
|
|
|
text = text.replace(/\[adverbs\]/, adverbs[randNumber(adverbs)])
|
2018-11-28 20:27:29 +01:00
|
|
|
text = text.replace(/\[noun\]/, noun[randNumber(noun)])
|
|
|
|
text = text.replace(/\[adjective\]/, adjective[randNumber(adjective)])
|
2018-12-01 04:32:32 +01:00
|
|
|
text = text.replace(/\[activities\]/, activities[randNumber(activities)])
|
2018-12-01 02:50:47 +01:00
|
|
|
text = text.replace(/\[celebrities\]/, celebreties[randNumber(celebreties)])
|
2018-12-01 04:32:32 +01:00
|
|
|
text = text.replace(/\[countries\]/, countries[randNumber(countries)])
|
2018-12-01 02:41:38 +01:00
|
|
|
text = text.replace(/\[diseases\]/, diseases[randNumber(diseases)])
|
|
|
|
text = text.replace(/\[elements\]/, elements[randNumber(elements)])
|
2018-12-01 04:32:32 +01:00
|
|
|
text = text.replace(/\[hobbies\]/, hobbies[randNumber(hobbies)])
|
2018-12-01 02:41:38 +01:00
|
|
|
text = text.replace(/\[music\]/, music[randNumber(music)])
|
2018-12-01 04:32:32 +01:00
|
|
|
text = text.replace(/\[prefixes\]/, prefixes[randNumber(prefixes)])
|
2018-12-01 02:41:38 +01:00
|
|
|
text = text.replace(/\[pronoun\]/, pronouns[randNumber(pronouns)])
|
|
|
|
text = text.replace(/\[state\]/, states[randNumber(states)])
|
|
|
|
text = text.replace(/\[title\]/, titles[randNumber(titles)])
|
|
|
|
text = text.replace(/\[unit\]/, units[randNumber(units)])
|
2018-11-28 20:27:29 +01:00
|
|
|
text = text.replace(/\[member\]/, message.guild.members.random().user.username)
|
2018-11-28 21:53:11 +01:00
|
|
|
text = text.replace(/\[number\]/, Math.floor((Math.random() * 9) + 1))
|
2018-12-01 02:41:38 +01:00
|
|
|
// Verify if it replaced everything
|
2018-12-03 03:45:03 +01:00
|
|
|
} while( text.includes('[verb]') || text.includes('[adverbs]') || text.includes('[noun]') || text.includes('[adjective]') || text.includes('[member]') || text.includes('[number]') || text.includes('[activities]') || text.includes('[celebrities]') || text.includes('[countries]') || text.includes('[diseases]') || text.includes('[elements]') || text.includes('[hobbies]') || text.includes('[music]') || text.includes('[prefixes]') || text.includes('[pronoun]') || text.includes('[state]') || text.includes('[title]') || text.includes('[unit]'))
|
2018-11-28 20:27:29 +01:00
|
|
|
|
|
|
|
// Send the final text
|
2018-12-30 01:20:24 +01:00
|
|
|
message.delete();
|
|
|
|
return message.channel.send(text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = SayCommand;
|