This repository has been archived by the owner on Jun 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
90 lines (77 loc) · 3.02 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const Discord = require("discord.js");
const fs = require("fs");
const yaml = require('js-yaml');
const bot = new Discord.Client({ disableEveryone: true, ws: { intents: ['GUILDS', 'GUILD_MEMBERS', 'GUILD_MESSAGES'] }});
let Config = null;
try {
let fileContents = fs.readFileSync('./config.yml', 'utf8');
Config = yaml.load(fileContents);
}
catch (e) {
console.log(e);
}
//define command collection
bot.commands = new Discord.Collection();
// command handler
fs.readdir("./commands/", (err, file) => {
if (err) console.log(err);
let jsfile = file.filter(f => f.split(".").pop() === "js");
if (jsfile.length <= 0) {
console.log("Cant Find Commands");
return;
}
jsfile.forEach((f, i) => {
let props = require(`./commands/${f}`);
bot.commands.set(props.help.name, props);
});
console.log("All commands loaded successfully\n");
});
// D.JS Client listeners
bot.on("error", (e) => console.error(e));
bot.on("warn", (e) => console.warn(e));
//bot.on("debug", (e) => console.info(e));
bot.on('reconnecting', () => console.log('Reconnecting WS...'));
bot.on('disconnect', () => {
console.log('Disconnected, trying to restart...');
process.exit();
});
// NodeJS process listeners
process.on('unhandledRejection', console.error);
process.on('warning', console.warn);
//on ready statment
bot.on("ready", async() => {
console.log("Online!")
console.log("^ The above message is for Pterodactyl to pickup and mark the server as online. ^\n")
console.log("------------------------------------------------------------------------------------------------------")
console.log("The bot is now online")
console.log(`Logged in as ${bot.user.username} || ${bot.user.id}`)
console.log("------------------------------------------------------------------------------------------------------")
console.log(`Invite me to a server with the following link.\nhttps://discordapp.com/api/oauth2/authorize?client_id=${bot.user.id}&permissions=125952&scope=bot`);
console.log("------------------------------------------------------------------------------------------------------")
bot.user.setPresence({
status: "online",
activity: {
name: Config.Settings.StatusMessage,
type: Config.Settings.StatusType
}
});
});
bot.on("message", async message => {
if (message.author.bot) return;
let messageArray = message.content.split(" ");
let args = messageArray.slice();
let cmd = messageArray[0].toLowerCase();
args = messageArray.slice(1);
if (Config.Setup.Prefix == cmd.slice(0, 1)) {
let Commandfile = bot.commands.get(cmd.slice(Config.Setup.Prefix.length));
if (Commandfile) Commandfile.run(bot, message, args);
}else{
let num = Math.floor(Math.random() * 201);
if(num == 69){
message.channel.send("Thats a **#Beta** moment.")
}else if(num == 21){
message.channel.send("Thats a **#StairGang** moment.")
}
}
});
bot.login(Config.Setup.Token);