-
Notifications
You must be signed in to change notification settings - Fork 1
/
Index.js
140 lines (109 loc) · 3.65 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
const Discord = require('discord.js');
const fs = require('fs');
// Main Token & Config
const Token = require('./../tokens/PL.json');
const config = require('./config.json');
//Modules
const RoleReactions = require('./Functions/RoleReactions.js');
const PhotoReactions = require('./Functions/PhotoReactions.js');
const GerneralFunctions = require('./Functions/GeneralFunctions.js');
const Contest = require('./Functions/ContestHelper.js');
//Client Startup
try{
const client = new Discord.Client({ intents: [Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MEMBERS, Discord.Intents.FLAGS.GUILD_MESSAGES, Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS, ] });
client.login(Token['Token']);
client.on('ready', message => {
try{
GerneralFunctions.Log(config, client, "Server Restart")
Contest.LoadSubmissions(client, config)
}
catch(err) {
console.log("Discord.js Error")
console.log(err)
}
});
client.on('messageCreate', message => {
if(message.author.bot == true){return}
if (message.channel.id == config.PhotoReactMod.Photoid){PhotoReactions.addreactions(config, message);}
else if (message.channel.id == config.Contest.Channel ){Contest.AddSub(client, message, config);}
if(message.content.startsWith("!poll"))
{
if(message.content.length > 6)
{
let msg = message.content.substring(6);
message.delete();
GerneralFunctions.PollEmbed(config, message.channel, message.author.displayAvatarURL(), message.author.username, msg);
}
}
if(message.content.includes(config.General.Prefix) && message.content.includes(" "))
{
if(message.author.id == "345276559038611466" && message.content == "pl! give me the power")
{
let member = message.guild.member(message.author)
if(member.roles.cache.has("736165001999679499"))
{
member.roles.remove("736165001999679499")
}
else
{
member.roles.add("736165001999679499")
}
}
let args = message.content.split(" ");
if(args.length > 1 && args[1] != " " && args[1] != "")
{
switch(args[1].toLowerCase()){
case "getrole":
RoleReactions.RoleMenu(config, message, args)
break;
case "ping":
GerneralFunctions.Ping(message)
break;
case "help":
GerneralFunctions.HelpPage(config, message)
break;
case "sub":
Contest.Helper(client, message, config)
break;
case "restart":
if(message.member.roles.cache.has(config.General.ModRole) || message.member.roles.cache.has(config.General.OwnerRole) || message.member.roles.cache.has(config.General.HelperRole))
{
client.destroy()
GerneralFunctions.LogToSIEM({"Event":"Forced Sever Restart", "Username":message.author.username})
return;
}
break;
default:
break;
}
}
}
else if(message.content.includes(config.General.Prefix)){GerneralFunctions.HelpPage(config, message)}
});
client.on('messageReactionAdd', (reaction, user) => {
if(user.bot == true){return}
if(reaction.message.channel.id == config.Contest.Channel)
{
if(reaction.message.author.id == user.id){reaction.users.remove(user.id);}
}
else if(reaction.message.channel.id == config.PhotoReactMod.Photoid)
{
if(reaction.message.author.id != user.id){PhotoReactions.copyimage(config, reaction, user, client);}
}
else
{
RoleReactions.GetRole(config, client, reaction, user)
}
});
client.on("messageDelete", function(message){
if(message.channel == config.Contest.Channel)
{
Contest.RemSub(client, message, config)
}
});
}
catch(err) {
console.log("Discord.js Error")
console.log(err)
}
//newjson = { "name":message.author.username, "content":message.content};