-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
39 lines (28 loc) · 1.08 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// the discord.js library
const Discord = require('discord.js');
const client = new Discord.Client();
// our discord token + the prefix for our commands
const { token, prefix } = require('./config.json');
// loads our quotes
const { quotes } = require('./quotes.json');
// message when the bot is ready!
client.on('ready', () => {
console.log('quote-bot succesfully loaded!');
});
// logs in with our token
client.login(token);
client.on('message', message => {
// checks if the message begins with our prefix and if the author of the message is not the bot itself
if (!message.content.startsWith(prefix) || message.author.bot) return;
// if the command is "#quote"
if (message.content === `${prefix}quote`) {
// get a random quote
const quoteIndex = Math.floor(Math.random() * quotes.length);
// gets the message
const quote = quotes[quoteIndex][0];
// gets the author
const author = quotes[quoteIndex][1];
// send the message in a neat format
message.channel.send('`🗨 ' + quote + '` - ' + author);
}
});