-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
2413 lines (2012 loc) · 96.6 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
# imports
import asyncio, shelve, aiofiles, discord, discord.utils, json, random, sys, datetime, string
from discord.ext import commands, tasks
from itertools import cycle
from time import timezone
from discord import *
from music import Player
#from reactionmenu import ButtonsMenu, ComponentsButton
from mcstatus import MinecraftServer
from dislash import *
# main bot setup
# set variables that might need editing
verText = '''Version 2.0.0 (SLASH COMMANDS! Full changelog: Post announcement embed commands (just like suggestions)
Pin qotds
Ping mc server
Fun fact command [delayed till next update sadly]
Clear queue on leave
Change help menus to use actually good gui
Poll command
Re enabled rob command but with a chance of losing
Slash commands
Fix starboard
add easter egg
add 'add qotd' command
redo every command with the new slash commands gui)'''
qotdH = 18 # Runs qotd in utc
qotdM = 25
robCooldown = 5
guildID = 831638462951456789 # if this isn't set qotd will not work
tonesList = {'s': 'sarcastic', 'j': 'joking', 'hj': 'half-joking', 'srs': 'serious', 'p': 'platonic', 'r': 'romantic',
'l': 'lyrics', 'ly': 'lyrics', 't': 'teasing', 'nm': 'not mad or upset', 'nc': 'negative connotation',
'neg': 'negative connotation', 'pc': 'positive connotation', 'pos': 'positive connotation',
'lh': 'lighthearted', 'nbh': 'nobody here', 'm': 'metaphorically', 'li': 'literally',
'rh': 'rhetorical question', 'gen': 'genuine question', 'hyp': 'hyperbole', 'c': 'copypasta',
'th': 'threat', 'cb': 'clickbait', 'f': 'fake', 'g': 'genuine'} # todo: add more tones
tonesList_enabled = True # change to false to disable tone detecting
actions = {'punch': ['punched', 'https://tenor.com/view/punchy-one-punch-man-anime-punch-fight-gif-16189288'],
'hi': ['said hi to', 'https://tenor.com/view/puppy-dog-wave-hello-hi-gif-13974826',
'https://tenor.com/view/hello-wave-cute-anime-cartoon-gif-7537923',
'https://tenor.com/view/hello-there-private-from-penguins-of-madagascar-hi-wave-hey-there-gif-16043627',
'https://tenor.com/view/cute-animals-mochi-mochi-peach-cat-goma-cat-wave-gif-17543358',
'https://tenor.com/view/baby-yoda-baby-yoda-wave-baby-yoda-waving-hi-hello-gif-15975082',
'https://tenor.com/view/hi-friends-baby-goat-saying-hello-saying-hi-hi-neighbor-gif-14737423',
'https://tenor.com/view/mr-bean-funny-hello-hi-wave-gif-3528683',
'https://tenor.com/view/yo-anime-hi-promised-neverland-gif-13430927'],
'run': ['ran away from', 'https://giphy.com/gifs/justin-g-run-away-fast-3o7ZetIsjtbkgNE1I4'],
'hug': ['hugged', 'https://giphy.com/gifs/loading-virtual-hug-ZBQhoZC0nqknSviPqT'],
'yeet': ['yeeted', 'https://giphy.com/gifs/memecandy-J1ABRhlfvQNwIOiAas'],
'highfive': ['high-fived', 'https://giphy.com/gifs/highfive-hifi-3oKIPnpZgBCniqStS8'],
'yeet': ['yeeted', 'https://tenor.com/view/yeet-lion-king-simba-rafiki-throw-gif-16194362']}
# initialize files
sConfig = shelve.open('config', writeback=True)
try:
print('Successfully loaded welcome channel as #' + sConfig['welcome'])
except KeyError:
print('Failed to load welcome channel.')
try:
print('Successfully loaded suggestion channel as #' + sConfig['suggestion'])
except KeyError:
print('Failed to load suggestion channel.')
try:
print('Successfully loaded starboard as #' + sConfig['star'])
except KeyError:
print('Failed to load starboard.')
try:
print('Successfully loaded logs channel as #' + sConfig['logs'])
except KeyError:
print('Failed to load logs channel.')
try:
print('Successfully loaded accepted/denied suggestions channel as #' + sConfig['suggestion2'])
except KeyError:
print('Failed to load accepted/denied suggestions channel.')
try:
print('Successfully loaded qotd channel as #' + sConfig['qotd'])
except KeyError:
print('Failed to load qotd channel.')
# load permissions
intents = discord.Intents.default()
intents.members = True
intents.messages = True
# load status
status = cycle(
['Try )help', 'Prefix - )'])
filteredMessage = None
usersOnRobCooldown = {}
@tasks.loop(seconds=5)
async def change_status():
await bot.change_presence(activity=discord.Game(next(status)))
# initialize
bot = commands.Bot(command_prefix="&", help_command=None, intents=intents)
#ButtonsMenu.initialize(bot)
slash = SlashClient(bot, show_warnings = True)
guilds = [831638462951456789, 851233957571067914]
bot.ticket_configs = {}
bot.warnings = {} # guild_id : {member_id: [count, [(admin_id, reason)]]}
@bot.event
async def on_ready():
for guild in bot.guilds:
async with aiofiles.open(f"{guild.id} warnings.txt", mode="a") as temp:
pass
bot.warnings[guild.id] = {}
for guild in bot.guilds:
async with aiofiles.open(f"{guild.id} warnings.txt", mode="r") as file:
lines = await file.readlines()
for line in lines:
data = line.split(" ")
member_id = int(data[0])
admin_id = int(data[1])
reason = " ".join(data[2:]).strip("\n")
try:
bot.warnings[guild.id][member_id][0] += 1
bot.warnings[guild.id][member_id][1].append((admin_id, reason))
except KeyError:
bot.warnings[guild.id][member_id] = [1, [(admin_id, reason)]]
for file in ["ticket_configs.txt"]:
async with aiofiles.open(file, mode="a") as temp:
pass
async with aiofiles.open("ticket_configs.txt", mode="r") as file:
lines = await file.readlines()
for line in lines:
data = line.split(" ")
bot.ticket_configs[int(data[0])] = [int(data[1]), int(data[2]), int(data[3])]
await qotd(self=bot)
print("Your bot is ready to be used.")
class BotData:
def __init__(self):
self.welcome_channel = None
self.goodbye_channel = None
self.suggestion_channel = None
self.starboard_channel = None
self.suggestion_channel_two = None
self.logs_channel = None
self.qotd_channel = None
botdata = BotData()
# load reaction roles, done later because they reference bot variables
# also load suggestion number
try:
bot.reaction_roles = sConfig['reaction']
except KeyError:
sConfig['reaction'] = []
try:
suggestionNumber = sConfig['snum']
except KeyError:
sConfig['snum'] = 0
try:
sentQotds = sConfig['qnum']
except KeyError:
sConfig['qnum'] = 0
sentQotds = 0
# test commands
@slash.command(
description="Tests the bot"
)
async def test(inter):
await inter.reply("Your test worked! " + str(inter.author))
@slash.command(
description="Gets a user's info",
options=[
Option("user", "Enter the user", Type.USER)
# By default, Option is optional
# Pass required=True to make it a required arg
]
)
async def user_info(inter, user = None):
user = user or inter.author
await inter.reply(user.name)
# ver command
@slash.command(
description="Replies with the version"
)
async def ver(ctx):
await ctx.reply(verText)
# help commands
@bot.event
async def on_message(message):
if bot.user.mentioned_in(message):
await message.channel.send(f'Run {bot.command_prefix}help for help.')
await bot.process_commands(message)
# the docs you're looking for are https://github.com/Defxult/reactionmenu/blob/335c5f838e793cc2ea46bb02d5c2a44da2c99bb8/README.md unless you updated, in which case idk somewhere near there
# Removed because slash commands dont need help
# A shame because the help gui looked super cool
# but
# it had to be done
# - j5155, 6/25/2021
""" @slash.command(
description="Sends a help GUI"
)
async def help(ctx):
helpChannel = ctx.channel
ctx.reply('Help loading...')
basicHelp = discord.Embed(title="Basic Help!", description="", color=discord.Color.green())
basicHelp.description += f"**{bot.command_prefix}test** : Tests to make sure the bot is working properly.\n"
basicHelp.description += f"\n"
basicHelp.description += f"**{bot.command_prefix}help** : The help command gives you a list of commands you can do with ths bot. you can also @ mention the bot in a message to get a list of commands.\n"
basicHelp.description += f"\n"
basicHelp.description += f"**{bot.command_prefix}moderator_help** : provides a list of moderator commands. Only staff members have access to this command.\n"
basicHelp.description += f"\n"
basicHelp.description += f"**{bot.command_prefix}quick_help** : gets a quick help message.\n"
basicHelp.description += f"\n"
basicHelp.description += f"**{bot.command_prefix}ver** : responds with the bot version and latest feature.\n"
basicHelp.description += f"\n"
basicHelp.description += f"**{bot.command_prefix}suggest (suggestion)** : suggests something in the suggestion channel.\n"
basicHelp.set_footer(text="Here is a list of commands the bot can do!", icon_url=bot.user.avatar_url)
ecoHelp = discord.Embed(title="Economy Help!", description="", color=discord.Color.green())
ecoHelp.description += f"**{bot.command_prefix}shop** : lists the buyable items you can get.\n"
ecoHelp.description += f"\n"
ecoHelp.description += f"**{bot.command_prefix}bal** : lists your balance.\n"
ecoHelp.description += f"\n"
ecoHelp.description += f"**{bot.command_prefix}withdraw (amount)** : lets you take however much money you want out of your bank account.\n"
ecoHelp.description += f"\n"
ecoHelp.description += f"**{bot.command_prefix}deposit (amount)** : lets you put however much money you want into your back account.\n"
ecoHelp.description += f"\n"
ecoHelp.description += f"**{bot.command_prefix}buy (item)** : lets you buy the item you want from the shop/\n"
ecoHelp.description += f"\n"
ecoHelp.description += f"**{bot.command_prefix}gamble (amount)** : gambles the amount of money you want to gamble.\n"
ecoHelp.description += f"\n"
ecoHelp.description += f"**{bot.command_prefix}bag** : lists the items you have bought from the store.\n"
ecoHelp.description += f"\n"
ecoHelp.description += f"**{bot.command_prefix}sell (item)** : sells an item back to the store for money, you will not get all the money you used to buy the item back.\n"
ecoHelp.description += f"\n"
ecoHelp.description += f"**{bot.command_prefix}send (user) (amount)** : sends specified amount of money to specified user.\n"
ecoHelp.description += f"\n"
ecoHelp.description += f"**{bot.command_prefix}coinflip (amount) (face) ** : bets on flipping a coin\n"
ecoHelp.description += f"\n"
ecoHelp.description += f"**{bot.command_prefix}roll (amount) (face) ** : bets on rolling a dice, run without an amount to not bet\n"
ecoHelp.description += f"\n"
ecoHelp.description += f"**{bot.command_prefix}leaderboard (amount of players you want listed)** : lists the specified amount of players based on who has the most money.\n"
ecoHelp.set_footer(text="Here is a list of commands the bot can do!", icon_url=bot.user.avatar_url)
funHelp = discord.Embed(title="Fun Help!", description="", color=discord.Color.green())
funHelp.description += f"**{bot.command_prefix}8ball** : Responds like an 8ball. You can also type **{bot.command_prefix}8b**\n"
funHelp.description += f"\n"
funHelp.description += f"**{bot.command_prefix}action (action) (user)** : Responds with a gif of your action. You can also type **{bot.command_prefix}a**\n"
funHelp.description += f"\n"
funHelp.description += f"**{bot.command_prefix}poll (description)** : Responds with a poll of your action.\n"
funHelp.set_footer(text="Here is a list of commands the bot can do!", icon_url=bot.user.avatar_url)
musicHelp = discord.Embed(title="Music Help!", description="", color=discord.Color.green())
musicHelp.description += f"**{bot.command_prefix}join** : Makes the bot join the music channel\n"
musicHelp.description += f"\n"
musicHelp.description += f"**{bot.command_prefix}leave** : Makes the bot leave the channel\n"
musicHelp.description += f"\n"
musicHelp.description += f"**{bot.command_prefix}play (song name, or link)** : Plays the song you requested\n"
musicHelp.description += f"\n"
musicHelp.description += f"**{bot.command_prefix}skip** : Adds a vote skip to the chat to vote on the song being skipped\n"
musicHelp.description += f"\n"
musicHelp.description += f"**{bot.command_prefix}queue** : Lists the songs in a queue\n"
musicHelp.description += f"\n"
musicHelp.description += f"**{bot.command_prefix}search (song name)** : Will provide you with links to the song you want to play (the first link is what the bot would have played)\n"
musicHelp.set_footer(text="Here is a list of commands the bot can do!", icon_url=bot.user.avatar_url)
mcHelp = discord.Embed(title="Minecraft Help!", description="", color=discord.Color.green())
mcHelp.description += f"**{bot.command_prefix}ping (ip)** : Replies with info about a Java server, by default pings the official HSC one\n"
mcHelp.set_footer(text="Here is a list of commands the bot can do!", icon_url=bot.user.avatar_url)
helpMenu = ButtonsMenu(ctx, back_button='◀️', next_button='▶️', menu_type=ButtonsMenu.TypeEmbed)
helpMenu.add_page(basicHelp)
helpMenu.add_page(ecoHelp)
helpMenu.add_page(funHelp)
helpMenu.add_page(musicHelp)
helpMenu.add_page(mcHelp)
# prev and next
npb = ComponentsButton(label='Previous', style = 1, custom_id=ComponentsButton.ID_PREVIOUS_PAGE)
prpb = ComponentsButton(label='Next', style = 1, custom_id=ComponentsButton.ID_NEXT_PAGE)
# first and last pages
fpb = ComponentsButton(label='First', style = 3, custom_id=ComponentsButton.ID_GO_TO_FIRST_PAGE)
lpb = ComponentsButton(label='Last', style = 3, custom_id=ComponentsButton.ID_GO_TO_LAST_PAGE)
# go to page
gtpb = ComponentsButton(label='Choose', style = 2, custom_id=ComponentsButton.ID_GO_TO_PAGE)
# end session
#esb = ComponentsButton(label='End', style = 4, custom_id=ComponentsButton.ID_END_SESSION)
helpMenu.add_button(npb)
helpMenu.add_button(prpb)
helpMenu.add_button(fpb)
helpMenu.add_button(lpb)
helpMenu.add_button(gtpb)
#helpMenu.add_button(esb)
await helpMenu.start(send_to=helpChannel) """
@slash.command(
description="Gets quick help"
)
async def quick_help(ctx):
info = await info_embed()
await ctx.reply(embed=info)
async def info_embed():
info = discord.Embed(title="Quick Help!", description="", color=discord.Color.green())
info.description += f"Do **{bot.command_prefix}minecraft_help** : to get quick help with the minecraft server.\n"
info.description += f"\n"
info.description += f"Do **{bot.command_prefix}discord_help** : to get quick help with the discord\n"
info.description += f"\n"
info.description += f"Do **{bot.command_prefix}faq** : to get a FAQ list.\n"
info.set_footer(
text="Thanks for using Homeschool Club quick help services. If you need more help please open a ticket.",
icon_url=bot.user.avatar_url)
return info
@slash.command(
description="Gets minecraft help"
)
async def minecraft_help(ctx):
mc = await minecraft_embed()
await ctx.reply(embed=mc)
async def minecraft_embed():
mc = discord.Embed(title="Minecraft server help!", description="", color=discord.Color.green())
mc.description += f"To get a rank on the minecraft server do **/shop** and you can right click on the rank you want to buy, if you have enough money to buy it. Keep in mind that this is in game money not real money.\n"
mc.description += f"\n"
mc.description += f"To set a home do **/sethome (home name)** and it will set your home. To go to a home that you already made do **/home (home name)** and you will teleport there.\n"
mc.description += f"\n"
mc.description += f"To get back to spawn at any time do **/spawn**\n"
mc.description += f"\n"
mc.description += f"To get to the lobby/spawn of any game do **/warp (warp name)** the warps to get to a spawn/lobby are **/warp FactionSpawn**, **/warp PvPLobby**, **/warp SandBoxSpawn** and **/warp SMPspawn**\n"
mc.set_footer(text="I hope this helped, if it didnt please open a ticket in the **help-tickets** channel",
icon_url=bot.user.avatar_url)
return mc
@slash.command(
description="Gets discord help"
)
async def discord_help(ctx):
disc_help = await discord_help_embed()
await ctx.reply(embed=disc_help)
async def discord_help_embed():
disc_help = discord.Embed(title="Discord server help!", description="", color=discord.Color.green())
disc_help.description += f"To get a rank on the discord server, do **{bot.command_prefix}shop** and buy your rank, keep in mind you need to have enough money to buy it.\n"
disc_help.description += f"\n"
disc_help.description += f"To suggest something do **{bot.command_prefix}suggest (suggestion)** and you suggestion will be sent.\n"
disc_help.description += f"\n"
disc_help.description += f"To earn money, you will have to do **{bot.command_prefix}beg** and to earn money if a fun way, if you already have money, you can do **{bot.command_prefix}gamble (amount)**\n"
disc_help.set_footer(text="I hope this helped, if it didn't please open a ticket in the **help-tickets** channel",
icon_url=bot.user.avatar_url)
return disc_help
@slash.command(
description="Gets a FAQ"
)
async def faq(ctx):
FAQ = await faq_embed()
await ctx.reply(embed=FAQ)
async def faq_embed():
FAQ = discord.Embed(title="this is the FAQ section, you can read frequently asked questions here.", description="",
color=discord.Color.green())
FAQ.description += f"How do i get a vip/mvp rank? : To get a VIP or MVP rank you must go on the minecraft server and do **/shop** Once you do that command you will find the ranks and their prices, remember that they are in game currency and not real life money.\n"
FAQ.description += f"\n"
FAQ.description += f"How do i open a ticket? : to open a ticket you can go to #help-tickets and react to the message there to open a ticket.\n"
FAQ.description += f"\n"
FAQ.description += f"What do we do here? : This is a server for anyone who is homeschooled, feel free to invite your friends. To get an invite for your friends just open a ticket and you will get an invite that can invite one(1) person.\n"
FAQ.description += f"\n"
FAQ.description += f"How do i get the edgy role? : to get the edgy role just @ mention a staff member or moderator, and they can give you the role.\n"
FAQ.description += f"\n"
FAQ.description += f"How do i get the YouTuber rank? : To get the YouTuber rank you must have 50 subscribers or more, as said in the rules.\n"
FAQ.set_footer(text="I hope this helped, if it didn't please open a ticket in the **help-tickets** channel",
icon_url=bot.user.avatar_url)
return FAQ
# Removed because slash commands dont need help
# A shame because the help gui looked super cool
# but
# it had to be done
# - j5155, 6/25/2021
''' @slash.command(
description="Gets moderator help",
)
@slash_commands.has_role("━━ « ( ⍟ Staff Team ⍟ ) » ━━")
async def moderator_help(ctx):
await ctx.reply('Help menu loading...')
moderator1 = discord.Embed(title="Basic Help!", description="", color=discord.Color.green())
moderator1.description += f"**{bot.command_prefix}warn (member) (reason)** : warns a member for an infraction of the rules.\n"
moderator1.description += f"\n"
moderator1.description += f"**{bot.command_prefix}warnings (member)** : provides a list of warnings from that member, with who gave the warning, and what the warning was for.\n"
moderator1.description += f"\n"
moderator1.description += f"**{bot.command_prefix}mute (@member)** : mutes the mentioned member\n"
moderator1.description += f"\n"
moderator1.description += f"**{bot.command_prefix}unmute (member ID) or (username + gamertag with no space between them)** : unmutes a muted member.\n"
moderator1.description += f"\n"
moderator1.description += f"**{bot.command_prefix}purge (amount)** : deletes the amount of messages in the command. remember to put 1 number more than the amount of messages you want to delete, because the bot needs to delete the purge message too.\n"
moderator1.description += f"\n"
moderator1.description += f"**{bot.command_prefix}kick (@member)** : requires trialstaff or higher to preform this command. This command kicks a member from the server.\n"
moderator1.description += f"\n"
moderator1.description += f"**{bot.command_prefix}ban (@member)** : bans the member mentioned.\n"
moderator1.description += f"\n"
moderator1.description += f"**{bot.command_prefix}unban (member ID) or (username and gamertag)** : unbans the member with the ID you sent in the command.\n"
moderator1.set_footer(text="Please note that normal members do not have permission to use these commands.",
icon_url=bot.user.avatar_url)
moderator2 = discord.Embed(title='Suggestion Help!', description='', color=discord.Color.green())
moderator2.description += f"**{bot.command_prefix}accept (reason)**: run this command while replying to a suggestion to move it to the decided suggestions channel\n"
moderator2.description += f"\n"
moderator2.description += f"**{bot.command_prefix}deny (reason)**: run this command while replying to a suggestion to move it to the decided suggestions channel\n"
moderator2.description += f"\n"
moderator2.description += f"**{bot.command_prefix}implement (reason)**: run this command while replying to a suggestion to move it to the decided suggestions channel\n"
moderator2.set_footer(text="Please note that normal members do not have permission to use these commands.",
icon_url=bot.user.avatar_url)
moderator3 = discord.Embed(title='Configuration Help!', description = '', color=discord.Color.green())
moderator3.description += f"**{bot.command_prefix}ticket_config** : Displays configuration of the tickets.\n"
moderator3.description += f"\n"
moderator3.description += f"**{bot.command_prefix}configure_ticket** : sets up the ticket reaction message by configuring the ticket.\n"
moderator3.description += f"\n"
moderator3.description += f"**{bot.command_prefix}set_welcome_channel** : sets the welcome channel of the server.\n"
moderator3.description += f"\n"
moderator3.description += f"**{bot.command_prefix}set_goodbye_channel** : sets the goodbye channel of the server.\n"
moderator3.description += f"\n"
moderator3.description += f"**{bot.command_prefix}set_reaction (role) (message id) (emoji)**: set a reaction role\n"
moderator3.description += f"\n"
moderator3.description += f"**{bot.command_prefix}reset_snum (number)**: set the number of suggestions, next suggestion will be this plus 1\n"
moderator3.description += f"\n"
moderator3.description += f"**{bot.command_prefix}reset_qnum (number)**: set the number of posted qotds, next qotd will be this plus 1\n"
moderator3.description += f"\n"
moderator3.description += f"**{bot.command_prefix}set_decided_suggestion_channel (channel)**: set the channel for decided suggestions\n"
moderator3.description += f"\n"
moderator3.description += f"**{bot.command_prefix}set_logs_channel (channel)**: set the channel for modlogs\n"
moderator3.description += f"\n"
moderator3.description += f"**{bot.command_prefix}set_qotd_channel** : sets the qotd channel of the server.\n"
moderator3.set_footer(text="Please note that normal members do not have permission to use these commands.",
icon_url=bot.user.avatar_url)
moderator4 = discord.Embed(title='Music Help!', description = '', color=discord.Color.green())
moderator4.description += f"**{bot.command_prefix}fskip** : Skips the current song that is playing.\n"
moderator4.set_footer(text="Please note that normal members do not have permission to use these commands.",
icon_url=bot.user.avatar_url)
modHelpMenu = ButtonsMenu(ctx, back_button='◀️', next_button='▶️', menu_type=ButtonsMenu.TypeEmbed)
modHelpMenu.add_page(moderator1)
modHelpMenu.add_page(moderator2)
modHelpMenu.add_page(moderator3)
modHelpMenu.add_page(moderator4)
# first and last pages
# prev and next
npb = ComponentsButton(label='Previous', style = 1, custom_id=ComponentsButton.ID_PREVIOUS_PAGE)
prpb = ComponentsButton(label='Next', style = 1, custom_id=ComponentsButton.ID_NEXT_PAGE)
# first and last pages
fpb = ComponentsButton(label='First', style = 3, custom_id=ComponentsButton.ID_GO_TO_FIRST_PAGE)
lpb = ComponentsButton(label='Last', style = 3, custom_id=ComponentsButton.ID_GO_TO_LAST_PAGE)
# go to page
gtpb = ComponentsButton(label='Choose', style = 2, custom_id=ComponentsButton.ID_GO_TO_PAGE)
# end session
#esb = ComponentsButton(label='End', style = 4, custom_id=ComponentsButton.ID_END_SESSION)
modHelpMenu.add_button(npb)
modHelpMenu.add_button(prpb)
modHelpMenu.add_button(fpb)
modHelpMenu.add_button(lpb)
modHelpMenu.add_button(gtpb)
await modHelpMenu.start() '''
# starboard
@slash.command(
description="Sets the starboard channel",
options=[
Option("channel", "Enter the channel", Type.CHANNEL)
# By default, Option is optional
# Pass required=True to make it a required arg
]
)
@slash_commands.has_role("━━ « ( ⍟ Staff Team ⍟ ) » ━━")
async def set_starboard(ctx, channel=None):
if channel != None:
channel_name = channel.name
for channel in ctx.guild.channels:
if channel.name == channel_name:
botdata.starboard_channel = channel
sConfig['star'] = channel_name
sConfig.sync()
await ctx.reply(f"Starboad has been set to: {channel.name}")
# await channel.send("This is the new welcome channel!")
return
await ctx.reply(
"Invalid channel. Make sure you're sending a channel name (welcome), and not a channel link (#welcome).")
# ticket system
@bot.event
async def on_raw_reaction_add(payload):
guild = bot.get_guild(payload.guild_id)
if payload.member.id != bot.user.id and str(
payload.emoji) == '⭐': # thanks https://stackoverflow.com/questions/65156352
rguild = bot.get_guild(payload.guild_id)
rchannel = bot.get_channel(payload.channel_id)
rmessage = await rchannel.fetch_message(payload.message_id)
reaction = discord.utils.get(rmessage.reactions, emoji=payload.emoji.name)
if payload.member.id == rmessage.author.id:
await reaction.remove(payload.member)
elif reaction and reaction.count == 3:
if botdata.starboard_channel == None:
for channel in rguild.channels:
if channel.name == sConfig['star']:
botdata.starboard_channel = channel
embed = discord.Embed(color=15105570)
embed.set_author(name=rmessage.author.name, icon_url=rmessage.author.avatar_url)
embed.add_field(name="Message Content", value=rmessage.content)
embed.add_field(name='Link', value='[Jump!](%s)' % rmessage.jump_url)
if len(reaction.message.attachments) > 0:
embed.set_image(url=reaction.message.attachments[0].url)
embed.set_footer(text=f" ⭐ {reaction.count} | # {reaction.message.channel.name}")
embed.timestamp = datetime.datetime.utcnow()
await botdata.starboard_channel.send(embed=embed)
for role, msgid, emoji in sConfig['reaction']:
if msgid == payload.message_id and emoji == payload.emoji.name:
await payload.member.add_roles(guild.get_role(role))
if payload.member.id != bot.user.id and str(payload.emoji) == u"\U0001F3AB":
msg_id, channel_id, category_id = bot.ticket_configs[payload.guild_id]
if payload.message_id == msg_id:
guild = bot.get_guild(payload.guild_id)
for category in guild.categories:
if category.id == category_id:
break
channel = guild.get_channel(channel_id)
ticket_num = 1 if len(category.channels) == 0 else int(category.channels[-1].name.split("-")[1]) + 1
ticket_channel = await category.create_text_channel(f"ticket-{payload.member.display_name}",
topic=f"A ticket for {payload.member.display_name}.",
permission_synced=True)
await ticket_channel.set_permissions(payload.member, read_messages=True, send_messages=True)
message = await channel.fetch_message(msg_id)
await message.remove_reaction(payload.emoji, payload.member)
await ticket_channel.send(
f"{payload.member.mention} Thank you for creating a ticket! Use **&close** to close your ticket. The staff team (<@&705864664302747751>) will be with you shortly.")
try:
await bot.wait_for("message", check=lambda
m: m.channel == ticket_channel and m.author == payload.member and m.content == "&close",
timeout=1000)
except asyncio.TimeoutError:
await ticket_channel.delete()
else:
await ticket_channel.delete()
def in_ticket():
def predicate(inter):
return inter.channel.category.name == 'Player Support'
return check(predicate)
@in_ticket()
@slash.command(
description="Closes a ticket",
)
async def close(ctx):
if ctx.channel.category.name == 'Player Support':
await ctx.reply('Channel closed.')
await ctx.channel.delete()
else:
ctx.reply('This command only works in tickets.')
@slash_commands.has_role("Administrator")
@slash.command(
description="Configure ticket",
options=[
Option("message_id", "Enter the id of the message", Type.STRING, required=True),
Option("category", "Enter the category", Type.STRING, required=True)
# By default, Option is optional
# Pass required=True to make it a required arg
]
)
async def configure_ticket(ctx, msg: discord.Message = None, category: discord.CategoryChannel = None):
if msg is None or category is None:
await ctx.reply("Failed to configure the ticket as an argument was not given or was invalid.")
return
bot.ticket_configs[ctx.guild.id] = [msg.id, msg.channel.id, category.id] # this resets the configuration
async with aiofiles.open("ticket_configs.txt", mode="r") as file:
data = await file.readlines()
async with aiofiles.open("ticket_configs.txt", mode="w") as file:
await file.write(f"{ctx.guild.id} {msg.id} {msg.channel.id} {category.id}\n")
for line in data:
if int(line.split(" ")[0]) != ctx.guild.id:
await file.write(line)
await msg.add_reaction(u"\U0001F3AB")
await ctx.reply("Successfully configured the ticket system.")
@slash_commands.has_role("━━ « ( ⍟ Staff Team ⍟ ) » ━━")
@slash.command(
description="View ticket configuration",
)
async def ticket_config(ctx):
try:
msg_id, channel_id, category_id = bot.ticket_configs[ctx.guild.id]
except KeyError:
await ctx.reply("You have not configured the ticket system yet.")
else:
embed = discord.Embed(title="Ticket system configurations.", color=discord.Color.green())
embed.description = f"**Reaction message ID** : {msg_id}\n"
embed.description += f"**Ticket category ID** : {category_id}\n\n"
await ctx.reply(embed=embed)
# welcome and leave messages
@slash_commands.has_role("━━ « ( ⍟ Staff Team ⍟ ) » ━━")
@slash.command(
description="Sets the welcome channel",
options=[
Option("channel", "Enter the channel", Type.CHANNEL, required=True)
# By default, Option is optional
# Pass required=True to make it a required arg
]
)
async def set_welcome_channel(ctx, channel=None):
if channel != None:
channel_name = channel.name
for channel in ctx.guild.channels:
if channel.name == channel_name:
botdata.welcome_channel = channel
sConfig['welcome'] = channel_name
sConfig.sync()
await ctx.reply(f"Welcome channel has been set to: {channel.name}")
# await channel.send("This is the new welcome channel!")
return
await ctx.reply(
"Invalid channel. Make sure you're sending a channel name (welcome), and not a channel link (#welcome).")
# Removed command because it does the same as welcome - j5155, 6/6/2021
# @commands.has_role("━━ « ( ⍟ Staff Team ⍟ ) » ━━")
# @bot.command()
# async def set_goodbye_channel(ctx, channel_name=None):
# if channel_name != None:
# for channel in ctx.guild.channels:
# if channel.name == channel_name:
# botdata.goodbye_channel = channel
# sConfig['goodbye'] = channel_name
# sConfig.sync()
# await ctx.channel.send(f"Goodbye channel has been set to: {channel.name}")
# await channel.send("This is the new goodbye channel!")
#
# else:
# await ctx.channel.send("You didnt include the name of a goodbye channel.")
# reaction roles
@bot.event
async def on_raw_reaction_remove(payload):
guild = bot.get_guild(payload.guild_id)
for role, msgid, emoji in sConfig['reaction']:
if msgid == payload.message_id and emoji == payload.emoji.name:
await bot.get_guild(payload.guild_id).get_member(payload.user_id).remove_roles(guild.get_role(role))
@slash_commands.has_role("ADMIN")
@slash.command(
description="Sets a reaction role",
options=[
Option("role", "Enter the role", Type.STRING, required=True),
Option("msg", "Enter a message", Type.STRING, required=True),
Option("emoji", "Enter the emoji", Type.STRING, required=True)
# By default, Option is optional
# Pass required=True to make it a required arg
]
)
async def set_reaction(ctx, role: discord.Role = None, msg: discord.Message = None, emoji=None):
if role != None and msg != None and emoji != None:
await msg.add_reaction(emoji)
sConfig.setdefault('reaction', []).append((role.id, msg.id, emoji))
sConfig.sync()
ctx.reply("Reaction role set.")
else:
await ctx.reply("Invalid arguments.")
# bot warning and moderation system.
@bot.event
async def on_guild_join(guild):
bot.warnings[guild.id] = {}
@slash_commands.has_role("━━ « ( ⍟ Staff Team ⍟ ) » ━━")
@slash.command(
description="Warns a user",
options=[
Option("member", "Enter a member", Type.USER, required=True),
Option("reason", "Enter a reason", Type.STRING)
# By default, Option is optional
# Pass required=True to make it a required arg
]
)
async def warn(ctx, member: discord.Member = None, *, reason=None):
if member is None:
return await ctx.send("The provided member could not be found, or you forgot to provide one.")
if reason is None:
return await ctx.send("Please provide a reason for warning this member.")
try:
first_warning = False
bot.warnings[ctx.guild.id][member.id][0] += 1
bot.warnings[ctx.guild.id][member.id][1].append((ctx.author.id, reason))
except KeyError:
first_warning = True
bot.warnings[ctx.guild.id][member.id] = [1, [(ctx.author.id, reason)]]
count = bot.warnings[ctx.guild.id][member.id][0]
async with aiofiles.open(f"{ctx.guild.id} warnings.txt", mode="a") as file:
await file.write(f"{member.id} {ctx.author.id} {reason}\n")
await ctx.reply(f"{member.mention} has {count} {'warning' if first_warning else 'warnings'}.")
@slash_commands.has_role("Staff")
@slash.command(
description="View a member's warnings",
options=[
Option("member", "Enter a member", Type.USER)
# By default, Option is optional
# Pass required=True to make it a required arg
]
)
async def warnings(ctx, member: discord.Member = None):
if member is None:
member = ctx.author
embed = discord.Embed(title=f"displaying warnings for {member.name}", description="", color=discord.Color.red())
try:
i = 1
for admin_id, reason in bot.warnings[ctx.guild.id][member.id][1]:
admin = ctx.guild.get_member(admin_id)
embed.description += f"**warnings {1}** given by {admin.mention} for: *'{reason}'*.\n"
i += 1
await ctx.reply(embed=embed)
except KeyError: # this person has no warnings
await ctx.reply("This user has no warnings.")
@slash.command(
description="Purges messages",
options=[
Option("amount", "Enter the amount", Type.STRING, required=True)
# By default, Option is optional
# Pass required=True to make it a required arg
]
)
@slash_commands.has_permissions(manage_messages=True)
async def purge(ctx, amount=2):
await ctx.channel.purge(limit=int(amount))
delMessage = await ctx.reply('Performed successfully')
await asyncio.sleep(2)
await delMessage.delete()
@slash.command(
description="Kicks a user",
options=[
Option("user", "Enter the user", Type.USER),
Option("reason", "Enter a reason", Type.STRING)
# By default, Option is optional
# Pass required=True to make it a required arg
]
)
@slash_commands.has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member, *, reason="No reason provided."):
await ctx.reply(member.mention + " has been kicked.")
await member.kick(reason=reason)
@slash.command(
description="Bans a user",
options=[
Option("user", "Enter the user", Type.USER),
Option("reason", "Enter a reason", Type.STRING)
# By default, Option is optional
# Pass required=True to make it a required arg
]
)
@slash_commands.has_permissions(ban_members=True)
async def ban(ctx, member: discord.Member, *, reason="No reason provided."):
await ctx.reply(member.mention + " has been banned.")
await member.ban(reason=reason)
@slash.command(
description="Unbans a user",
options=[
Option("user", "Enter the user", Type.STRING),
# By default, Option is optional
# Pass required=True to make it a required arg
]
)
@slash_commands.has_permissions(ban_members=True)
async def unban(ctx, *, member):
banned_users = await ctx.guild.bans()
member_name, member_disc, = member.split('#')
for banned_entry in banned_users:
user = banned_entry.user
if (user.name, user.discriminator,) == (member_name, member_disc):
await ctx.guild.unban(user)
await ctx.reply(member_name + " has been unbanned.")
return
await ctx.reply(member + " was not found.")
@slash.command(
description="Mutes a user",
options=[
Option("user", "Enter the user", Type.USER, required=True),
Option("reason", "Enter a reason", Type.STRING)
# By default, Option is optional
# Pass required=True to make it a required arg
]
)
@slash_commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member):
muted_role = ctx.guild.get_role(708075939019489360)
member_role = ctx.guild.get_role(695742663256834141)
await member.remove_roles(member_role)
await member.add_roles(muted_role)
await ctx.reply(member.mention + " has been muted.")
@slash_commands.has_role("━━ « ( ⍟ Staff Team ⍟ ) » ━━")
@slash.command(
description="Unmutes a user",
options=[
Option("user", "Enter the user", Type.USER, required=True),
# By default, Option is optional
# Pass required=True to make it a required arg
]
)
async def unmute(ctx, member: discord.Member):
muted_role = ctx.guild.get_role(708075939019489360)
member_role = ctx.guild.get_role(695742663256834141)
await member.add_roles(member_role)
await member.remove_roles(muted_role)
await ctx.reply(member.mention + " has been unmuted.")
# suggestion command
@slash_commands.has_role("━━ « ( ⍟ Staff Team ⍟ ) » ━━")
@slash.command(
description="Sets the suggestion channel",
options=[
Option("schannel", "Enter the channel", Type.CHANNEL)
# By default, Option is optional
# Pass required=True to make it a required arg
]
)
async def set_suggestion_channel(ctx, schannel=None):
if schannel != None:
channel_name = schannel.name
for channel in ctx.guild.channels:
if channel.name == channel_name:
botdata.suggestion_channel = channel
sConfig['suggestion'] = channel_name
await ctx.reply(f"Suggestion channel was set to: {channel.name}")
# await channel.send("This is the new suggestion channel!")
@slash_commands.has_role("━━ « ( ⍟ Staff Team ⍟ ) » ━━")
@slash.command(
name='set_decided_suggestion_channel',
description="Sets the decided suggestion channel",
options=[
Option("set_channel", "Enter the channel", Type.CHANNEL, required=True)
# By default, Option is optional
# Pass required=True to make it a required arg
]
)
async def set_decided_channel(ctx, set_channel=None):
if set_channel != None:
channel_name = set_channel.name
for channel in ctx.guild.channels:
if channel.name == channel_name:
botdata.suggestion_channel_two = channel
sConfig['suggestion2'] = channel_name
await ctx.reply(f"Decided suggestion channel was set to: {channel.name}")
# await channel.send("This is the new suggestion channel!")
@slash_commands.has_role("━━ « ( ⍟ Staff Team ⍟ ) » ━━")
@slash.command(
name='accept',
description="Use this while replying to a suggestion to accept it.",
options=[
Option("number", "Number of affected suggestion", Type.STRING, required=True),
Option("reason", "Enter the reason", Type.STRING)