Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript discord bot 8 ball command

const Discord = require("discord.js");

module.exports.run = async (bot, message, args) => {

	//!8ball <question fjdksf>
	if(!args[2]) return message.reply("Please ask a full question!");
	let replies = ["Yes.", "No.", "I don't know.", "Ask again later"];
	
	let result = Math.floor((Math.random() * replies.length));
	let question = args.slice(1).join(" ");
	
	let ballembed = new Discord.RichEmbed()
	.setAuthor(message.author.tag)
	.setColor("#FF9900")
	.addField("Question", question)
	.addField("Answer", replies[result]);
	
	message.channel.send(ballembed)	
}
Comment

javascript discord bot 8 ball command

//THIS METHOD USES THE BOTKIT-DISCORD CONNECTOR
//To get it, open the terminal, navigate to your bot's folder and do
//$ npm install --save botkit-discord

const discordBotkit = require('botkit-discord');

const configuration = {
    token: 'YOUR_DISCORD_TOKEN'
};

const discordBot = discordBotkit(configuration);

discordBot.hears('.*', 'mention', (bot, message) => {
	const responses = [
		"It is certain",
		"It is decidedly so",
		"Without a doubt",
		"Yes – definitely",
		"You may rely on it",
		"As I see it",
		"yes",
		"Most Likely",
		"Outlook good",
		"Yes",
		"Signs point to yes"
	];
	const randomIndex = Math.floor(Math.random() * responses.length);
	bot.reply(message, responses[randomIndex]);
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: get keys objet javascript 
Javascript :: react material modal custom backdrop 
Javascript :: Ckeditor get content html 
Javascript :: get url parameter in react js 
Javascript :: electron app to exe 
Javascript :: express js params 
Javascript :: google apps script moment js 
Javascript :: enumerate node js 
Javascript :: chart.js change font color 
Javascript :: on member join discord js 
Javascript :: how to dynamically show image from local storage in react native 
Javascript :: js find node number in div 
Javascript :: js get all object styles 
Javascript :: js simulate click 
Javascript :: Do not know how to serialize a BigInt 
Javascript :: set html attribute jquery 
Javascript :: curl accept json 
Javascript :: get current screen name react navigation 
Javascript :: on_raw_reaction_add example 
Javascript :: float force loopback 
Javascript :: slide right jquery 
Javascript :: set focus javascript 
Javascript :: inline z-index react 
Javascript :: ngfor select angular 
Javascript :: $.dialog after create focus 
Javascript :: youtube skip 
Javascript :: input pattern for np whitespaces at the end or beginning 
Javascript :: javascript scroll to bottom of div 
Javascript :: mongoose count documents 
Javascript :: json object get field with at symbol 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =