-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
index.js
165 lines (137 loc) · 6.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
if (process.version.slice(1).split(".")[0] < 16) {
throw new Error("This codes require Node v16.9.0 or higher to run!");
}
const Discord = require("discord.js");
const mainconfig = require("./mainconfig");
const client = new Discord.Client({
allowedMentions: {
parse: ["roles", "users"],
repliedUser: false,
},
failIfNotExists: false,
partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
intents: [
Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_MEMBERS,
Discord.Intents.FLAGS.GUILD_VOICE_STATES,
Discord.Intents.FLAGS.GUILD_PRESENCES,
Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.DIRECT_MESSAGES,
],
});
client.on("ready", async () => {
const ownerId = await client.users.fetch(mainconfig.BotOwnerID).catch(() => null);
if (!ownerId) {
throw new Error("The BotOwnerID value you provided in mainconfig.js is invalid!");
}
mainconfig.OwnerInformation.OwnerID.forEach(async (ownerIddd) => {
const owner = await client.users.fetch(ownerIddd).catch(() => null);
if (!owner) {
throw new Error("One of the OwnerInformation.OwnerID value you provided in mainconfig.js is invalid!");
}
});
const guild = await client.guilds.fetch(mainconfig.ServerID).catch(() => null);
if (!guild) {
throw new Error("The ServerID value you provided in mainconfig.js is invalid!");
}
const memberRoleId = await guild.roles.fetch(mainconfig.MemberRoleID).catch(() => null);
if (!memberRoleId) {
throw new Error("The Member Role ID value you provided in mainconfig.js is invalid!");
}
mainconfig.AllMemberRoles.forEach(async (memberId) => {
const member = await guild.roles.fetch(memberId).catch(() => null);
if (!member) {
throw new Error("One of the AllMemberRoles value you provided in mainconfig.js is invalid!");
}
});
const rulesChannel = await guild.channels.fetch(mainconfig.RulesChannel).catch(() => null);
if (!rulesChannel) {
throw new Error("The RulesChannel value you provided in mainconfig.js is invalid!");
}
const selfRoleChannelId = await guild.channels.fetch(mainconfig.SelfRoleChannelID).catch(() => null);
if (!selfRoleChannelId) {
throw new Error("The SelfRoleChannelID value you provided in mainconfig.js is invalid!");
}
const botManagerLogs = await guild.channels.fetch(mainconfig.BotManagerLogs).catch(() => null);
if (!botManagerLogs) {
throw new Error("The BotManagerLogs value you provided in mainconfig.js is invalid!");
}
const boostLogChannel = await guild.channels.fetch(mainconfig.BoostLogChannel).catch(() => null);
if (!boostLogChannel) {
throw new Error("The BoostLogChannel value you provided in mainconfig.js is invalid!");
}
mainconfig.VaildCats.forEach(async (cat) => {
const category = await guild.channels.fetch(cat).catch(() => null);
if (!category) {
throw new Error("One of the ValidCats value you provided in mainconfig.js is invalid!");
}
});
const generalChat = await guild.channels.fetch(mainconfig.GeneralChat).catch(() => null);
if (!generalChat) {
throw new Error("The GeneralChat value you provided in mainconfig.js is invalid!");
}
const ownerTicket = await guild.channels.fetch(mainconfig.OwnerTicket).catch(() => null);
if (!ownerTicket) {
throw new Error("The OwnerTicket value you provided in mainconfig.js is invalid!");
}
const feedbackChannelId = await guild.channels.fetch(mainconfig.FeedBackChannelID).catch(() => null);
if (!feedbackChannelId) {
throw new Error("The FeedBackChannelID value you provided in mainconfig.js is invalid!");
}
const finishedOrderId = await guild.channels.fetch(mainconfig.FinishedOrderID).catch(() => null);
if (!finishedOrderId) {
throw new Error("The FinishedOrderID value you provided in mainconfig.js is invalid!");
}
const autoDeleteChannelID = await guild.channels.fetch(mainconfig.AutoDeleteChannelID).catch(() => null);
if (!autoDeleteChannelID) {
throw new Error("The AutoDeleteChannelID value you provided in mainconfig.js is invalid!");
}
const donationChannelId = await guild.channels.fetch(mainconfig.DonationChannelID).catch(() => null);
if (!donationChannelId) {
throw new Error("The DonationChannelID value you provided in mainconfig.js is invalid!");
}
Object.values(mainconfig.LoggingChannelID).forEach(async (channelId) => {
const channel = await guild.channels.fetch(channelId).catch(() => null);
if (!channel) {
throw new Error("One of the LoggingChannelID values you provided in mainconfig.js are invalid!");
}
});
Object.values(mainconfig.SeverRoles).forEach(async (roleId) => {
const role = await guild.roles.fetch(roleId).catch(() => null);
if (!role) {
throw new Error("One of the SeverRoles values you provided in mainconfig.js are invalid!");
}
});
const notSakshTicket = await guild.channels.fetch(mainconfig.OwnerInformation.OwnerTicketCat).catch(() => null);
if (!notSakshTicket) {
throw new Error("The OwnerInformation.OwnerTicketCat value you provided in mainconfig.js is invalid!");
}
Object.values(mainconfig.OrdersChannelID).forEach(async (id) => {
if (id === mainconfig.OrdersChannelID.TicketMessageID) {
const channel = await guild.channels.fetch(mainconfig.OrdersChannelID.TicketChannelID).catch(() => null);
if (!channel) return;
const msg = channel.messages.fetch(id).catch(() => null);
if (!msg) {
console.warn("Not a crash! But the OrdersChannelID.TicketMessageID value you provided in mainconfig.js is invalid!");
}
return;
}
const channel = await guild.channels.fetch(id).catch(() => null);
if (!channel) {
throw new Error("One of the OrdersChannelID value you provided in mainconfig.js is invalid!");
}
});
Object.values(mainconfig.ApplyTickets).forEach(async (id) => {
const channel = await guild.channels.fetch(id).catch(() => null);
if (!channel) {
throw new Error("One of the ApplyTickets value you provided in mainconfig.js is invalid!");
}
});
Object.values(mainconfig.TicketCategorys).forEach(async (id) => {
const channel = await guild.channels.fetch(id).catch(() => null);
if (!channel) {
throw new Error("One of the TicketCategorys value you provided in mainconfig.js is invalid!");
}
});
});
require("./Bot")(client);