forked from Supositware/Haha-Yes
merged random with say
This commit is contained in:
parent
645846403d
commit
e7703d83d0
2 changed files with 26 additions and 54 deletions
|
@ -1,50 +0,0 @@
|
||||||
const { Command } = require('discord.js-commando');
|
|
||||||
const SelfReloadJSON = require('self-reload-json');
|
|
||||||
const blacklist = require('../../blacklist');
|
|
||||||
module.exports = class RandomCommand extends Command {
|
|
||||||
constructor(client) {
|
|
||||||
super(client, {
|
|
||||||
name: 'random',
|
|
||||||
aliases: ['rand'],
|
|
||||||
group: 'fun',
|
|
||||||
memberName: 'test',
|
|
||||||
description: `replace what you send with random verb adjective ect ( exemple '{prefix} random i want you to [verb] with [noun]')`,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
key: 'text',
|
|
||||||
prompt: 'What do you want me to replace?',
|
|
||||||
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)
|
|
||||||
} while( text.includes('[verb]') || text.includes('[adverb]') || text.includes('[noun]') || text.includes('[adjective]') || text.includes('[member]') )
|
|
||||||
|
|
||||||
// Send the final text
|
|
||||||
message.say(text);
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -5,9 +5,10 @@ module.exports = class sayCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
super(client, {
|
super(client, {
|
||||||
name: 'say',
|
name: 'say',
|
||||||
|
aliases: ['repeat'],
|
||||||
group: 'fun',
|
group: 'fun',
|
||||||
memberName: 'say',
|
memberName: 'say',
|
||||||
description: `Repeat the text you send`,
|
description: `Repeat the text you send ( can also use [verb] [noun] [adverb] [adjective] [member] and [number] to get random thing )`,
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
key: 'text',
|
key: 'text',
|
||||||
|
@ -23,7 +24,28 @@ module.exports = class sayCommand extends Command {
|
||||||
if(blacklistJson[message.author.id])
|
if(blacklistJson[message.author.id])
|
||||||
return blacklist(blacklistJson[message.author.id] , message)
|
return blacklist(blacklistJson[message.author.id] , message)
|
||||||
|
|
||||||
message.delete();
|
|
||||||
|
// 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() * 10) + 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.say(text);
|
message.say(text);
|
||||||
}
|
}
|
||||||
};
|
};
|
Loading…
Reference in a new issue