-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
501 lines (429 loc) · 20.5 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
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
const Discord = require('discord.js');
const {Client , MessageEmbed} = require('discord.js');
const oof = new Client ();
const bot = new Discord.Client();
const ms = require('ms');
const fs = require('fs');
const moongose = require('mongoose')
const ping = require('minecraft-server-util');
const { error } = require('console');
moongose.connect("mongodb+srv://cutcopy:[email protected]/cutcopy?retryWrites=true&w=majority",{
useUnifiedTopology: true,
useNewUrlParser: true,
});
const token = 'enter discord token here';
var PREFIX = '-';
oof.on('ready',() =>{
console.log('bot is ready and online!')
})
bot.on('ready',() =>{
console.log('oof is ready and online!')
})
bot.on('messagereactionroleadd',(messageReaction,user) => {
console.log(user.username + 'reacted');
})
bot.on('guildMemberAdd',function(member){
member.send('Welcome to the server!')
let memberrole = member.guild.roles.cache.find(role => role.name === 'member');
member.roles.add(memberrole);
});
bot.on('message',message=>{
if(message.content === 'hello'){
message.reply('HELLO FRIEND!');
}
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]){
case 'info':
const embed = new Discord.MessageEmbed()
.setTitle('user information')
.addField('Player Name',message.author.username,true)
.addField('owner',message.guild.owner,true)
.addField('current server', message.guild.name,true)
.setColor(0xF1C40F)
.setThumbnail(message.author.avatarURL(true))
message.channel.send(embed);
break;
case 'ping':
const emb = new Discord.MessageEmbed()
.addField('pong',message.author.tag)
message.channel.send(emb);
break;
case 'clear':
if(message.member.roles.cache.find(role => role.name ==='Admin') || message.member.roles.cache.find(role => role.name ==='Staff')|| message.member.roles.cache.find(role => role.name === 'Owner') ) {
if(!args[1]){
const em = new Discord.MessageEmbed()
.setTitle('moderation')
.addField('please enter the number of messages to clear!',message.author.tag )
message.channel.send(em);
}
else{
if(args[1]<= 100){
message.channel.bulkDelete(args[1]);
}
else if(args[1]<=200){
message.channel.bulkDelete(100)
.then(message.channel.bulkDelete(args[1]-100))
}
else if(args[1]<=300){
message.channel.bulkDelete(100)
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(args[1]-200))
}
else if(args[1]<=400){
message.channel.bulkDelete(100)
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(args[1]-300))
}
else if(args[1]<=500){
message.channel.bulkDelete(100)
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(args[1]-400))
}
else if(args[1]<=600){
message.channel.bulkDelete(100)
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(args[1]-500))
}
else if(args[1]<=700){
message.channel.bulkDelete(100)
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(args[1]-600))
}
else if(args[1]<=800){
message.channel.bulkDelete(100)
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(args[1]-700))
}
else if(args[1]<=900){
message.channel.bulkDelete(100)
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(args[1]-800))
}
else if(args[1]<=1000){
message.channel.bulkDelete(100)
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(100))
.then(message.channel.bulkDelete(args[1]-900))
}
else if(args[1]>1000){
return message.reply('I dont clearing of messages above 1000');
}
else{
return message.reply('Invalid args');
}
const ded = new Discord.MessageEmbed()
.setTitle('moderation')
.addField('you succesfully cleared ' + args[1] + ' messages')
message.channel.send(ded);
}
return true;
}
else{
message.channel.send('you got no permsission to do it')
message.delete()
.then(message.channel.bulkDelete('1'))
.then( message.member.send('there was an error while performing that function : ' + 'you can not do that!'))
}
break;
case 'mute':
if(message.member.roles.cache.find(role => role.name === 'Staff')){
message.delete();
let person =message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[1]))
if(!person) return message.reply('Please send a valid username to mute');
let mainrole = message.guild.roles.cache.find(role => role.name === 'member');
let muterole = message.guild.roles.cache.find(role => role.name === 'Muted');
if(!muterole) return message.reply('There is no muted role present in the server')
let time = args[2];
if(!args[2]) return message.reply('Please enter a time limit to mute the user');
if(args[1] === bot.user.tag) return message.reply('Dont act oversmart and dont try to mute me or I will mute You')
if(args[1]=== `@${message.author}`) return message.reply('you cant mute ur self')
person.roles.add(muterole.id);
if(!args[3]) return message.reply('please speecify a reason to mute')
let ok = args.slice(3).join(' ')
const g = new MessageEmbed()
.setTitle('Moderation')
.addField('Muted',person.displayName,true)
.addField('Staff',message.author.tag,true)
.addField('time',time,true)
.addField('reason',ok,true)
message.channel.send(g)
setTimeout(function(){
person.roles.remove(muterole.id)
const l = new MessageEmbed()
.setTitle('Moderation')
.addField('Unmuted',person.displayName,true)
.addField('Staff',bot.user.tag,true)
message.channel.send(l)
},ms(time));
}
else{
message.reply('No permission')
}
break;
case 'unmute':
if(message.member.roles.cache.find(role => role.name === 'staff')){
message.delete();
if(!args[1]) return message.reply('please mesntion a user to unmuted')
let pers =message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[1]))
if(!pers) return message.reply('please enter a valid username(who is there in the server');
let mainrol = message.guild.roles.cache.find(role => role.name === 'member');
let muterol = message.guild.roles.cache.find(role => role.name === 'muted');
if( pers.roles.cache.find(role => role.name === 'Muted')){
pers.roles.remove(muterol)
const m = new MessageEmbed()
.addField('Unmuted',pers.displayName,true)
.addField('Staff',message.author.tag,true)
.setTitle('Moderation')
message.channel.send(m)
}
else
{
message.reply('The user mentioned is probably not muted')
}
}
else{
message.delete
message.reply('No permission')
}
break;
case 'suggest':
message.delete();
let cut =args.slice(1).join(' ')
if(!args[1] ){
return message.reply('please enter what u wanna suggest')
}
else{
let sChannel = message.guild.channels.cache.find(x => x.name === 'ꜱɴ┇suggestions');
if(!sChannel) return message.channel.send('your server has no suggestions channel')
const a = new MessageEmbed()
.setFooter(message.author.username)
.setTitle('Suggestion')
.setDescription(cut)
sChannel.send(a).then(messageReaction =>{
messageReaction.react("👎");
messageReaction.react("👍");
message.delete().catch(console.error);
})
return ;
}
case 'ddev':
if((message.author.id == 688237610636017714) || (message.author.id == 420616930819309589)){
let ddev = message.guild.roles.cache.find(role => role.name === 'Discord Dev')
if(!args[1]) return;
if(!args[2]) return;
if(!ddev) return;
let per = message.guild.member(message.mentions.users.first())
if(!per ) return;
if(args[1] === 'add'){
if(per.roles.cache.find(role => role.name===('Discord Dev'))) return;
per.roles.add(ddev)
}
else if(args[1] ==='remove'){
if(!per.roles.cache.find(role => role.name===('Discord Dev'))) return;
per.roles.remove(ddev)
}
else{
message.reply('invalid args')
}
}
break;
case 'warn':
message.delete()
if(message.member.roles.cache.find(role => role.name ==='Staff')){
if(!args[1]) return message.reply('Please mention a user to mute')
.then(message.channel.send('`Usage -warn <user> <reason>`'));
let perso =message.guild.member(message.mentions.users.first() || message.guild.members.cache.get(args[1]))
if(!perso) return message.reply('Invalid user')
.then(message.channel.send('`Usage -warn <user> <reason>`'));
if(!args[2]) return message.reply('Please specify a reason for warn')
.then(message.channel.send('`Usage -warn <user> <reason>`'));
let gh = '**'+args.slice(2).join(" ") +'**';
var ab = '1';
let warn = message.guild.roles.cache.find(role => role.name === 'Warns*1');
let war = message.guild.roles.cache.find(role => role.name === 'Warns*2');
let wa = message.guild.roles.cache.find(role => role.name === 'Warns*3');
let w = message.guild.roles.cache.find(role => role.name === 'Warns*4');
let warns = message.guild.roles.cache.find(role => role.name === 'Manywarns');
if(perso.roles.cache.find(role => role.name === 'Warns*1')){
ab = '2';
perso.roles.remove(warn.id)
perso.roles.add(war.id).catch(console.log(error))
}
else if(perso.roles.cache.find(role => role.name === 'Warns*2')){
ab = '3';
perso.roles.remove(war.id)
perso.roles.add(wa.id).catch(console.log(error))
}
else if(perso.roles.cache.find(role => role.name === 'Warns*3')){
ab = '4';
perso.roles.remove(wa.id)
perso.roles.add(w.id).catch(console.log(error))
}
else if(perso.roles.cache.find(role => role.name === 'Warns*4')){
ab = 'more than 4';
perso.roles.remove(w.id)
perso.roles.add(warns.id).catch(console.log(error))
}
else {
perso.roles.add(warn.id);
}
const hm = new MessageEmbed()
.setTitle('Moderation')
.addField("Warned",perso.displayName,true)
.addField("Staff",message.member.displayName,true)
.addField("Reason",gh,true)
.addField("Warncount",ab,true)
message.channel.send(hm);
}
else{
return message.reply('No permissions').catch(console.log(error));
}
break;
case 'announce':
{
if(message.channel.id == 641151742129602570 ){
if(!args[1]){
message.delete();
message.channel.send('please type something u want to announce')
}
else{
message.delete()
let desc = args.slice(1).join(' ')
const k = new MessageEmbed()
.setAuthor(message.author.username)
.setDescription(desc)
message.channel.send(k)
message.channel.send('@everyone')
message.member.send('your announcemnet has been send as' )
message.member.send(k)
}
}
else{
message.delete()
message.reply('invalid channel')
}
}
}
})
oof.on('message',message=>{
let args = message.content.substring(PREFIX.length).split(" ");
switch(args[0]){
case 'help':
const hi = new MessageEmbed()
.setTitle('help')
.setColor(0xFF0000)
.setDescription('the command is under developement');
message.member.send(hi);
break;
case 'say' :
if((message.author.id == 688237610636017714) || (message.author.id == 420616930819309589)){
message.delete()
let hmm = '**'+ args.slice(1).join(" ")+'**';
const gi = new MessageEmbed()
.setDescription(hmm)
.setColor(0xFF0000)
return message.channel.send(gi);
}
break;
case 'send':
message.delete();
if((message.author.id == 688237610636017714) || (message.author.id == 420616930819309589)){
if(!args[1]) return message.reply('Usage -send <channel name> <message>');
if(!args[2]) return message.reply('Usage -send <channel name> <message>');
let h = args[1];
let gf = message.guild.channels.cache.find(x => x.name === h );
if(!gf) return message.reply('invalid channel');
let pe = '**' + args.slice(2).join(" ")+'**';
let hj = new MessageEmbed()
.setDescription(pe)
.setColor(0xFF0000)
gf.send(hj);
}
break;
case 'poll':
const b = new MessageEmbed()
.setColor(0xFFC300)
.setTitle('Poll')
.setDescription('-poll to create a simple poll');
if(!args[1]) return message.channel.send(b);
if(message.channel.id == 690974232410193990 ){
let p = args.slice(1).join(" ");
const f = new MessageEmbed()
.setColor(0xFFC300)
.setTitle('Poll')
.setDescription("**" +p+"**")
.setFooter(`Poll created by ${message.author.tag}`);
message.channel.send(f).then(messageReaction =>{
messageReaction.react(`👎`);
messageReaction.react(`👍`);
message.delete().catch(console.error);
})
}
break;
case 'status':
ping('play.skullnetwork.net',2187 ,(error,response) => {
if(error) throw error
if(!args[1]){
const ip = 'play.skullnetwork.net'
const nab = new MessageEmbed()
.setTitle('Server Status')
.setColor(0xF1C40F)
.addField('Server IP ',ip,true)
.addField('version',response.version,true)
.addField('online players',response.onlinePlayers,true)
.addField('Max players',response.maxPlayers,true)
.setThumbnail('https://i.ibb.co/cC4HN4P/server-icon.png')
message.channel.send(nab)
}
else if( args[1]){
message.channel.send('please type only !status');
}
else if( args[2]){
message.channel.send('please type only !status');
}
else if( args[3]){
message.channel.send('please type only !status');
}
else{
const offline ='offline'
const ip = 'play.skullnetwork.net'
const hmm = new MessageEmbed()
.setTitle('Server Status')
.addField('Server IP ',ip,true)
.addField('server is',offline,true)
message.channel.send(hmm)
message.member.send('Dont worry, Server will be online soon')
}
})
break;
}
})
bot.login(token);
oof.login(token);