-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
98 lines (87 loc) · 3.38 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
91
92
93
94
95
96
97
98
/*
DONE - TODO: The commands must be exported to `client-commands/commands.js`
TODO: Improve readability of code
DONE - TODO: All the command access are given by hardcodeduserid values, need to shift them to role based perms
TODO: The current error handling feels very inefficient
! Warning: Use only discord.js v13 and Node 16.6 or higher !
*/
require("dotenv").config();
const TOKEN = process.env.TOKEN;
const config = require('./config.json');
const prefix = config["prefix"];
const availableCommands = config["commands"];
const {
Client,
Intents
} = require("discord.js");
const botIntents = new Intents();
botIntents.add(
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_PRESENCES
);
// Create a new client instance
const client = new Client({
intents: botIntents
});
const commandFunctions = require("./client-commands/commands.js");
client.once("ready", () => {
console.log("Ready!");
commandFunctions.init(client);
});
client.on("messageCreate", (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
//ignore if no prefix
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if(message.type == "REPLY"){
return message.reply("Dont use the command with a reply");
}
if (availableCommands.includes(command)) {
commandFunctions.leave(message); //lol check if the server is mine or PESU 2019, otherwise leave
if (command === "ping") {
commandFunctions.ping(message);
} else if (command == "mute") {
commandFunctions.mute(message, args);
} else if (command == "unmute") {
commandFunctions.unmute(message, args);
} else if (command === "kick") {
commandFunctions.kick(message, args);
} else if (command === "kid") {
commandFunctions.kid(message, args);
} else if (command == "contribute" || command == "support") {
commandFunctions.support(message);
} else if (command == "nick" || command == "changenick") {
commandFunctions.nick(message, args);
} else if (command == "ban") {
commandFunctions.ban(message, args);
} else if (command == "unban") {
commandFunctions.unban(message, args);
} else if (command == "p" || command == "purge") {
commandFunctions.purge(message, args);
} else if (command == "e" || command == "echo"){
commandFunctions.echo(message, args);
} else if (command == "joke"){
commandFunctions.joke(message);
} else if (command == "thread"){
commandFunctions.thread(message, args);
} else if (command == "uptime"){
commandFunctions.uptime(message);
} else if (command == "server"){
commandFunctions.servers(message);
}
} else {
message.channel.send({
content: "I have no response for this shit",
reply: {
messageReference: message.id
},
});
}
});
process.on("uncaughtException", function(err) {
commandFunctions.error(err);
// console.log("Caught exception: " + err);
});
// Login to Discord with your client's token
client.login(TOKEN);