javascript discord bot 8 ball command

Solutions on MaxInterview for javascript discord bot 8 ball command by the best coders in the world

showing results for - "javascript discord bot 8 ball command"
Pauline
09 Mar 2019
1const Discord = require("discord.js");
2
3module.exports.run = async (bot, message, args) => {
4
5	//!8ball <question fjdksf>
6	if(!args[2]) return message.reply("Please ask a full question!");
7	let replies = ["Yes.", "No.", "I don't know.", "Ask again later"];
8	
9	let result = Math.floor((Math.random() * replies.length));
10	let question = args.slice(1).join(" ");
11	
12	let ballembed = new Discord.RichEmbed()
13	.setAuthor(message.author.tag)
14	.setColor("#FF9900")
15	.addField("Question", question)
16	.addField("Answer", replies[result]);
17	
18	message.channel.send(ballembed)	
19}
20
Dashawn
04 Jun 2016
1//THIS METHOD USES THE BOTKIT-DISCORD CONNECTOR
2//To get it, open the terminal, navigate to your bot's folder and do
3//$ npm install --save botkit-discord
4
5const discordBotkit = require('botkit-discord');
6
7const configuration = {
8    token: 'YOUR_DISCORD_TOKEN'
9};
10
11const discordBot = discordBotkit(configuration);
12
13discordBot.hears('.*', 'mention', (bot, message) => {
14	const responses = [
15		"It is certain",
16		"It is decidedly so",
17		"Without a doubt",
18		"Yes – definitely",
19		"You may rely on it",
20		"As I see it",
21		"yes",
22		"Most Likely",
23		"Outlook good",
24		"Yes",
25		"Signs point to yes"
26	];
27	const randomIndex = Math.floor(Math.random() * responses.length);
28	bot.reply(message, responses[randomIndex]);
29});
30