-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
36 lines (29 loc) · 885 Bytes
/
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
const dotenv = require('dotenv');
dotenv.config();
const eris = require('eris');
const bot = new eris.Client(process.env.MeraBot_TOKEN);
const axios = require('axios');
bot.on('ready', () => {
console.log('Doge is ready!');
});
bot.on('messageCreate', async (msg) => {
const botWasMentioned = msg.mentions.find(
mentionedUser => mentionedUser.id === bot.user.id,
);
if (botWasMentioned) {
try {
await msg.channel.createMessage(
`Doge is here!`,
);
let dogeimage = await axios.get('https://dog.ceo/api/breeds/image/random');
await msg.channel.createMessage(dogeimage.data.message);
} catch (err) {
console.warn('Failed to respond to mention.');
console.warn(err);
}
}
});
bot.on('error', err => {
console.warn(err);
});
bot.connect();