forked from victoria-lo/discordBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (35 loc) · 1016 Bytes
/
index.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
require('dotenv').config();
const Discord = require('discord.js');
const axios = require('axios');
const client = new Discord.Client();
let interval;
client.on('message', async msg => {
switch (msg.content) {
case "ping":
msg.reply("Pong!");
break;
case "!meme":
msg.channel.send("Here's your meme!");
const img = await getMeme();
msg.channel.send(img);
break;
case "!eye":
msg.channel.send("You are now subscribed to eye reminders.");
interval = setInterval (function () {
msg.channel.send("Please take an eye break now!")
.catch(console.error);
}, 3600000); //every hour
break;
case "!stop":
msg.channel.send("I have stopped eye reminders.");
clearInterval(interval);
break;
}
});
async function getMeme(){
const res = await axios.get('https://memeapi.pythonanywhere.com/');
console.log(res.data)
return res.data.memes[0].url;
}
//must be last line
client.login(process.env.CLIENT_TOKEN);