-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
1309 lines (1190 loc) · 56.9 KB
/
main.py
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
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import asyncio
import datetime
from multiprocessing.sharedctypes import Value
import os
import time
from profanity_check import predict
import discord
import pymongo
from discord.ext import commands
from discord.ext import tasks
from dotenv import load_dotenv
import short
from keep_alive import keep_alive
url = "https://cdn.discordapp.com/attachments/800381129223831592/814762083220324392/tuxpi.com.1613127751-removebg-preview.png"
website = "https://modbot.studio"
load_dotenv()
token = os.getenv("DISCORD_TOKEN")
intents = discord.Intents.default()
intents.members = True
red = 0xF04747
green = 0x43B581
orange = 0xFAA61A
client = pymongo.MongoClient(str(os.getenv("URL")))
mydb = client["mydatabase"]
prefixes = mydb["guild"]
warns = mydb["warns"]
embedVar = ""
css1 = ''
addedword = False
def get_prefix(bot, message):
if not message.guild:
return '/'
else:
a = prefixes.find_one({"_id": str(message.guild.id)})
return a["prefix"]
@tasks.loop(seconds=300)
async def change_status():
await bot.change_presence(status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.listening, name="/help in {} servers!".format(len(bot.guilds))))
bot = commands.AutoShardedBot(command_prefix=get_prefix, case_insensitive=True, intents=intents)
bot.launch_time = datetime.datetime.now()
bot.remove_command('help')
if __name__ == '__main__':
print("Loading extensions.....")
extensions = ['utils.default', 'utils.stats', 'utils.music', 'utils.log', 'utils.handler', 'utils.post']
for extension in extensions:
bot.load_extension(extension)
print("All the extensions were loaded.")
print("Waiting for bot to be ready......")
@bot.event
async def on_ready():
await bot.change_presence(status=discord.Status.online,
activity=discord.Activity(type=discord.ActivityType.listening,
name="/help in {} servers!".format(len(bot.guilds))))
print("Ready")
print("Logged in as {}".format(bot.user.name))
print("----------")
print("Using discord.py version", discord.__version__)
print(f"ID: {bot.user.id}")
print(f"Full username: {bot.user}")
print("----------")
change_status.start()
@bot.event
async def on_guild_remove(guild):
try:
query = {"_id": str(guild.id)}
prefixes.delete_one(query)
except Exception as e:
print(e)
emptylist = []
@bot.event
async def on_guild_join(guild):
default = {"_id": str(guild.id), "prefix": "/", "filter": True, "whitelist": emptylist, "language": 'en',
"welcomeMessage": False, "goodbyeMessage": False,
"lChannel": "empty",
"wMessage": 'Hey {{user}}, welcome to {{server}}! :wave:',
"gMessage": 'Noooooo! {{user}} left the server! :weary_face:', "wChannel": 'empty', "gChannel": 'empty',
"badWords": emptylist, "infractions": emptylist}
prefixes.insert_one(default)
embed = discord.Embed(title="Thanks for adding me to your server!",
description="I hope I could help you to make this server a better place!")
embed.set_author(name="modbot", url=website, icon_url=url)
embed.add_field(name="Get started", value="To view all my commands simply chat /help. ", inline=True)
embed.add_field(name="Get help",
value="If you need more help you can join the support server by [this link](https://discord.gg/N94NXsVNQg). To report ",
inline=True)
embed.add_field(name="Donations",
value="We really appreciate donation to support our developement and hosting!! Donate by [joining our support server](https://discord.gg/N94NXsVNQg) and sending \"donate\" in #general, thank you!!!",
inline=False)
embed.set_footer(text="To report any issue [join our support server](https://discord.gg/N94NXsVNQg).")
text_channels = guild.text_channels
for channel in text_channels:
try:
await channel.send(embed=embed)
except Exception as E:
print(E)
continue
else:
break
@bot.command()
@commands.cooldown(1, 60, commands.BucketType.user)
async def suggest(ctx, *, suggestion):
channel = bot.get_channel(811979160968888351)
await channel.send(f"{ctx.author} suggested '{suggestion}'")
@bot.command()
@commands.cooldown(1, 1, commands.BucketType.user)
async def uptime(ctx):
delta_uptime = datetime.datetime.now() - bot.launch_time
hours, remainder = divmod(int(delta_uptime.total_seconds()), 3600)
minutes, seconds = divmod(remainder, 60)
days, hours = divmod(hours, 24)
embed = discord.Embed(color=green)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Yeah!",
value=f"My uptime is {days}d, {hours}h, {minutes}m, {seconds}s.",
inline=True)
await ctx.send(embed=embed)
@bot.command()
@commands.cooldown(1, 10, commands.BucketType.user)
async def help(ctx):
page = {}
if not ctx.message.guild:
pre = '/'
else:
a = prefixes.find_one({"_id": str(ctx.guild.id)})
pre = a["prefix"]
page['1'] = discord.Embed(title='Help page 1/4', color=green)
page['1'].add_field(name=f"`TIP`",
value=f"You can use our [dashboard](https://dash.modbot.studio) (dash.modbot.studio) to customize modbot easily.",
inline=False)
page['1'].add_field(name=f"{pre}log <#channel>",
value=f"Set the log channel!",
inline=False)
page['1'].add_field(name=f"{pre}play",
value=f"Play a song! Just join a voice channel and type \"{pre}play <song name>\"! ",
inline=False)
page['1'].add_field(name=f"{pre}stop",
value=f"Stop the current playing song.",
inline=False)
page['1'].add_field(name=f"{pre}loop",
value="Loops the current playing song.",
inline=False)
page['1'].add_field(name=f"{pre}skip",
value=
f"Vote to skip to the next song in the queue. The requester can skip without voting.",
inline=False)
page['1'].add_field(name=f"{pre}now",
value=
f"Display current playing song.",
inline=False)
page['1'].add_field(name=f"{pre}volume",
value=f"Sets the player volume. Use \"{pre}volume <value>\". ",
inline=False)
page['1'].add_field(name=f"{pre}queue",
value=
f"Display the player queue.",
inline=False)
page['2'] = discord.Embed(title='Help page 2/4', color=green)
page['2'].add_field(name=f"{pre}addword",
value=f"Add a custom swear word to your server! Simple type '{pre}addword <word>' changing word to the desired word.",
inline=False)
page['2'].add_field(name=f"{pre}rmword",
value=f"Remove a custom swear word from your server's custom badwords! Simple type '{pre}rmword <word>' changing word to the desired word. You can only remove custom words. If you need to remove a default word just [join the support server](https://discord.gg/N94NXsVNQg) and ping the Developer or the Staff roles.",
inline=False)
page['2'].add_field(name=f"{pre}prefix",
value="Select your custom prefix! Just type \"/prefix <your new prefix>\" changing your new prefix to the desired prefix. If you forgot the prefix simply ping me.",
inline=False)
page['2'].add_field(name=f"{pre}whitelist",
value=
f"Simply whitelist an user from the swear words filter. To use this command type \"{pre}whitelist @user_mention\". You can whitelist an unlimited amount of members!",
inline=False)
page['2'].add_field(name=f"{pre}blacklist",
value=
f"Simply blacklist an user to the swear words filter. To use this command type \"{pre}blacklist @user_mention\". All members are blacklisted by default.",
inline=False)
page['2'].add_field(name=f"{pre}filter",
value=f"Simply turn ON/OFF the swear word filter, type \"{pre}filter <on/off>\".",
inline=False)
page['2'].add_field(name=f"{pre}kick",
value=
f"Kick a member, use \"{pre}kick @user_mention <optional reason>\".",
inline=False)
page['3'] = discord.Embed(title='Help page 3/4', color=green)
page['3'].add_field(name=f"{pre}infractions",
value=
f"Check how many infractions an user has! Use '{pre}infractions @user_ping'",
inline=False)
page['3'].add_field(name=f"{pre}clearall",
value=
f"Clear all the infractions for an user. Use '{pre}clearall @user_ping'",
inline=False)
page['3'].add_field(name=f"{pre}ban",
value=f"Ban a member, use \"{pre}ban @user_mention <optional reason>\".",
inline=False)
page['3'].add_field(name=f"{pre}unban",
value=f"Unban a member, use \"{pre}unban member_username#XXXX\".",
inline=False)
page['3'].add_field(name=f"{pre}mute",
value=
f"Mute an user. To use this command create a \"Muted\" role without the \"Send messages\" permission. Then type \"{pre}mute @user_mention\".",
inline=False)
page['3'].add_field(name=f"{pre}unmute",
value=
f"Unmute an user. To use this command you have to mute the user first and type \"{pre}unmute @user_mention\".",
inline=False)
page['3'].add_field(name=f"{pre}text",
value=
f"Create a new text channel. Use \"{pre}text <name of the channel>\". Discord willl automatically convert whitespaces into \"-\"",
inline=False)
page['3'].add_field(name=f"{pre}voice",
value=
f"Create a new voice channel. Use \"{pre}voice <name of the channel>\".",
inline=False)
page['3'].add_field(name=f"{pre}delete",
value=
f"Delete a text or a voice channel. You can also use /rm. For use this command just type \"{pre}rm channel-name\".",
inline=False)
page['4'] = discord.Embed(title='Help page 4/4', color=green)
page['4'].add_field(name=f"{pre}suggest",
value=
f"Suugest a new feature or report a bug to the developers! Use \"{pre}suggest <your suggestion>\". We accept any kind of idea, thank you for helping us!",
inline=False)
page['4'].add_field(name=f"{pre}short",
value=f"Short an url! Simply use '{pre}short <url to short>'",
inline=False)
page['4'].add_field(name=f"{pre}invite",
value=
"Create an instant invite to your server. Note that the generated invite will never expire and it will have unlimited uses.",
inline=False)
page['4'].add_field(name=f"{pre}info",
value=f"Get the join date of a member, use \"{pre}info @user_mention\".",
inline=False)
page['4'].add_field(name=f"{pre}purge",
value=
f"Purge as many messages as you want, use \"{pre}purge <numer of messages to delete>\"",
inline=False)
page['4'].add_field(name=f"{pre}uptime",
value=
"Check the bot uptime.",
inline=False)
page['4'].add_field(name=f"{pre}ping",
value="Check the bot's ping",
inline=False)
page['4'].add_field(name="More Info",
value=
f"You can get more info about modbot on https://modbot.studio. To contact the team directly [join the support server](https://discord.gg/N94NXsVNQg).")
number = 1
pagination = await ctx.send(embed=page[str(number)])
await pagination.add_reaction('⏪')
await pagination.add_reaction('⬅️')
await pagination.add_reaction('⏹')
await pagination.add_reaction('➡️')
await pagination.add_reaction('⏩')
def check(reaction, user):
return reaction.emoji in ['⬅️', '➡️', '⏹', '⏩', '⏪'] and user == ctx.author
while True:
try:
reaction, user = await bot.wait_for('reaction_add', timeout=600, check=check)
except asyncio.TimeoutError:
await pagination.delete()
break
else:
if reaction.emoji == '➡️':
number += 1
try:
await reaction.remove(ctx.author)
except:
pass
try:
await pagination.edit(embed=page[str(number)])
except KeyError:
number = 1
await pagination.edit(embed=page[str(number)])
elif reaction.emoji == '⬅️':
number -= 1
try:
await reaction.remove(ctx.author)
except:
pass
try:
await pagination.edit(embed=page[str(number)])
except KeyError:
number = 4
await pagination.edit(embed=page[str(number)])
elif reaction.emoji == '⏹':
try:
await pagination.clear_reactions()
except:
pass
break
elif reaction.emoji == '⏩':
number = 4
try:
await reaction.remove(ctx.author)
except:
pass
try:
await pagination.edit(embed=page[str(number)])
except KeyError:
number = 4
await pagination.edit(embed=page[str(number)])
elif reaction.emoji == '⏪':
number = 1
try:
await reaction.remove(ctx.author)
except:
pass
try:
await pagination.edit(embed=page[str(number)])
except KeyError:
number = 4
await pagination.edit(embed=page[str(number)])
## Accept command ##
@bot.command(pass_context=True)
@commands.has_permissions(send_messages=True)
@commands.cooldown(1, 1, commands.BucketType.user)
async def accept(message):
user = message.message.author
role = 'Verified'
try:
await user.add_roles(discord.utils.get(user.guild.roles, name=role))
await message.channel.purge(limit=1)
except Exception as e:
await message.send(
'Cannot assign role. Error: ' + str(e))
print('Cannot assign role. Error: ' + str(e))
## Ban command ##
@bot.command()
@commands.has_permissions(ban_members=True)
@commands.cooldown(1, 1, commands.BucketType.user)
async def ban(ctx, member: discord.Member, *, reason=None):
check = False
for i in member.roles:
if i in ctx.author.roles[1:]:
check = True
if check is True:
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name=":x:", value="I can't ban members with a role that is higher than mine!", inline=True)
await ctx.send(embed=embed)
else:
await member.ban(reason=reason)
embed = discord.Embed(color=orange)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name=":lock:", value=f"{member.mention} was banned by {ctx.author.mention}!", inline=True)
await ctx.send(embed=embed)
@ban.error
async def ban_error(ctx, error):
if isinstance(error, commands.BadArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Member not found",
value=f"{ctx.author.mention}, i could not found the member you tell me! Try again pinging the member to ban!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingPermissions):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Missing permissions",
value=f"{ctx.author.mention}, you don't have enough permissions to ban a member! You need the Ban members permission to use this command!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Member not found", value=f"{ctx.author.mention}, please tell me a member to ban!",
inline=True)
await ctx.send(embed=embed)
## Unban command ##
@bot.command()
@commands.cooldown(1, 1, commands.BucketType.user)
@commands.has_permissions(ban_members=True)
async def unban(ctx, *, member):
banned_users = await ctx.guild.bans()
member_name, member_discriminator = member.split('#')
for ban_entry in banned_users:
user = ban_entry.user
if (user.name, user.discriminator) == (member_name, member_discriminator):
await ctx.guild.unban(user)
embed = discord.Embed(color=green)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name=":unlock:", value=f"{member} was unbanned by {ctx.author.mention}!",
inline=True)
await ctx.send(embed=embed)
break
else:
embed = discord.Embed(color=green)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name=":x:", value=f"{member} could not be found in the list of banned users!",
inline=True)
await ctx.send(embed=embed)
break
@unban.error
async def unban_error(ctx, error):
if isinstance(error, commands.BadArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Member not found",
value=f"{ctx.author.mention}, i could not found the member you tell me! Try again typing the username and the discriminator of the user to unban!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingPermissions):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Missing permissions",
value=f"{ctx.author.mention}, you don't have enough permissions to unban a member! You need the Ban members permission to use this command!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Member not found", value=f"{ctx.author.mention}, please tell me a member to unban!",
inline=True)
await ctx.send(embed=embed)
## Kick command ##
@bot.command()
@commands.cooldown(1, 1, commands.BucketType.user)
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member, *, reason=None):
check = False
for i in member.roles:
if i in ctx.author.roles[1:]:
check = True
if check is True:
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name=":x:", value="I can't kick moderator/admins!", inline=True)
await ctx.send(embed=embed)
else:
await member.kick(reason=reason)
embed = discord.Embed(color=orange)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name=":lock:", value=f"{member.mention} was kicked by {ctx.author.mention}!", inline=True)
await ctx.send(embed=embed)
@kick.error
async def kick_error(ctx, error):
if isinstance(error, commands.BadArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Member not found",
value=f"{ctx.author.mention}, i could not found the member you tell me! Try again pinging the member to kick!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingPermissions):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Missing permissions",
value=f"{ctx.author.mention}, you don't have enough permissions to kick a member! You need the Kick members permission to use this command!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Member not found", value=f"{ctx.author.mention}, please tell me a member to kick!",
inline=True)
await ctx.send(embed=embed)
## Info command ##
@bot.command(aliases=['profile'])
@commands.cooldown(1, 1, commands.BucketType.user)
async def info(ctx, member: discord.Member):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Info",
value=f"{member.mention} joined the server at {member.joined_at}",
inline=True)
await ctx.send(embed=embed)
@info.error
async def info_error(ctx, error):
if isinstance(error, commands.BadArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Member not found",
value=f"{ctx.author.mention}, i could not found the member you tell me! Try again pinging the member to check!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Member not found", value=f"{ctx.author.mention}, please tell me a member to check!",
inline=True)
await ctx.send(embed=embed)
## Short command ##
@bot.command(name='short')
@commands.cooldown(1, 5, commands.BucketType.user)
async def short_url(ctx, *, url):
a = short.shorten(str(url))
embed = discord.Embed(color=green)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Done!", value=f"{ctx.author.mention}, your url was shorened! Copy it --> {a}",
inline=True)
await ctx.send(embed=embed)
## Clean command ##
@bot.command(pass_context=True, aliases=['purge'])
@commands.has_permissions(manage_messages=True)
@commands.cooldown(1, 1, commands.BucketType.user)
async def clean(ctx, limit1: int):
limit = limit1 + 1
await ctx.channel.purge(limit=limit)
embed = discord.Embed(color=green)
embed.set_author(name="modbot", url=website, icon_url=url)
embed.add_field(name="Done!", value=f"Purged {limit1} messages!", inline=True)
await ctx.send(embed=embed)
await ctx.message.delete()
@clean.error
async def clear_error(ctx, error):
if isinstance(error, commands.BadArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Bad value",
value=f"{ctx.author.mention}, you typed a bad number of messages to delete! Retry!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingPermissions):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Missing permissions",
value=f"{ctx.author.mention}, you don't have enough permissions to purge the chat! You need the Manage messages permission to use this command!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="No amount given!",
value=f"{ctx.author.mention}, please tell me an amount of messages to delete!",
inline=True)
await ctx.send(embed=embed)
## Mute command ##
@bot.command()
@commands.cooldown(1, 1, commands.BucketType.user)
@commands.has_permissions(administrator=True)
async def mute(ctx, member: discord.Member):
await member.add_roles(discord.utils.get(member.guild.roles, name='Muted'))
embed = discord.Embed(title="User Muted!",
description=f"**{member}** was muted by **{ctx.message.author}**!",
color=orange)
await ctx.send(embed=embed)
@mute.error
async def mute_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.send("ERROR 403! You don't have enough permissions to do it!"
)
if isinstance(error, commands.BadArgument):
await ctx.send("ERROR 400! You passed me a bad member to mute!")
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send("ERROR 400! Tell me the member to mute!")
## Unmute command ##
@bot.command()
@commands.cooldown(1, 1, commands.BucketType.user)
@commands.has_permissions(administrator=True)
async def unmute(ctx, user: discord.Member):
await user.remove_roles(discord.utils.get(user.guild.roles, name='Muted'))
embed = discord.Embed(title="User Unmuted!",
description=f"**{user}** was unmuted by **{ctx.message.author}**!",
color=green)
await ctx.send(embed=embed)
@unmute.error
async def unmute_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.send("ERROR 403! You don't have enough permissions to do it!"
)
if isinstance(error, commands.BadArgument):
await ctx.send("ERROR 400! You passed me a bad member to unmute!")
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send("ERROR 400! Tell me the member to unmute!")
## New text channel command ##
@bot.command(aliases=['new_txt', 'text'])
@commands.cooldown(1, 1, commands.BucketType.user)
async def new_text_channel(ctx, *, name):
guild = ctx.message.guild
await guild.create_text_channel(name)
embed = discord.Embed(color=green)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Done!", value=f"Successfully created the \"{name}\" channel!", inline=True)
await ctx.send(embed=embed)
@new_text_channel.error
async def new_text_channel_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Missing permissions",
value=f"{ctx.author.mention}, you don't have enough permissions to create a channel! You need the Manage channels permission to use this command!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="No name given",
value=f"{ctx.author.mention}, please tell me a name for the new channel!", inline=True)
await ctx.send(embed=embed)
## New channel command ##
@bot.command(aliases=['new_voice', 'voice'])
@commands.cooldown(1, 1, commands.BucketType.user)
async def new_voice_channel(ctx, *, name):
guild = ctx.message.guild
await guild.create_voice_channel(name)
embed = discord.Embed(color=green)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Done!", value=f"Successfully created the \"{name}\" channel!", inline=True)
await ctx.send(embed=embed)
@new_voice_channel.error
async def new_voice_channel_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Missing permissions",
value=f"{ctx.author.mention}, you don't have enough permissions to create a channel! You need the Manage channels permission to use this command!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="No name given",
value=f"{ctx.author.mention}, please tell me a name for the new channel!", inline=True)
await ctx.send(embed=embed)
## Ping command ##
@bot.command()
@commands.cooldown(1, 1, commands.BucketType.user)
async def ping(ctx):
embed = discord.Embed(color=green)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name=":ping_pong:", value=f"{ctx.author.mention}, my ping is {round(bot.latency * 1000)}ms!",
inline=True)
await ctx.send(embed=embed)
## Refresh command ##
@bot.command(name='refresh', hidden=True)
@commands.is_owner()
async def refresh(ctx):
msg = await ctx.send("Refreshing my status...")
await bot.change_presence(
activity=discord.Activity(
type=discord.ActivityType.listening,
name="/help in {} servers!".format(len(bot.guilds))))
time.sleep(1)
await msg.edit(content="Ok, i refreshed my status. I'm in {} servers.".
format(len(bot.guilds)))
## Upgrade command ##
@bot.command(name='upgrade', hidden=True)
@commands.is_owner()
async def upgrade(ctx):
await ctx.send("Under upgrade mode toggled.")
await bot.change_presence(
status=discord.Status.idle,
activity=discord.Activity(
type=discord.ActivityType.listening,
name="for upgrade......"))
## Invite command ##
@bot.command()
@commands.cooldown(1, 1, commands.BucketType.user)
async def invite(ctx):
link = await ctx.channel.create_invite(max_age=0)
embed = discord.Embed(color=green)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Done!", value=f"This is your invite link: {str(link)}", inline=True)
await ctx.send(embed=embed)
## Status command ##
@bot.command()
@commands.is_owner()
async def status(ctx):
embedVar = discord.Embed(title="Bot Info", color=green)
embedVar.set_thumbnail(url=bot.user.avatar_url)
embedVar.add_field(
name="Owner:", value='<@776713998682292274>', inline=False)
embedVar.add_field(name="Name:", value=bot.user.name, inline=False)
embedVar.add_field(name="ID:", value=bot.user.id, inline=False)
embedVar.add_field(
name="Ping:", value=f'{round(bot.latency * 1000)}ms', inline=False)
embedVar.add_field(
name="Total Servers in:",
value=f"{len(bot.guilds)} servers",
inline=False)
await ctx.send(embed=embedVar)
## Prefix command ##
@bot.command()
@commands.has_permissions(manage_guild=True)
@commands.cooldown(1, 10, commands.BucketType.user)
async def prefix(ctx, prefix):
query = {"_id": str(ctx.guild.id)}
new = {"$set": {"prefix": str(prefix)}}
prefixes.update_one(query, new)
await ctx.send(f'Prefix changed to {prefix}')
@prefix.error
async def prefix_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Missing permissions",
value=f"{ctx.author.mention}, you don't have enough permissions to change the prefix! You need the Manage server permission to use this command!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Invalid prefix", value=f"{ctx.author.mention}, please tell me a prefix to set!",
inline=True)
await ctx.send(embed=embed)
## Whitelist command ##
@bot.command()
@commands.cooldown(1, 1, commands.BucketType.user)
@commands.has_permissions(administrator=True)
async def whitelist(ctx, member: discord.Member):
query = {"_id": str(ctx.guild.id)}
new = {"$push": {"whitelist": str(member.id)}}
prefixes.update_one(query, new)
embed = discord.Embed(color=green)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Done!", value=f"{member.mention} has got whitelisted!", inline=True)
await ctx.send(embed=embed)
@whitelist.error
async def whitelist_error(ctx, error):
if isinstance(error, commands.BadArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Member not found",
value=f"{ctx.author.mention}, i could not found the member you tell me! Try again pinging the member to whitelist!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingPermissions):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Missing permissions",
value=f"{ctx.author.mention}, you don't have enough permissions to whitelist a member! You need the Administrator permission to use this command!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Member not found",
value=f"{ctx.author.mention}, please tell me a member to whitelist!", inline=True)
await ctx.send(embed=embed)
## Blacklist command ##
@bot.command()
@commands.cooldown(1, 1, commands.BucketType.user)
@commands.has_permissions(administrator=True)
async def blacklist(ctx, member: discord.Member = None):
try:
query = {'_id': str(ctx.guild.id)}
new = {"$pull": {"whitelist": str(member.id)}}
prefixes.update_one(query, new)
except:
pass
embed = discord.Embed(color=green)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Done!", value=f"{member.mention} has got blacklisted!", inline=True)
await ctx.send(embed=embed)
@blacklist.error
async def blacklist_error(ctx, error):
if isinstance(error, commands.BadArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Member not found",
value=f"{ctx.author.mention}, i could not found the member you tell me! Try again pinging the member to blacklist!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingPermissions):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Missing permissions",
value=f"{ctx.author.mention}, you don't have enough permissions to blacklist a member! You need the Administrator permission to use this command!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Member not found",
value=f"{ctx.author.mention}, please tell me a member to blacklist!", inline=True)
await ctx.send(embed=embed)
## Filter command ##
@bot.command(name='set-swear', aliases=['filter'])
@commands.cooldown(1, 5, commands.BucketType.user)
@commands.has_permissions(manage_guild=True)
async def set(ctx, *, arg: str):
if arg.lower() == "off":
try:
query = {"_id": str(ctx.guild.id)}
new = {"$set": {"filter": False}}
prefixes.update_one(query, new)
embed = discord.Embed(color=green)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Done!", value="The filter is now setted off!", inline=True)
await ctx.send(embed=embed)
except:
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name=":x:",
value=f"{ctx.author.mention}, the filter is already disabled in this server!",
inline=True)
await ctx.send(embed=embed)
if arg.lower() == "on":
try:
query = {"_id": str(ctx.guild.id)}
new = {"$set": {"filter": True}}
prefixes.update_one(query, new)
embed = discord.Embed(color=green)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Done!", value="The filter is now setted on!", inline=True)
await ctx.send(embed=embed)
except:
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name=":x:",
value=f"{ctx.author.mention}, the filter is already enabled in this server!",
inline=True)
await ctx.send(embed=embed)
@set.error
async def set_error(ctx, error):
if isinstance(error, commands.BadArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Inavlid option",
value=f"{ctx.author.mention}, please choose a valid option (on/off)!", inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingPermissions):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Missing permissions",
value=f"{ctx.author.mention}, you don't have enough permissions to disable the filter! You need the Administrator permission to use this command!",
inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Invalid option", value=f"{ctx.author.mention}, please tell me what to do (on/off)!",
inline=True)
await ctx.send(embed=embed)
@bot.command()
@commands.has_permissions(administrator=True)
@commands.cooldown(1, 1, commands.BucketType.user)
async def log(ctx, channel: str):
channel = channel.replace("<#", "")
channel = channel.replace(">", "")
query = {"_id": str(ctx.guild.id)}
new = {"$set": {"lChannel": str(channel)}}
prefixes.update_one(query, new)
embed = discord.Embed(color=green)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Done!", value=f"Log channel was set!",
inline=True)
await ctx.send(embed=embed)
@log.error
async def log_error(ctx, error):
if isinstance(error, commands.BadArgument):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Inavlid channel",
value=f"{ctx.author.mention}, please mention a real channel!", inline=True)
await ctx.send(embed=embed)
if isinstance(error, commands.MissingPermissions):
embed = discord.Embed(color=red)
embed.set_author(name="modbot", url=website,
icon_url=url)
embed.add_field(name="Missing permissions",
value=f"{ctx.author.mention}, you don't have enough permissions to disable the filter! You need the Administrator permission to use this command!",
inline=True)
await ctx.send(embed=embed)