-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
103 lines (83 loc) · 2.76 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
99
100
101
102
103
//requirements
Discord = require('discord.js');
const config = require("./data/config.json");
const Init = require("./init.js");
client = new Discord.Client();
require("./common.js");
//cl
//ready
client.on('ready', () => {
console.log('ready')
Init.Core({"discord":Discord, "client":client})
Functions.Execute('init')
});
client.on("messageReactionAdd", async (msgReaction, user) => {
if (user.bot) return;
if(msgReaction.emoji.toString() == '✅') return;
let msg = msgReaction.message;
let emoji = msgReaction.emoji.toString();
await Functions.Execute('msgReactionAdd', msg, emoji, user);
});
client.on("messageReactionRemove", async (msgReaction, user) => {
if (user.bot) return;
if(msgReaction.emoji.toString() == '✅') return;
let msg = msgReaction.message;
let emoji = msgReaction.emoji.toString();
await Functions.Execute('msgReactionRemove', msg, emoji, user);
});
client.on("messageDelete", message =>{
Functions.Execute('discordLogs', 'messageDelete', message);
});
client.on("messageUpdate", async (oldmessage, message) =>{
await Functions.Execute('discordLogs', 'messageUpdate', oldmessage, message);
await Functions.Execute('channelCheck', message);
});
client.on("guildMemberAdd", async member =>{
await Functions.Execute('guildMemberAdd', member);
});
client.on("guildMemberRemove", async member =>{
await Functions.Execute('guildMemberRemove', member);
});
//commands
client.on('message', async message => {
if(message.author.bot) return;
let msgCheck = false;
if (message.channel.type != 'dm') {
await Functions.Execute('channelCheck', message).then(response => {
msgCheck = response;
});
}else {
await Functions.Execute('discordLogs', 'dm', message);
}
if (msgCheck) return;
var IsCommand = false;
var newprefix;
var content = message.content.toLowerCase();
if (typeof Commands.prefix === 'object')
for (let prfx of Commands.prefix) {
if (content.startsWith(prfx)) {
IsCommand = true;
newprefix = prfx;
}
}
else
if (content.startsWith(Commands.prefix)) {
IsCommand = true;
newprefix = Commands.prefix;
}
if (newprefix) {
let args = message.content.slice(newprefix.length).trim().split(/ +/g);
let command = args.shift().toLowerCase();
if (IsCommand) {
return Commands.Execute(command, message, args)
}
}
});
//errors
process.on('unhandledRejection', error => {
console.error('Unhandled promise rejection:', error);
});
client.on('shardError', error => {
console.error('A websocket connection encountered an error:', error);
});
client.login(config.token)