-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
1595 lines (1343 loc) · 58.2 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
# custom programs ^
# from itertools import cycle
import datetime
import logging
import math
import os
import random
import re
import time
from difflib import SequenceMatcher
import aioimgur
import asuna_api
import async_cse
import chardet
import discord
import mystbin
import sr_api
# modules ^
from discord.ext import commands
from pytz import timezone # all good
import ClientConfig
import color_code
import DatabaseConfig
import DatabaseControl
import GetPfp
import GlobalLinker
import random_response
import RankSystem
import swear_checker
import UpdateNotify
# import itertools
bad_list = swear_checker.bad_word_list
logging.basicConfig(level=logging.INFO)
client = ClientConfig.client
jdjg_id = [
168422909482762240,
393511863385587712,
]
# this is used for the order command
# jdjg's id only(don't add any more)
# be careful not to have a * anywhere else,
# or the text will be italicised
discordprefix = "JDBot*"
guild_prefixes = {}
admins = [
168422909482762240,
269904594526666754,
717822288375971900,
357006546674253826,
734666800905846834,
]
admin_contact = [
168422909482762240,
717822288375971900,
357006546674253826,
]
admin_contact2 = [
168422909482762240,
357006546674253826,
]
# adding an id(if you have access to the source code and want to fork it, credit us, getting your discord id is easy, replace ours with the ones you are playing to use)
slur_censor = []
class BetterMemberConverter(commands.Converter):
async def convert(self, ctx, argument):
try:
user = await commands.MemberConverter().convert(ctx, argument)
except commands.MemberNotFound:
user = None
if user == None:
tag = re.match(r"#?(\d{4})", argument)
if tag:
if ctx.guild:
test = discord.utils.get(ctx.guild.members, discriminator=tag.group(1))
if test:
user = test
if not test:
user = ctx.author
if ctx.guild is None:
user = await BetterUserconverter().convert(ctx, argument)
if user:
user = client.get_user(user.id)
if user is None:
user = ctx.author
return user
class BetterUserconverter(commands.Converter):
async def convert(self, ctx, argument):
try:
user = await commands.UserConverter().convert(ctx, argument)
except commands.UserNotFound:
user = None
if not user and ctx.guild:
user = ctx.guild.get_member_named(argument)
if user == None:
match2 = re.match(r"<@&([0-9]+)>$", argument)
if match2:
argument2 = match2.group(1)
role = ctx.guild.get_role(int(argument2))
if role.is_bot_managed:
user = role.tags.bot_id
user = client.get_user(user)
if user is None:
user = await client.fetch_user(user)
if user == None:
tag = re.match(r"#?(\d{4})", argument)
if tag:
test = discord.utils.get(client.users, discriminator=tag.group(1))
if test:
user = test
if not test:
user = ctx.author
return user
async def triggered_converter(url, ctx):
sr_client = sr_api.Client(session=client.aiohttp_session)
source_image = sr_client.filter(option="triggered", url=str(url))
imgur_client = aioimgur.ImgurClient(os.environ["imgur_id"], os.environ["imgur_secret"])
imgur_url = await imgur_client.upload_from_url(source_image.url)
embed = discord.Embed(color=random.randint(0, 16777215))
embed.set_author(name=f"Triggered gif requested by {ctx.author}", icon_url=(ctx.author.display_avatar.url))
embed.set_image(url=imgur_url["link"])
embed.set_footer(text="powered by some random api")
await ctx.send(embed=embed)
@client.command()
async def CRAP_BACKUP(ctx):
await ctx.send("Crap ok...ill back them up real quick")
guild_search = client.get_guild(736422329399246990)
guild_emoji_fetch = guild_search.emojis
for obj in guild_emoji_fetch:
print(obj.url)
@client.group(name="order", invoke_without_command=True)
async def order(ctx, *, args=None):
if args is None:
await ctx.send("You can't order nothing.")
if args:
time_before = time.perf_counter()
image_client = async_cse.Search(os.environ["image_api_key"], engine_id=os.environ["google_image_key"])
results = await image_client.search(args, safesearch=True, image_search=True)
emoji_image = sorted(results, key=lambda x: SequenceMatcher(None, x.image_url, args).ratio())[-1]
await image_client.close()
time_after = time.perf_counter()
try:
await ctx.message.delete()
except discord.errors.Forbidden:
pass
embed = discord.Embed(
title=f"Item: {args}",
description=f"{ctx.author} ordered a {args}",
color=random.randint(0, 16777215),
timestamp=ctx.message.created_at,
)
embed.set_author(name=f"order for {ctx.author}:", icon_url=(ctx.author.display_avatar.url))
embed.add_field(name="Time Spent:", value=f"{int((time_after - time_before)*1000)}MS")
embed.add_field(name="Powered by:", value="Google Images Api")
embed.set_image(url=emoji_image.image_url)
embed.set_footer(text=f"{ctx.author.id} \nCopyright: I don't know the copyright.")
await ctx.send(
content="Order has been logged for safety purposes(we want to make sure no unsafe search is sent)",
embed=embed,
)
await client.get_channel(996864571962839143).send(embed=embed)
@client.command(
brief="a command to get the avatar of a user",
help="using the userinfo technology it now powers avatar grabbing.",
aliases=[
"pfp",
],
)
async def avatar(ctx, *, user: BetterUserconverter = None):
if user is None:
user = ctx.author
embed = discord.Embed(color=random.randint(0, 16777215))
embed.set_author(name=f"{user.name}'s avatar:", icon_url=(user.display_avatar.url))
embed.set_image(url=(user.display_avatar.url))
embed.set_footer(text=f"Requested by {ctx.author}")
await ctx.send(embed=embed)
@client.command(brief="a command that takes a url and sees if it's an image.")
async def image_check(ctx):
images = list(filter(lambda e: e.type == "image", ctx.message.embeds))
for e in images:
if e.type == "image":
await ctx.send(f"{e.url}")
if not images:
await ctx.send(
"you need to pass a url with an image, if you did, then please run again. This is a discord issue, and I do not want to wait for discord to change its message."
)
@client.command(brief="a command to send mail")
async def mail(ctx, *, user: BetterUserconverter = None):
if user is None:
await ctx.reply("User not found, returning Letter")
user = ctx.author
if user:
def check(m):
return m.author.id == ctx.author.id
await ctx.reply("Please give me a message to use.")
message = await client.wait_for("message", check=check)
embed_message = discord.Embed(
title=message.content, timestamp=(message.created_at), color=random.randint(0, 16777215)
)
embed_message.set_author(name=f"Mail from: {ctx.author}", icon_url=(ctx.author.display_avatar.url))
embed_message.set_footer(text=f"{ctx.author.id}")
embed_message.set_thumbnail(url="https://i.imgur.com/1XvDnqC.png")
if user.dm_channel is None:
await user.create_dm()
await user.send(embed=embed_message)
embed_message.add_field(name="Sent To:", value=str(user))
await client.get_channel(996864571962839143).send(embed=embed_message)
@order.command(brief="a command to shuffle images from google images")
async def shuffle(ctx, *, args=None):
if args is None:
await ctx.send("You can't order nothing")
if args:
time_before = time.perf_counter()
image_client = async_cse.Search(os.environ["image_api_key"], engine_id=os.environ["google_image_key"])
results = await image_client.search(args, safesearch=True, image_search=True)
emoji_image = results[random.randint(0, len(results) - 1)]
await image_client.close()
time_after = time.perf_counter()
try:
await ctx.message.delete()
except discord.errors.Forbidden:
pass
embed = discord.Embed(
title=f"Item: {args}",
description=f"{ctx.author} ordered a {args}",
color=random.randint(0, 16777215),
timestamp=ctx.message.created_at,
)
embed.set_author(name=f"order for {ctx.author}:", icon_url=(ctx.author.display_avatar.url))
embed.add_field(name="Time Spent:", value=f"{int((time_after - time_before)*1000)}MS")
embed.add_field(name="Powered by:", value="Google Images Api")
embed.set_image(url=emoji_image.image_url)
embed.set_footer(text=f"{ctx.author.id} \nCopyright: I don't know the copyright.")
await ctx.send(
content="Order has been logged for safety purposes(we want to make sure no unsafe search is sent)",
embed=embed,
)
await client.get_channel(996864571962839143).send(embed=embed)
@client.command(brief="a command to shuffle images from google images", aliases=["order-shuffle"])
async def order_shuffle(ctx, *, args):
if args is None:
await ctx.send("You can't order nothing")
if args:
time_before = time.perf_counter()
image_client = async_cse.Search(os.environ["image_api_key"], engine_id=os.environ["google_image_key"])
results = await image_client.search(args, safesearch=True, image_search=True)
emoji_image = results[random.randint(0, len(results) - 1)]
await image_client.close()
time_after = time.perf_counter()
try:
await ctx.message.delete()
except discord.errors.Forbidden:
pass
embed = discord.Embed(
title=f"Item: {args}",
description=f"{ctx.author} ordered a {args}",
color=random.randint(0, 16777215),
timestamp=ctx.message.created_at,
)
embed.set_author(name=f"order for {ctx.author}:", icon_url=(ctx.author.display_avatar.url))
embed.add_field(name="Time Spent:", value=f"{int((time_after - time_before)*1000)}MS")
embed.add_field(name="Powered by:", value="Google Images Api")
embed.set_image(url=emoji_image.image_url)
embed.set_footer(text=f"{ctx.author.id} \nCopyright: I don't know the copyright.")
await ctx.send(
content="Order has been logged for safety purposes(we want to make sure no unsafe search is sent)",
embed=embed,
)
await client.get_channel(996864571962839143).send(embed=embed)
@client.command(help="a hug command to hug people", brief="this the first command to hug.")
async def hug(ctx, *, Member: BetterMemberConverter = None):
if Member is None:
Member = ctx.author
if Member.id == ctx.author.id:
person = client.user
target = ctx.author
if Member.id != ctx.author.id:
person = ctx.author
target = Member
sr_client = sr_api.Client(session=client.aiohttp_session)
image = await sr_client.get_gif("hug")
embed = discord.Embed(color=random.randint(0, 16777215))
embed.set_author(name=f"{person} hugged you! Awwww...", icon_url=(person.display_avatar.url))
embed.set_image(url=image.url)
embed.set_footer(text="powered by some random api")
if isinstance(ctx.channel, discord.TextChannel):
await ctx.send(content=target.mention, embed=embed)
if isinstance(ctx.channel, discord.DMChannel):
if target.dm_channel is None:
await target.create_dm()
try:
await target.send(content=target.mention, embed=embed)
except discord.Forbidden:
await ctx.author.send("Failed DM'ing them...")
@client.command(help="another command to give you pat gifs", brief="powered using the asuna api")
async def pat2(ctx, *, Member: BetterMemberConverter = None):
if Member is None:
Member = ctx.author
if Member.id == ctx.author.id:
person = client.user
target = ctx.author
if Member.id != ctx.author.id:
person = ctx.author
target = Member
asuna = asuna_api.Client(session=client.aiohttp_session)
url = await asuna.get_gif("pat")
embed = discord.Embed(color=random.randint(0, 16777215))
embed.set_author(name=f"{person} patted you! *pat pat pat*", icon_url=(person.display_avatar.url))
embed.set_image(url=url.url)
embed.set_footer(text="powered using the asuna.ga api")
if isinstance(ctx.channel, discord.TextChannel):
await ctx.send(content=target.mention, embed=embed)
if isinstance(ctx.channel, discord.DMChannel):
if target.dm_channel is None:
await target.create_dm()
try:
await target.send(content=target.mention, embed=embed)
except discord.Forbidden:
await ctx.author.send("Failed DM'ing them...")
@client.command(help="a command to send facepalm gifs", brief="using some random api it sends you a facepalm gif lol")
async def facepalm(ctx, *, Member: BetterMemberConverter = None):
if Member is None:
Member = ctx.author
if Member.id == ctx.author.id:
person = client.user
target = ctx.author
if Member.id != ctx.author.id:
person = ctx.author
target = Member
sr_client = sr_api.Client(session=client.aiohttp_session)
image = await sr_client.get_gif("face-palm")
embed = discord.Embed(color=random.randint(0, 16777215))
embed.set_author(name=f"{target} you made {person} facepalm", icon_url=(person.display_avatar.url))
embed.set_image(url=image.url)
embed.set_footer(text="powered by some random api")
if isinstance(ctx.channel, discord.TextChannel):
await ctx.send(content=target.mention, embed=embed)
if isinstance(ctx.channel, discord.DMChannel):
if target.dm_channel is None:
await target.create_dm()
try:
await target.send(content=target.mention, embed=embed)
except discord.Forbidden:
await ctx.author.send("Failed Dming them...")
@client.command(help="takes a .png attachment or your avatar and makes a triggered version.")
async def triggered(ctx):
y = 0
if len(ctx.message.attachments) > 0:
for x in ctx.message.attachments:
if x.filename.endswith(".png"):
url = x.url
await triggered_converter(url, ctx)
y = y + 1
if not x.filename.endswith(".png"):
pass
if len(ctx.message.attachments) == 0 or y == 0:
url = ctx.author.display_avatar.with_format(format="png")
await triggered_converter(url, ctx)
@client.command(help="uploads your emojis into a mystbin link")
async def look_at(ctx):
if isinstance(ctx.message.channel, discord.TextChannel):
message_emojis = ""
for x in ctx.guild.emojis:
message_emojis = message_emojis + " " + str(x) + "\n"
mystbin_client = mystbin.Client(session=client.aiohttp_session)
paste = await mystbin_client.post(message_emojis)
await ctx.send(paste.url)
if isinstance(ctx.channel, discord.DMChannel):
await ctx.send("We can't use that in DMS")
@client.command()
async def headpat(ctx):
import petpet.Pet
await petpet.Pet.get_pet(ctx.message, ctx.message.channel)
@client.command(
help="a way to look up minecraft usernames",
brief="using the official minecraft api, looking up minecraft information has never been easier(tis only gives minecraft account history relating to name changes)",
)
async def mchistory(ctx, *, args=None):
import asuna_api
asuna = asuna_api.Client(session=client.aiohttp_session)
minecraft_info = await asuna.mc_user(args)
if not args:
await ctx.send("Please pick a minecraft user.")
if args:
embed = discord.Embed(title=f"Minecraft Username: {args}", color=random.randint(0, 16777215))
embed.set_footer(text=f"Minecraft UUID: {minecraft_info.uuid}")
embed.add_field(name="Orginal Name:", value=minecraft_info.name)
y = 0
for x in minecraft_info.history:
if y > 0:
embed.add_field(
name=f"Username:\n{x['name']}",
value=f"Date Changed:\n{x['changedToAt']}\n \nTime Changed: \n {x['timeChangedAt']}",
)
y = y + 1
embed.set_author(name=f"Requested by {ctx.author}", icon_url=(ctx.author.display_avatar.url))
await ctx.send(embed=embed)
@client.command(
help="a command to backup text", brief="please don't upload any private files that aren't meant to be seen"
)
async def text_backup(ctx):
if ctx.message.attachments:
for x in ctx.message.attachments:
file = await x.read()
if len(file) > 0:
encoding = chardet.detect(file)["encoding"]
if encoding:
text = file.decode(encoding)
mystbin_client = mystbin.Client(session=client.aiohttp_session)
paste = await mystbin_client.post(text)
await ctx.send(content=f"Added text file to mystbin: \n{paste.url}")
if encoding is None:
await ctx.send(
"it looks like it couldn't decode this file, if this is an issue DM JDJG Inc. Official#3439 or it wasn't a text file."
)
if len(file) < 1:
await ctx.send("this doesn't contain any bytes.")
@client.command()
async def ping(ctx):
await ctx.send("Pong")
await ctx.send(f"Response time: {client.latency*1000}")
@client.group(name="apply", invoke_without_command=True)
async def apply(ctx):
await ctx.send("this command is meant to apply")
@apply.command(help="a command to apply for our Bloopers.")
async def bloopers(ctx, *, args=None):
if args is None:
await ctx.send("You didn't give us any info.")
if args:
if isinstance(ctx.message.channel, discord.TextChannel):
await ctx.message.delete()
for x in [708167737381486614, 168422909482762240]:
apply_user = client.get_user(x)
if apply_user.dm_channel is None:
await apply_user.create_dm()
embed_message = discord.Embed(title=args, color=random.randint(0, 16777215), timestamp=(ctx.message.created_at))
embed_message.set_author(name=f"Application from {ctx.author}", icon_url=(ctx.author.display_avatar.url))
embed_message.set_footer(text=f"{ctx.author.id}")
embed_message.set_thumbnail(url="https://i.imgur.com/PfWlEd5.png")
await apply_user.send(embed=embed_message)
@client.command(help="get an invite to invite the bot")
async def invite(ctx):
embed = discord.Embed(
title="The Invite Links!", value="One is for testing, one is the normal bot.", color=random.randint(0, 16777215)
)
embed.add_field(
name="Testing Link:",
value="https://discordapp.com/oauth2/authorize?client_id=702243652960780350&scope=bot&permissions=8",
inline=False,
)
embed.add_field(
name="Normal Invite:",
value=f"https://discordapp.com/oauth2/authorize?client_id={client.user.id}&scope=bot&permissions=8",
inline=False,
)
embed.set_thumbnail(url=(client.user.display_avatar.url))
await ctx.send(embed=embed)
@client.command(help="gives the id of the current guild or DM if you are in one.")
async def guild_get(ctx):
if isinstance(ctx.channel, discord.TextChannel):
await ctx.send(content=ctx.guild.id)
if isinstance(ctx.channel, discord.DMChannel):
await ctx.send(ctx.channel.id)
@client.command(
help="This gives random history using Sp46's api.",
brief="a command that uses SP46's api's random history command to give you random history responses",
)
async def random_history(ctx, *, args=None):
if args is None:
args = 1
asuna = asuna_api.Client(session=client.aiohttp_session)
response = await asuna.random_history(args)
for x in response:
await ctx.send(f":earth_africa: {x}")
@client.command(
help="a way to view open source",
brief="you can see the open source with the link it provides",
aliases=["open source"],
)
async def open_source(ctx):
source_send = discord.Embed(
title="Project at: https://github.com/JDJGInc/JDJGBotSupreme",
description="Want to get more info, contact the owner with the JDBot*owner command",
color=random.randint(0, 16777215),
)
source_send.set_author(name=f"{client.user} Source Code:", icon_url=(client.user.display_avatar.url))
await ctx.send(embed=source_send)
@client.command(help="a command to tell you the channel id")
async def this(ctx):
await ctx.send(ctx.channel.id)
await ctx.send(ClientConfig.whoami)
@client.command(help="gives you the milkman gif", brief="you summoned the milkman oh no")
async def milk(ctx):
embed = discord.Embed(title="You have summoned the milkman", color=random.randint(0, 16777215))
embed.set_image(url="https://i.imgur.com/JdyaI1Y.gif")
embed.set_footer(text="his milk is delicious")
await ctx.send(embed=embed)
@client.command(help="gives you who the owner is.")
async def owner(ctx):
info = client.application
if info.team is None:
owner = info.owner.id
if info.team:
owner = info.team.owner_id
support_guild = client.get_guild(736422329399246990)
owner = support_guild.get_member(owner)
if owner.bot:
user_type = "Bot"
if not owner.bot:
user_type = "User"
guilds_list = [guild for guild in client.guilds if guild.get_member(owner.id)]
if not guilds_list:
guild_list = "None"
x = 0
for g in guilds_list:
if x < 1:
guild_list = g.name
if x > 0:
guild_list = guild_list + f", {g.name}"
x = x + 1
if owner:
nickname = str(owner.nick)
joined_guild = owner.joined_at.strftime("%m/%d/%Y %H:%M:%S")
status = str(owner.status).upper()
highest_role = owner.roles[-1]
if owner is None:
nickname = "None"
joined_guild = "N/A"
status = "Unknown"
for guild in client.guilds:
member = guild.get_member(owner.id)
if member:
status = str(member.status).upper()
break
highest_role = "None Found"
embed = discord.Embed(
title=f"Bot Owner: {owner}",
description=f"Type: {user_type}",
color=random.randint(0, 16777215),
timestamp=ctx.message.created_at,
)
embed.add_field(name="Username:", value=owner.name)
embed.add_field(name="Discriminator:", value=owner.discriminator)
embed.add_field(name="Nickname: ", value=nickname)
embed.add_field(name="Joined Discord: ", value=(owner.created_at.strftime("%m/%d/%Y %H:%M:%S")))
embed.add_field(name="Joined Guild: ", value=joined_guild)
embed.add_field(name="Part of Guilds:", value=guild_list)
embed.add_field(name="ID:", value=owner.id)
embed.add_field(name="Status:", value=status)
embed.add_field(name="Highest Role:", value=highest_role)
embed.set_image(url=owner.display_avatar.url)
await ctx.send(embed=embed)
try:
await RankSystem.GetStatus(ctx.message, owner)
except:
await ctx.send("User not in Rank System")
@client.command(
help="a command to give information about the team",
brief="this command works if you are in team otherwise it will just give the owner.",
)
async def team(ctx):
information = client.application
if information.team == None:
true_owner = information.owner
team_members = []
if information.team != None:
true_owner = information.team.owner
team_members = information.team.members
embed = discord.Embed(title=information.name, color=random.randint(0, 16777215))
embed.add_field(name="Owner", value=true_owner)
embed.set_footer(text=f"ID: {true_owner.id}")
embed.set_image(url=information.icon.url if information.icon else bot.display_avatar.url)
for x in team_members:
embed.add_field(name=x, value=x.id)
await ctx.send(embed=embed)
@client.command(help="a command to send I hate spam.")
async def spam(ctx):
embed = discord.Embed(color=random.randint(0, 16777215))
embed.set_image(url="https://i.imgur.com/1LckTTu.gif")
await ctx.send(content="I hate spam.", embed=embed)
@client.command(help="a command to give information about a file")
async def file(ctx):
if len(ctx.message.attachments) < 1:
await ctx.send(ctx.message.attachments)
await ctx.send("no file submitted")
if len(ctx.message.attachments) > 0:
embed = discord.Embed(title="Attachment info", color=random.randint(0, 16777215))
for x in ctx.message.attachments:
embed.add_field(name=f"ID: {x.id}", value=f"[{x.filename}]({x.url})")
embed.set_footer(text="Check on the url/urls to get a direct download to the url.")
await ctx.send(embed=embed, content="\nThat's good")
@client.command(help="a command meant to flip coins", brief="commands to flip coins, etc.")
async def coin(ctx, *, args=None):
if args:
value = random.choice([True, False])
if args.lower().startswith("h") and value:
win = True
elif args.lower().startswith("t") and not value:
win = True
elif args.lower().startswith("h") and not value:
win = False
elif args.lower().startswith("t") and value:
win = False
else:
await ctx.send("Please use heads or Tails as a value.")
return
if value:
pic_name = "heads"
else:
pic_name = "Tails"
url_dic = {"heads": "https://i.imgur.com/MzdU5Z7.png", "Tails": "https://i.imgur.com/qTf1owU.png"}
embed = discord.Embed(title="coin flip", color=random.randint(0, 16777215))
embed.set_author(name=f"{ctx.author}", icon_url=(ctx.author.display_avatar.url))
embed.add_field(name="The Coin Flipped: " + ("heads" if value else "tails"), value=f"You guessed: {args}")
embed.set_image(url=url_dic[pic_name])
if win:
embed.add_field(name="Result: ", value="You won")
else:
embed.add_field(name="Result: ", value="You lost")
await ctx.send(embed=embed)
if args is None:
await ctx.send("example: \n```test*coin heads``` \nnot ```test*coin```")
@client.command()
async def stats(ctx):
embed = discord.Embed(title="Bot stats", color=random.randint(0, 16777215))
embed.add_field(name="Guild count", value=len(client.guilds))
embed.add_field(name="User Count:", value=len(client.users))
await ctx.send(embed=embed)
async def guildinfo(ctx, guild):
bots = 0
users = 0
for x in guild.members:
if x.bot is True:
bots = bots + 1
if x.bot is False:
users = users + 1
static_emojis = 0
animated_emojis = 0
usable_emojis = 0
for x in guild.emojis:
if x.animated is True:
animated_emojis = animated_emojis + 1
if x.animated is False:
static_emojis = static_emojis + 1
if x.available is True:
usable_emojis = usable_emojis + 1
embed = discord.Embed(title="Guild Info:", color=random.randint(0, 16777215))
embed.add_field(name="Server Name:", value=guild.name)
embed.add_field(name="Server ID:", value=guild.id)
embed.add_field(name="Server created at:", value=f"{guild.created_at} UTC")
embed.add_field(name="Server Owner:", value=guild.owner)
embed.add_field(name="Member Count:", value=guild.member_count)
embed.add_field(name="Users:", value=users)
embed.add_field(name="Bots:", value=bots)
embed.add_field(name="Channel Count:", value=len(guild.channels))
embed.add_field(name="Role Count:", value=len(guild.roles))
embed.set_thumbnail(url=(guild.icon.url))
embed.add_field(name="Emoji Limit:", value=guild.emoji_limit)
embed.add_field(name="Max File Size:", value=f"{guild.filesize_limit/1000000} MB")
embed.add_field(name="Shard ID:", value=guild.shard_id)
embed.add_field(name="Animated Icon", value=guild.is_icon_animated())
embed.add_field(name="Static Emojis", value=static_emojis)
embed.add_field(name="Animated Emojis", value=animated_emojis)
embed.add_field(name="Total Emojis:", value=f"{len(guild.emojis)}/{guild.emoji_limit*2}")
embed.add_field(name="Usable Emojis", value=usable_emojis)
await ctx.send(embed=embed)
@client.command(
help="gives you info about a guild",
aliases=[
"server_info",
"guild_fetch",
"guild_info",
"fetch_guild",
],
)
async def serverinfo(ctx, *, args=None):
if args:
match = re.match(r"(\d{16,21})", args)
guild = client.get_guild(int(match.group(0)))
if guild is None:
guild = ctx.guild
if args is None:
guild = ctx.guild
await guildinfo(ctx, guild)
@client.command(help="a command to find the nearest emoji")
async def emote(ctx, *, args=None):
if args is None:
await ctx.send("Please specify an emote")
if args:
emoji = discord.utils.get(client.emojis, name=args)
if emoji is None:
await ctx.send("we haven't found anything")
if emoji:
await ctx.send(emoji)
@client.command(help="this is a way to get the nearest channel.")
async def closest_channel(ctx, *, args=None):
if args is None:
await ctx.send("Please specify a channel")
if args:
if isinstance(ctx.channel, discord.TextChannel):
channel = discord.utils.get(ctx.guild.channels, name=args)
if channel:
await ctx.send(channel.mention)
if channel is None:
await ctx.send("Unforantely we haven't found anything")
if isinstance(ctx.channel, discord.DMChannel):
await ctx.send("You can't use it in a DM.")
@client.command()
async def pi(ctx):
await ctx.send(math.pi)
@client.command(help="a command to get the closest user.")
async def closest_user(ctx, *, args=None):
if args is None:
await ctx.send("please specify a user")
if args:
from difflib import SequenceMatcher
userNearest = discord.utils.get(client.users, name=args)
user_nick = discord.utils.get(client.users, display_name=args)
if userNearest is None:
userNearest = sorted(client.users, key=lambda x: SequenceMatcher(None, x.name, args).ratio())[-1]
if user_nick is None:
user_nick = sorted(client.users, key=lambda x: SequenceMatcher(None, x.display_name, args).ratio())[-1]
await ctx.send(f"Username: {userNearest}")
await ctx.send(f"Display name: {user_nick}")
if isinstance(ctx.channel, discord.TextChannel):
member_list = []
for x in ctx.guild.members:
if x.nick is None:
pass
if x.nick:
member_list.append(x)
nearest_server_nick = sorted(member_list, key=lambda x: SequenceMatcher(None, x.nick, args).ratio())[-1]
await ctx.send(f"Nickname: {nearest_server_nick}")
if isinstance(ctx.channel, discord.DMChannel):
await ctx.send("You unforantely don't get the last value.")
@client.command(
help="a command to send wink gifs", brief="you select a user to send it to and it will send it to you lol"
)
async def wink(ctx, *, Member: BetterMemberConverter = None):
if Member is None:
Member = ctx.author
if Member.id == ctx.author.id:
person = client.user
target = ctx.author
if Member.id != ctx.author.id:
person = ctx.author
target = Member
sr_client = sr_api.Client(session=client.aiohttp_session)
image = await sr_client.get_gif("wink")
embed = discord.Embed(color=random.randint(0, 16777215))
embed.set_author(name=f"{person} winked at you", icon_url=(person.display_avatar.url))
embed.set_image(url=image.url)
embed.set_footer(text="powered by some random api")
if isinstance(ctx.channel, discord.TextChannel):
await ctx.send(content=target.mention, embed=embed)
if isinstance(ctx.channel, discord.DMChannel):
if target.dm_channel is None:
await target.create_dm()
try:
await target.send(content=target.mention, embed=embed)
except discord.Forbidden:
await ctx.author.send("Failed Dming them...")
@client.command(
aliases=["user_info", "user-info", "ui", "whois"],
brief="a command that gives information on users",
help="this can work with mentions, ids, usernames, and even full names.",
)
async def userinfo(ctx, *, user: BetterUserconverter = None):
user = user or ctx.author
user_type = ["User", "Bot"][user.bot]
if ctx.guild:
member_version = await client.getch_member(ctx.guild, user.id)
if member_version:
nickname = str(member_version.nick)
joined_guild = member_version.joined_at.strftime("%m/%d/%Y %H:%M:%S")
status = str(member_version.status).upper()
highest_role = member_version.top_role
if not member_version:
nickname = str(member_version)
joined_guild = "N/A"
status = "Unknown"
for guild in client.guilds:
member = guild.get_member(user.id)
if member:
status = str(member.status).upper()
break
highest_role = "None Found"
if not ctx.guild:
nickname = "None"
joined_guild = "N/A"
status = "Unknown"
for guild in client.guilds:
member = guild.get_member(user.id)
if member:
status = str(member.status).upper()
break
highest_role = "None Found"
guilds_list = [guild for guild in client.guilds if guild.get_member(user.id) and guild.get_member(ctx.author.id)]
if not guilds_list:
guild_list = "None"
if guilds_list:
guild_list = ", ".join(map(str, guilds_list))
embed = discord.Embed(
title=f"{user}",
description=f"Type: {user_type}",
color=random.randint(0, 16777215),
timestamp=ctx.message.created_at,
)
embed.add_field(name="Username: ", value=user.name)
embed.add_field(name="Discriminator:", value=user.discriminator)
embed.add_field(name="Nickname: ", value=nickname)
embed.add_field(name="Joined Discord: ", value=(user.created_at.strftime("%m/%d/%Y %H:%M:%S")))
embed.add_field(name="Joined Guild: ", value=joined_guild)