forked from demtario/mailer-discord-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
38 lines (31 loc) · 842 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
37
38
import { Client, RichEmbed } from 'discord.js'
class Bot {
constructor() {
this.client = new Client()
}
login(token) {
return new Promise((resolve) => {
this.client.login(token);
this.client.on('ready', () => {
console.log(`DiscordBot logged in as ${this.client.user.tag}!`);
resolve()
});
})
}
async destroy() {
await this.setStatus('Shutted down')
await this.client.destroy()
}
sendMessage(msg, channelName) {
const channel = this.client.channels.find(({name}) => name === channelName)
if(channel) {
channel.send(msg)
} else {
console.log(`Warning: Given channel name (${channelName}) does not exist!`)
}
}
async setStatus(status, type = 'PLAYING') {
await this.client.user.setActivity(status, { type })
}
}
export default Bot