-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.js
60 lines (52 loc) · 2.09 KB
/
bot.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require('dotenv').config();
const Discord = require('discord.js');
const client = new Discord.Client();
const quotes = require('./quotes.json');
const birthdays = require('./birthdays.js').birthdays;
let unusedQuotes = [...quotes];
let stevenToday = false;
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('message', msg => {
if (msg.content === 'ping') {
msg.reply('pong!!!!!');
}
});
// This event will run on every single message received, from any channel or DM.
client.on("message", async message => {
// Bot will ignore itself and other bots
if (message.author.bot) return;
// Generates random and sends quote if message mentions @bobby (or author is steven once a day)
// Steven Id: 81532687680016384
if ((message.mentions.members && message.mentions.members.has(client.user.id))) {
// || (message.author.id === '81532687680016384' && !stevenToday)) {
if (message.author.id === '81532687680016384') stevenToday = true;
let index = Math.floor(Math.random() * unusedQuotes.length);
message.channel.send(unusedQuotes[index].toUpperCase());
console.log('Sending message')
console.log(unusedQuotes[index].toUpperCase())
unusedQuotes = unusedQuotes.slice(0, index).concat(unusedQuotes.slice(index + 1));
if (unusedQuotes.length <= quotes.length / 2) unusedQuotes = [...quotes];
}
});
// Reset Steven variable every morning
setInterval(() => {
if (new Date().getHours() === 0) {
stevenToday = false;
}
}, 3600000);
// Checks for birthdays so Robert can wish a happy nameday
setInterval(() => {
let today = new Date();
if (today.getHours() === 8) {
for (let birthday of birthdays) {
if (birthday.day.getMonth() === today.getMonth() && birthday.day.getDate() === today.getDate()) {
const mention = `<@${birthday.userID}>`
client.channels.get('414534539042619395').send("GODS BE GOOD. YOU'VE LIVED TO SEE ANOTHER NAMEDAY " + mention + ". NOW EAT, DRINK, AND WHORE YOUR WAY TO AN EARLY GRAVE!");
}
}
}
}, 3600000);
client.on('error', console.error);
client.login(process.env.DISCORD_TOKEN);