Merge pull request #14 from jondeaves/randomize-fix

Randomize fix
This commit is contained in:
Lance Krasniqi
2020-08-12 22:17:33 +02:00
committed by GitHub
2 changed files with 17 additions and 12 deletions

View File

@@ -25,7 +25,7 @@ export default class App {
// Triggers once after connecting to server
this._discordClient.once('ready', () => {
this._loggerService.log('info', 'The Bot is connected to Discord server');
this._loggerService.log('info', 'Venom is connected to the Discord server');
});
// Triggers on every message the bot can see
@@ -40,29 +40,29 @@ export default class App {
const command = commandList.get(commandName) || commandList.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (!command) {
return message.reply('Monkey no understand that command yet!');
return message.reply('looks like I haven\'t learned that trick yet!');
};
try {
await command.execute(message, args, prefix, commandList);
} catch (error) {
this._loggerService.log('error', error.message);
message.reply('there was an error trying to execute that command!');
message.reply('there was an error trying to follow that command!');
}
});
this._discordClient.on('guildMemberAdd', member => {
// base
const greetings = ["Hello, {name}! CA greets you!", "Welcome to CA, {name}!", "Hi {name}! Welcome to CA!"];
const greeting = greetings[Math.floor(Math.random() * greetings.length )];
const greeting = greetings[Math.floor(Math.random() * greetings.length - 1)];
// favor
const flavors = [
"As PROMISED, grab a free pie! Courtesy of {random}!",
"The water is pure here! You should ask {random} for their water purified water for a sip!",
"Welcome to CA! Home of the sane, the smart and {random}!"
"Home of the sane, the smart and {random}!"
];
const randomMember = member.guild.members.cache.random();
const flavor = flavors[Math.floor(Math.random() * flavors.length)];
const flavor = flavors[Math.floor(Math.random() * flavors.length - 1)];
// result
member.guild.systemChannel.send(greeting.replace('{name}', member.displayName) + " " + flavor.replace('{random}', randomMember.displayName));
});

View File

@@ -7,12 +7,17 @@ const command: ICommand = {
aliases: ['eightball', 'magicball', 'ball', 'wisdomball'],
description: 'Ask the magic eightball for advice!',
async execute(message: Discord.Message, args: string[]) {
const responses = ["as I see it, yes.", "err, ask again later.", "better not tell you now.", "that's hard to predict right now.",
"concentrate... and ask again.", "don't count on it.", "it is certain.", "it is decidedly so.", "most likely.", "no.",
"likely not.", "my sources say no.", "hmm, outlook not so good.", "outlook is good.", "not sure, try again.",
"as dubealex commands it: maybe!", "googliano'd the answer and uh, it's a yes?", "careful, but yes",
"signs point to yes.", "very doubtful.", "without a doubt.","yes.", "yes - definitely.", "yeah, you can rely on it."];
message.reply(responses[Math.floor(Math.random() * responses.length)]);
if (args.length == 0)
{
message.reply('where\'s the question?');
} else {
const responses = ["as I see it, yes.", "err, ask again later.", "better not tell you now.", "that's hard to predict right now.",
"concentrate... and ask again.", "don't count on it.", "it is certain.", "it is decidedly so, yes.", "most likely.", "no.",
"likely not.", "my sources say no.", "hmm, outlook not so good.", "okay, outlook is good.", "not sure, ask again later.",
"as dubealex commands it: maybe!", "googliano'd the answer and uh, it's a yes?", "careful, but yes",
"signs point to a yes.", "very doubtful, very doubtful.", "without a doubt.","yes.", "yes - definitely.", "yeah, you can rely on it."];
message.reply(responses[Math.floor(Math.random() * responses.length - 1)]);
}
},
};