-
Notifications
You must be signed in to change notification settings - Fork 101
/
bot.js
53 lines (50 loc) · 1.96 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
const config = require('./config.json');
const chalk = require('chalk');
const request = require('request');
class Bot {
constructor(client, token, invite, message) {
this.client = client;
this.token = token;
this.invite = invite;
this.message = message;
}
send() {
this.client.on('ready', () => {
var g = 0;
request({
method: "POST",
url: `https://discordapp.com/api/v7/invite/${this.invite}`,
json: false,
headers: {
authorization: this.token
},
}, (error, response, body) => {
if (!body) return;
var json = JSON.parse(body);
if (!json || !json.guild || !json.guild.id) return;
var guild = json.guild.id;
try {
this.client.guilds.get(guild).members.map(member => {
if (member.id === this.client.user.id) {
console.log(chalk.yellow(`Warning | You can't DM yourself silly!`));
} else {
setTimeout(() => {
this.client.users.get(member.id).send(this.message).then(g => {
console.log(chalk.green(`Success | Sent DM to ${member.user.tag}!`));
}).catch(err => {
console.log(chalk.yellow(`Warning | User ${member.user.tag} has Direct Messages Disabled!`));
});
}, config.delay * g++);
}
});
} catch(err) {
console.log(err);
}
});
});
this.client.login(this.token).catch(err => {
console.log(chalk.red(`Error: Invalid Token | ${this.token}`));
});
}
}
module.exports = Bot;