This repository has been archived by the owner on Apr 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
354 lines (276 loc) · 8.99 KB
/
server.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
/*
This Source Code Form is subject to the terms of the GNU General Public License:
Copyright (C) 2021-2022 OPENBOTLIST CONTRUBUTORS
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
*/
const {
Client,
MessageEmbed,
Formatters: { hyperlink, time }
} = require('discord.js');
const { writeFileSync, readFileSync } = require('node:fs');
const { EventEmitter } = require('node:events');
const dbpath = './database.json';
const client = new Client({ disableEveryone: true, intents: 98303 }); // is 98303 enougth? -no
// DATABASE - a pretty basic one lmao
let i = 0;
let ii = 0;
var log = (m) => {
i++;
ii++;
};
var DB = {};
class db {
static load() {
log('loading');
DB = JSON.parse(readFileSync(dbpath).toString());
}
static save() {
writeFileSync(dbpath, JSON.stringify(DB));
}
static get(id) {
// log("get", id)
if (!DB[id]) return null;
return JSON.parse(JSON.stringify(DB[id])); // string -> parse :: deep copy
}
static set(id, val) {
//haha static go brr
// log("set", id, val)
DB[id] = val;
db.save();
}
static add(id, val) {
if (!DB[id]) DB[id] = 0;
DB[id] = Number(DB[id]) + val;
db.save();
}
static async fetch(id) {
return db.get(id);
}
static has(id) {
return Boolean(DB[id]);
}
static delete(id) {
return delete DB[id];
}
static lol() {
return ii;
}
}
db.load();
const options = {
prefix: '!',
token: process.env.token, // token reaveal
logs: {
modlogs: '966028505458556968'
},
k: {
k: 'k' // k.
},
team: ['396571938081865741', '544676649510371328'],
bottumrev:["928624781731983380"]
};
client.on('messageCreate', async (message) => {
const args = message.content.trim().split(/\s+/);
const command = args.shift().toLowerCase();
if (command === '!add-bot') {
const ADD_BOT_CHANNEL = '966397896176058428'; // id of the add-new bottum channel
if (message.channel.id !== ADD_BOT_CHANNEL) {
await message.channel.send(
'oh god ur cringe use this command at <#966397896176058428> smh ppl these days'
);
return;
}
if (message.channel.id === ADD_BOT_CHANNEL) {
// !add-bot <ID> <PREFIX> <SHORT DESC>
const id = args[0];
if (id === undefined) {
await message.channel.send('The ID of the Discord bot is required.');
return;
}
const user = await client.users.fetch(id).catch(() => null);
if (user === null) {
await message.channel.send('No bot with the specified ID exists.');
return;
}
if (!user.bot) {
await message.channel.send("That's not a bot.");
return;
}
const prefix = args[1];
if (prefix === undefined) {
await message.channel.send('You must specify the prefix of the bot.');
return;
}
if (prefix.length > 10) {
await message.channel.send(
"The prefix length can't be longer than 10 characters."
);
return;
}
const shortDesc = args[2];
if (shortDesc === undefined) {
await message.channel.send(
'You must provide a short description explaining how the bot really is and what purpose it serves (must be 150 characters or less).'
);
return;
}
if (shortDesc.length > 150) {
await message.channel.send(
"The short description can't be longer than 150 characters."
);
return;
}
db.set(id, {
name: user.username,
id,
prefix,
shortDesc,
approved: false,
owner: message.author.id
});
await message.author.send('Your bot has been added to the queue!'); //send it to PMs
await message.delete(); // this should delete the command message (!add-bot)
}
}
if (command === '!queue') {
// the queue system
// BOT NAME (PREFIX) - INVITE (NO PERMS) - INVITE (8 PERMS)
// if its apprvoed dont show it on the list
if (!options.team.includes(message.author.id)) {
await message.channel.send('You have to be in the team');
return;
}
const embed = new MessageEmbed().setTitle('***Queue***').setDescription(
Object.values(DB)
.filter((bot) => !bot.approved)
.map((bot) => {
const invite = `https://discord.com/oauth2/authorize?client_id=${bot.id}&scope=bot%20applications.commands&perms=`;
return `${bot.name} (${bot.prefix}) - ${hyperlink(
'invite (no perms)',
`${invite}0`
)} - ${hyperlink('invite (administrator perms)', `${invite}8`)}`;
})
.join('\n\n')
);
if (options.team.includes(message.author.id)) {
await message.channel.send({ embeds: [embed] });
return;
}
}
if (command === '!approve') {
if (!options.team.includes(message.author.id) && !options.bottumrev.includes(message.author.id)) {
await message.channel.send('You have to be in the team');
return;
}
if (options.team.includes(message.author.id) && options.bottumrev.includes(message.author.id)) {
const id = args[0];
if (id === undefined) {
await message.channel.send(
'You must provide the ID of the Discord bot you want to approve.'
);
return;
}
const user = await client.users.fetch(id).catch(() => null);
if (user === null) {
await message.channel.send('No bot with the specified ID exists.');
return;
}
if (!user.bot) {
await message.channel.send("That's not a bot.");
return;
}
if (!db.has(id)) {
await message.channel.send('That bot is not in the queue.');
return;
}
const bot = db.get(id);
const modLogEmbed = new MessageEmbed()
.setColor('GREEN')
.addField('BOT NAME', bot.name)
.addField('APPROVED BY', message.author.tag)
.setDescription(`Approved at: ${time(new Date(), 'F')}`);
// sends the bot owner a DM about their bots have been apporoved
const owner = await client.users.fetch(bot.owner).catch(() => null);
if (owner === null) {
db.delete(id);
await message.channel.send(
'Looks like the owner of that bot has been deleted.'
);
return;
}
await owner
.send({ content: 'WOOO! :tada: YOUR BOT HAS BEEN APPOROVED' })
.catch(() => undefined);
// send the log embed to mod logs channel;
const log = client.channels.cache.get(options.logs.modlogs);
await log.send({ embeds: [modLogEmbed] });
// make the approved option true on db;
bot.approved = true;
}
}
if (command === '!decline') {
if (!options.team.includes(message.author.id) && !options.bottumrev.includes(message.author.id)) {
await message.channel.send('You have to be in the team');
return;
}
if (options.team.includes(message.author.id) && options.bottumrev.includes(message.author.id)) {
const id = args[0];
const reason = args.slice(1).join(' ');
if (id === undefined) {
await message.channel.send(
'You must provide the ID of the Discord bot you want to decline.'
);
return;
}
const user = await client.users.fetch(id).catch(() => null);
if (user === null) {
await message.channel.send('No bot with the specified ID exists.');
return;
}
if (!user.bot) {
await message.channel.send("That's not a bot.");
return;
}
if (!db.has(id)) {
await message.channel.send('That bot is not in the queue.');
return;
}
const bot = db.get(id);
const modLogEmbed = new MessageEmbed()
.setColor('RED')
.addField('BOT NAME', bot.name)
.addField('DECLINED BY', message.author.tag)
.addField('REASON', reason)
.setDescription(`Declined at: ${time(new Date(), 'F')}`);
// sends the bot owner a DM about their bots have been declined
const owner = await client.users.fetch(bot.owner).catch(() => null);
if (owner === null) {
db.delete(id);
await message.channel.send(
'Looks like the owner of that bot has been deleted.'
);
return;
}
await owner
.send({
content: `NOOO.... YOUR BOT HAVE BEEN DECLINED FOR THIS REASON: ${reason}`
})
.catch(() => undefined);
// send the log embed to mod logs channel;
const log = client.channels.cache.get(options.logs.modlogs);
await log.send({ embeds: [modLogEmbed] });
db.delete(id);
}
}
});
client.login(options.token);