This repository was archived by the owner on Jun 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
1225 lines (943 loc) · 40.3 KB
/
main.py
File metadata and controls
1225 lines (943 loc) · 40.3 KB
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 discord
import asyncio
import random
import datetime
import time
import requests
import urllib
import string
import re
from discord.ext import commands
from discord.ext import tasks
import os
import json
from discord.ext.commands import check
from dotenv import load_dotenv
#---------------------------#
#NAME: FetchBot
#Status: Working
#Version: 3.0.1
#Creator: Marc13 and Raxeemo
#---------------------------#
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
intents = discord.Intents.all()
client = discord.Bot(intents=intents, help_command=None)
global lastMeme
lastMeme = 0
#Defining startup
@client.event
async def on_ready():
print(f"Logged in as {client.user.name}")
await client.change_presence(activity=discord.Activity(
type=discord.ActivityType.listening, name="/help"))
global startTime
startTime = time.time()
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.respond("You don't have the required permissions to run this command!")
if isinstance(error, commands.CommandOnCooldown):
retry_after = int(error.retry_after)
await ctx.respond(f"This command is on cooldown! Try again in {retry_after} seconds!")
def check_if_user_has_premium(ctx):
with open("premium_users.json") as f:
premium_users_list = json.load(f)
if ctx.author.id not in premium_users_list:
return False
return True
api_key = "c08a058955da2e4ba9286a2117aa8897"
base_url = "http://api.openweathermap.org/data/2.5/weather?"
@client.command(description="Get the weather of a city")
@check(check_if_user_has_premium)
async def weather(ctx, *, city: str):
city_name = city
complete_url = base_url + "appid=" + api_key + "&q=" + city_name
response = requests.get(complete_url)
x = response.json()
channel = ctx.channel
if x["cod"] != "404":
async with channel.typing():
y = x["main"]
current_temperature = y["temp"]
current_temperature_celsiuis = str(round(current_temperature - 273.15))
current_pressure = y["pressure"]
current_humidity = y["humidity"]
z = x["weather"]
weather_description = z[0]["description"]
weather_description = z[0]["description"]
embed = discord.Embed(title=f"Weather in {city_name}",color=ctx.guild.me.top_role.color)
embed.add_field(name="Descripition", value=f"**{weather_description}**", inline=False)
embed.add_field(name="Temperature(C)", value=f"**{current_temperature_celsiuis}°C**", inline=False)
embed.add_field(name="Humidity(%)", value=f"**{current_humidity}%**", inline=False)
embed.add_field(name="Atmospheric Pressure(hPa)", value=f"**{current_pressure}hPa**", inline=False)
embed.set_thumbnail(url="https://i.ibb.co/CMrsxdX/weather.png")
embed.set_footer(text=f"Requested by {ctx.author.name}")
await ctx.respond(embed=embed)
else:
await ctx.respond("City not found.")
@client.command(description="Search for a youtube video")
@check(check_if_user_has_premium)
async def ytsearch(ctx, *, search1):
search = search1
search = search.replace(" ", "+")
html = urllib.request.urlopen("https://www.youtube.com/results?search_query=" + search)
video_ids = re.findall(r"watch\?v=(\S{11})", html.read().decode())
await ctx.respond("https://www.youtube.com/watch?v=" + video_ids[0])
@client.command(description="Kill the bot")
@commands.is_owner()
async def kill(ctx):
await ctx.respond("Bot process killed :skull:")
quit()
@client.command(aliases=['h'], description="Get a list of commands!")
async def help(ctx):
helpem = discord.Embed(
title="✦Help✦",
description="**Please DM Me If you Found Any Problems : Marc13#1627**",
color=discord.Color.random())
helpem.add_field(
name=":red_circle: Main commands :red_circle:",
value=
"**/randnum\n/help\n/kick\n/ban\n/clear\n/premium\n/dog\n/cat\n/fatcat\n/fatdog\n/giveaway\n/fact\n/manga\n/anime\n/membercount\n/activatepremium\n/invite\n/creroll\n/champion\n/alimit\n/flush\n/flushnick\n/future\n/reroll\n/rps\n/react\n/servers\n/info\n/me\n/ask\n/threat\n/warn\n/stupid\n/smart\n/delchannel\n/uptime\n/abuse\n/challenge\n/whois\n/avatar\n/helpmember**"
)
helpem.add_field(
name=":family_woman_boy: Relation commands :family_woman_boy:",
value=
"**/createaccount\n/relation\n/clearaccount\n/pet**"
)
helpem.add_field(
name=":coin: Premium commands :coin:",
value=
"**/ping\n/imagesearch\n/createday\n/poll\n/shortening\n/pron\n/unlock\n/lock\n/announce\n/github\n/spotify\n/meme\n/comic\n/slowmode**"
)
helpem.add_field(
name=":moneybag: Economy commands :moneybag:", value=
"**/balance\n/memberbalance\n/inventory\n/memberinventory\n/beg\n/daily\n/shop\n/buy\n/rob\n/pay\n/deposit\n/withdraw\n/set**"
)
helpem.add_field(
name=":white_check_mark: Full command list :white_check_mark:", value=
"For a full list of commands, please visit https://marcusolsson123.wixsite.com/fetchbot/commands"
)
helpem.set_footer(text=f"Requested By {ctx.author.name}",
icon_url=ctx.author.avatar.url)
helpem.set_author(name=client.user.name, icon_url=client.user.avatar.url)
await ctx.author.send(embed=helpem)
return await ctx.respond("Help sent in DM to you :white_check_mark:", ephemeral = True)
@client.command(description="Send help to a member!")
@commands.has_permissions(manage_guild=True)
async def helpmember(ctx,member:discord.Member):
helpem = discord.Embed(
title="✦Help✦",
description="**Please DM Me If you Found Any Problems : Marc13#1627**",
color=discord.Color.random())
helpem.add_field(
name=":red_circle: Main commands :red_circle:",
value=
"**/randnum\n/help\n/kick\n/ban\n/clear\n/dog\n/cat\n/fatcat\n/fatdog\n/giveaway\n/fact\n/manga\n/anime\n/membercount\n/invite\n/creroll\n/champion\n/alimit\n/flush\n/flushnick\n/future\n/reroll\n/rps\n/react\n/servers\n/info\n/me\n/ask\n/threat\n/warn\n/stupid\n/smart\n/delchannel\n/uptime\n/abuse\n/challenge\n/whois\n/avatar**"
)
helpem.add_field(
name=":family_woman_boy: Relation commands :family_woman_boy:",
value=
"**/createaccount\n/relation\n/clearaccount\n/pet**"
)
helpem.add_field(
name=":coin: Premium commands :coin:",
value=
"**/ping\n/imagesearch\n/createday\n/poll\n/shortening\n/pron\n/unlock\n/lock\n/announce\n/github\n/spotify\n/meme\n/comic\n/slowmode**"
)
helpem.set_footer(text=f"Requested By {ctx.author.name}",
icon_url=ctx.author.avatar.url)
helpem.set_author(name=client.user.name, icon_url=client.user.avatar.url)
await ctx.respond("Help sent!",ephemeral=True)
return await member.send(embed=helpem)
@client.command(aliases=['Gw'], description="Host a giveaway")
@commands.has_permissions(administrator=True)
@check(check_if_user_has_premium)
async def giveaway(ctx):
await ctx.respond(
"Hello . Please answer to these questions within 15 Seconds to Start the giveaway."
)
await asyncio.sleep(2)
questions = [
"Please mention the channel to host the giveaway : ",
"What should be the duration of the giveaway? (1s,1m,1h,1d,...)",
"What is the prize of this giveaway?"
]
answers = []
def check(m):
return m.author == ctx.author and m.channel == ctx.channel
for i in questions:
await ctx.respond(i)
try:
msg = await client.wait_for('message', timeout=15.0, check=check)
except asyncio.TimeoutError:
await ctx.send(
'You didn\'t answer in time, please be quicker next time!')
return
else:
answers.append(msg.content)
try:
c_id = int(answers[0][2:-1])
except:
await ctx.send(
f"You didn't mention a channel properly . Do it like this {ctx.channel.mention} ."
)
return
channel = client.get_channel(c_id)
time = convert(answers[1])
if time == -1:
await ctx.send(
f"You didn't answer the time with a proper unit . Use (S|M|H|D) . Ex : 5m ( 5 Minutes )"
)
return
elif time == -2:
await ctx.send("Time must be a number !")
return
prize = answers[2]
await ctx.send(
f"The giveaway will be in {channel.mention} and will last for {answers[1]} ."
)
embed = discord.Embed(title=":tada: **Giveaway!** :tada:",
description=f"{prize}",
color=ctx.author.color)
embed.add_field(name="Hosted by:", value=ctx.author.mention)
embed.set_footer(text=f"Ends in {answers[1]} !")
my_msg = await channel.send(embed=embed)
await my_msg.add_reaction("🎉")
await asyncio.sleep(time)
try:
new_msg = await channel.fetch_message(my_msg.id)
users = await new_msg.reactions[0].users().flatten()
users.pop(users.index(client.user))
winner = random.choice(users)
await channel.send(f"Congratulations! {winner.mention} won {prize}!")
except:
await channel.send(
"Giveaway ended and there were no winners because nobody reacted :pensive:"
)
return
def convert(time):
pos = ["s", "m", "h", "d"]
time_dict = {"s": 1, "m": 60, "h": 3600, "d": 3600 * 24}
unit = time[-1]
if unit not in pos:
return -1
try:
val = int(time[:-1])
except:
return -2
return val * time_dict[unit]
@client.command(aliases=["mc", "members"],
description="Get the current membercount in this server")
async def membercount(ctx):
a = ctx.guild.member_count
b = discord.Embed(title=f"Members in {ctx.guild.name}",
description=a,
color=discord.Color((0xffff00)))
await ctx.respond(embed=b)
@client.command(description="Send a invite link for FetchBot")
async def invite(ctx):
await ctx.respond(
"You can invite FetchBot here: https://discord.com/api/oauth2/authorize?client_id=935860231051829258&permissions=8&scope=bot"
)
@client.command(description="Send a update ping about a new FetchBot version")
@commands.is_owner()
async def update(ctx, pings, version):
await ctx.send(
f"{pings}, A new version of FetchBot is now out, Version; {version}!")
@client.command(description="Send a random food picture.")
async def food(ctx):
foodlist = [
'https://images.immediate.co.uk/production/volatile/sites/30/2020/08/chorizo-mozarella-gnocchi-bake-cropped-9ab73a3.jpg',
'https://images.pexels.com/photos/2097090/pexels-photo-2097090.jpeg?cs=srgb&dl=pexels-julie-aagaard-2097090.jpg&fm=jpg',
'https://prod-wolt-venue-images-cdn.wolt.com/5b99008d49345c000cd430fe/9ba7390e-6609-11eb-8a69-c24ba943a9d3_lingon_food_and_friends_menu_02.jpg'
]
foodchoice = random.choice(foodlist)
await ctx.respond(foodchoice)
@client.command(description="Send a alimit")
async def alimit(ctx):
await ctx.channel.purge(limit=1)
await ctx.send(
"----------------------------------------------------------------------------------------"
)
@client.command(description="Send a Arsenal Logo picture")
async def champion(ctx):
await ctx.respond(
"https://upload.wikimedia.org/wikipedia/en/thumb/5/53/Arsenal_FC.svg/1200px-Arsenal_FC.svg.png"
)
@client.command(description="Create a new role")
@commands.has_permissions(manage_roles=True)
async def creroll(ctx, *, name):
guild = ctx.guild
await guild.create_role(name=name)
await ctx.respond(f'The role `{name}` has now been created!')
@client.command(pass_context=True, description="Change a member's nick")
@commands.has_permissions(moderate_members=True)
async def flushnick(ctx, member: discord.Member, nick):
await member.edit(nick=nick)
await ctx.respond(f'{member.mention}s nick is now flushed and updated')
@client.command(pass_context=True, description="Reset a member's nick")
@commands.has_permissions(moderate_members=True)
async def flush(ctx, member: discord.Member):
await member.edit(nick='flushed_nick')
await ctx.respond(f'Flushed nick for {member.mention}')
@client.command(description="Reroll a giveaway")
@commands.has_permissions(administrator=True)
async def reroll(ctx, channel: discord.TextChannel, id_):
if channel == None:
await ctx.respond("Please mention a channel.")
return
if id_ == None:
await ctx.respond("Please enter the giveaway's ID.")
return
try:
new_msg = await channel.fetch_message(id_)
except:
await ctx.respond("The id was entered incorrectly.")
return
users = await new_msg.reactions[0].users().flatten()
users.pop(users.index(client.user))
winner = random.choice(users)
await channel.send(f"Congratulations! The new winner is {winner.mention}!")
@client.command(description="Play rock, paper, scissors!")
async def rps(ctx, *, player_choice):
username = str(ctx.author).split('#')[0]
if player_choice == None:
await ctx.respond("Please enter rock, paper or scissors .")
return
choices = ['rock', 'paper', 'scissors']
bot_choice = random.choice(choices)
if player_choice.lower() not in choices:
await ctx.respond('Please enter rock , paper or scissors .')
else:
if player_choice.lower() == bot_choice.lower():
await ctx.respond(f'Tie . we both picked {bot_choice}')
return
elif (player_choice.lower() == 'rock' and bot_choice.lower()
== 'scissors') or (player_choice.lower() == 'scissors'
and bot_choice.lower() == 'paper') or (
player_choice.lower() == 'paper'
and bot_choice.lower() == 'rock'):
await ctx.respond(
f'Yes ! You won , Haha , my choice was {bot_choice}.')
return
elif (player_choice.lower() == 'rock' and bot_choice.lower() == 'paper'
) or (player_choice.lower() == 'scissors' and bot_choice.lower()
== 'rock') or (player_choice.lower() == 'paper'
and bot_choice.lower() == 'scissors'):
await ctx.respond(
f"Hey {username} ! Don't be mad but i won . my choice was {bot_choice}."
)
@client.command(description="Echo a message")
@commands.has_permissions(administrator=True)
async def echo(ctx, *, message):
if message == None:
await ctx.respond("Please enter a message to echo.")
if ctx.author == client.user:
return
await ctx.respond("Successfully performed echo",ephemeral=True)
await ctx.send(message)
return
@client.command(description="Set a reminder")
@check(check_if_user_has_premium)
async def reminder(ctx, time, *, reminder):
print(time)
print(reminder)
user = ctx.author
embed = discord.Embed(color=0x55a7f7)
embed.set_footer(text="If you have any questions, suggestions or bug reports, please join our support Discord Server: https://discord.gg/6BHkmhezU4")
seconds = 0
if time.lower().endswith("d"):
seconds += int(time[:-1]) * 60 * 60 * 24
counter = f"{seconds // 60 // 60 // 24} days"
if time.lower().endswith("h"):
seconds += int(time[:-1]) * 60 * 60
counter = f"{seconds // 60 // 60} hours"
elif time.lower().endswith("m"):
seconds += int(time[:-1]) * 60
counter = f"{seconds // 60} minutes"
elif time.lower().endswith("s"):
seconds += int(time[:-1])
counter = f"{seconds} seconds"
if seconds == 0:
embed.add_field(name='Warning',
value='Please specify a proper duration')
elif seconds < 300:
embed.add_field(name='Warning',
value='You have specified a too short duration!\nMinimum duration is 5 minutes.')
elif seconds > 7776000:
embed.add_field(name='Warning', value='You have specified a too long duration!\nMaximum duration is 90 days.')
else:
await ctx.respond(f"You have successfully set a reminder for {reminder} in {counter}.", ephemeral = True)
await asyncio.sleep(seconds)
await ctx.send(f"Hello {ctx.author.mention}, you asked me to remind you about {reminder} {counter} ago.")
return
await ctx.respond(embed=embed)
@client.command(description="Print info about the servers fetchbot is used in")
async def servers(ctx):
embed = discord.Embed()
dd = len(client.guilds)
embed.add_field(name=":crown: Server Amount", value=dd)
await ctx.respond(embed = embed)
@client.command(description="Send a message to a user")
@commands.has_permissions(moderate_members=True)
async def msg(ctx,member : discord.Member,*,message):
await member.send(message)
await ctx.respond("Message sent!",ephemeral=True)
@client.command(description="See how long the bot has been up for")
async def uptime(ctx):
uptime = str(datetime.timedelta(seconds=int(round(time.time()-startTime))))
await ctx.respond(f"The Bot has been up for {uptime}")
@client.command(description="Add FetchBot Premium to a member")
async def addpremium(ctx, user : discord.Member):
if ctx.author.id not in (1069582672986390579, 1069581476443738233): # your desired IDs here
return await ctx.respond("You do not have the required permissions to do this!")
with open("premium_users.json") as f:
premium_users_list = json.load(f)
if user.id not in premium_users_list:
premium_users_list.append(user.id)
with open("premium_users.json", "w+") as f:
json.dump(premium_users_list, f)
await ctx.respond(f"{user.mention} has been added to premium!")
@client.command(description="Activate a premium subscription with a code")
async def activatepremium(ctx, code):
authorr = ctx.author
coodes = ["a8fsadhfg539j", "b8rsavhfg5gh5"]
if code not in coodes:
await ctx.respond("Code invalid", ephemeral = True)
return
with open("codes.json") as f:
codes_list = json.load(f)
if code in codes_list:
await ctx.respond("This code has already been claimed :pensive:")
return
if code not in codes_list:
codes_list.append(code)
with open("codes.json", "w+") as f:
json.dump(codes_list, f)
with open("premium_users.json") as f:
premium_users_list = json.load(f)
premium_users_list.append(authorr.id)
with open("premium_users.json", "w+") as f:
json.dump(premium_users_list, f)
await ctx.respond("Congrats! You have now activated your premium subscription!")
@client.command(description="Remove Premium from a member")
@commands.is_owner()
async def removepremium(ctx, user : discord.Member):
with open("premium_users.json") as f:
premium_users_list = json.load(f)
if user.id in premium_users_list:
premium_users_list.remove(user.id)
else:
await ctx.respond(f"{user.mention} is not in the premium users list, so they cannot be removed!")
return
with open("premium_users.json", "w+") as f:
json.dump(premium_users_list, f)
await ctx.respond(f"{user.mention} has been removed!")
@client.command(description="Pull the latest version from github and restart the bot")
@commands.is_owner()
async def gitpull(ctx):
await ctx.respond("Pulling from git and restarting",ephemeral=True)
await ctx.send("**Performing a planned github pull and restarting**")
quit()
@client.command(description="Get a random joke")
@check(check_if_user_has_premium)
async def joke(ctx):
jokelist = ["What do you call a couple of chimpanzees sharing an Amazon account? PRIME-mates.", "Why did the teddy bear say no to dessert? Because she was stuffed.", "What is a cats favorite dessert? A bowl full of mice-cream.", "What do you call two bananas on the floor? Slippers.", "Why was 6 afraid of 7? Because 7,8,9.", "Which planet loves to sing? Nep-tune!", "What do you call a fish without an eye? A fsh.", "Did you hear the joke about the roof? Never mind, it would go over your head."]
joke = random.choice(jokelist)
await ctx.respond(joke)
@client.event
async def on_guild_join(guild):
marc = client.get_user(719527356368289802)
channel = guild.text_channels[0]
invite = await channel.create_invite()
message = f'**Just joined {guild}, The invite link: {invite}**'
await marc.send(message)
@client.command(description="Get information about FetchBot Premium")
async def premium(ctx):
await ctx.respond("FetchBot Premium gives you access to a whole lot of new commands, aswell as more features! You can find the list with premium commands by using /help or going to the official FetchBot website. FetchBot premium currently costs 3$ and you can buy it here; http://fetchbot.org/fetchbot-premium")
@client.command(description="Get a link to a random game")
@check(check_if_user_has_premium)
async def randgame(ctx):
gamelist = ["https://snake.io/", "https://krunker.io/", "https://powerline.io/", "https://nobrakesio.totebo.com/"]
game = random.choice(gamelist)
await ctx.respond(f"Your random game: {game}")
@client.command(description="Get a comic!")
@check(check_if_user_has_premium)
async def comic(ctx):
chosen = random.randint(1,1500)
await ctx.respond(f"https://xkcd.com/{chosen}")
@client.command(description="See how many users someone have invited to a server")
@check(check_if_user_has_premium)
async def invites(ctx, member: discord.Member=None):
if member == None:
user = ctx.author
else:
user = member
total_invites = 0
for i in await ctx.guild.invites():
if i.inviter == user:
total_invites += i.uses
await ctx.respond(f"{user.name} has invited {total_invites} member{'' if total_invites == 1 else 's'}!")
@client.command(description="Post a meme!")
@check(check_if_user_has_premium)
async def meme(ctx):
global lastMeme
memelist=["https://cdn.discordapp.com/attachments/1062778746303680574/1062788689727602898/05c73f974ebbc739fa720e677029f2a5.png","https://cdn.discordapp.com/attachments/1062778746303680574/1062788672887476234/5b1ec1ca8975f12ea2f24f307873f014.png","https://cdn.discordapp.com/attachments/1062778746303680574/1062788385938362388/bde967cac7de114f8d7a587a8862e8a9.png","https://cdn.discordapp.com/attachments/1062778746303680574/1062787897402605619/2c44aa4096423a7f8426dabec159cbf0.png","","https://cdn.discordapp.com/attachments/1062778746303680574/1062787146311794839/37ad1a2814db78e5c7b3fbac7429f371.png" ,"https://cdn.discordapp.com/attachments/1062778746303680574/1062787067068821564/IMG_2220.jpg", "https://cdn.discordapp.com/attachments/1054423887598854165/1062785610164744222/7bf8cbf4f37461087bd8e83f8671edb1.png", "https://cdn.discordapp.com/attachments/1062778746303680574/1062786023622443088/7d7c1a38f1b09d123535945eb22cc7ac.png", "https://cdn.discordapp.com/attachments/1062778746303680574/1062786191822422046/267140c36ae0b4698fb43c28ea35ecc4.png", "https://cdn.discordapp.com/attachments/1062778746303680574/1062786299276308600/5365ad123560b8f2b2100846042adb50.png"]
meme = random.choice(memelist)
if meme==lastMeme:
meme = random.choice(memelist)
await ctx.respond(meme)
lastMeme = meme
else:
await ctx.respond(meme)
lastMeme = meme
@client.command(description="Send a announcement using the bot!")
@commands.has_permissions(administrator=True)
@check(check_if_user_has_premium)
async def announce(ctx,announcement):
embed=discord.Embed(
title=f"{announcement}"
)
await ctx.channel.send(embed=embed)
await ctx.respond("Successfully sent announcement!",ephemeral=True)
@client.command(description="Get a link to the FetchBot website")
async def website(ctx):
await ctx.respond("http://fetchbot.org")
@client.command(description="Lock a channel!")
@commands.has_permissions(manage_channels=True)
@check(check_if_user_has_premium)
async def lock(ctx, channel : discord.TextChannel):
channel = channel or ctx.channel
overwrite = channel.overwrites_for(ctx.guild.default_role)
overwrite.send_messages = False
await channel.set_permissions(ctx.guild.default_role, overwrite=overwrite)
await ctx.respond('Channel locked.')
@client.command(description="Unlock a channel!")
@commands.has_permissions(manage_channels=True)
@check(check_if_user_has_premium)
async def unlock(ctx, channel : discord.TextChannel):
channel = channel or ctx.channel
overwrite = channel.overwrites_for(ctx.guild.default_role)
overwrite.send_messages = True
await channel.set_permissions(ctx.guild.default_role, overwrite=overwrite)
await ctx.respond('Channel unlocked.')
@lock.error
async def lock_error(ctx, error):
if isinstance(error,commands.CheckFailure):
await ctx.respond('You do not have permission to use this command!')
@client.command(description="Start a poll")
@check(check_if_user_has_premium)
async def poll(ctx,*,message):
polle = discord.Embed(
title=message
)
lol = await ctx.send(embed=polle)
await lol.add_reaction("👍")
await lol.add_reaction("👎")
await ctx.respond("Poll started", ephemeral=True)
@client.command(description="Get a prawn picture")
@check(check_if_user_has_premium)
async def pron(ctx):
pronlist=["https://upload.wikimedia.org/wikipedia/commons/9/98/Penaeus_monodon.jpg","https://www.thefishsociety.co.uk/media/image/e3/1b/b0/prawn-ix.jpg","https://static8.depositphotos.com/1009628/870/i/950/depositphotos_8704465-stock-photo-fresh-prawn.jpg","https://www.thespruceeats.com/thmb/tyRFaxLEOMyqsI__qXeIqTvfyec=/2592x2592/smart/filters:no_upscale()/spotprawns-56b6bfe03df78c0b135b9c3c.jpg"]
pronpick = random.choice(pronlist)
await ctx.respond(pronpick)
@client.command(description="Get a random picture!")
@check(check_if_user_has_premium)
async def imagesearch(ctx, image):
embed = discord.Embed(
title = 'Image',
description = 'Your image',
colour = discord.Colour.purple()
)
embed.set_image(url='https://source.unsplash.com/1600x900/?{}'.format(image))
embed.set_footer(text=f"{image}")
await ctx.respond(embed=embed)
@client.command(description="Look up a github repo or user!")
@check(check_if_user_has_premium)
async def github(ctx,owner,repo=None):
if repo==None:
await ctx.respond(f"https://github.com/{owner}")
else:
await ctx.respond(f"https://github.com/{owner}/{repo}")
@client.command(description="Set a slowmode!")
@commands.has_permissions(manage_channels=True)
@check(check_if_user_has_premium)
async def slowmode(ctx,seconds:int):
await ctx.channel.edit(slowmode_delay=seconds)
await ctx.respond(f"Set the slowmode delay in this channel to {seconds} seconds!")
@client.command(description="See how many days ago the bot was created!")
@check(check_if_user_has_premium)
async def createday(ctx):
your_date = datetime.date(2022, 1, 26)
today = datetime.date.today()
delta = (today - your_date).days
await ctx.respond(f"FetchBot was created {delta} days ago")
@client.command(description="Get information about a shortening")
@check(check_if_user_has_premium)
async def shortening(ctx, *, shortening):
if shortening.lower()=="btw":
await ctx.respond("btw means; By the way")
elif shortening.lower()=="omg":
await ctx.respond("omg means; Oh my god")
elif shortening.lower()=="ty":
await ctx.respond("ty means; Thank you")
elif shortening.lower()=="thx":
await ctx.respond("thx means; Thanks")
else:
await ctx.respond("I don't have that shortening in my database. You could try with omg, or ty for example :)")
#ECONOMY COMMANDS BELOW ONLY
async def open_account(user):
users = await get_bank_data()
if str(user.id) in users:
return False
else:
users[str(user.id)] = {}
users[str(user.id)]["Wallet"] = 0
users[str(user.id)]["Bank"] = 0
with open("bank.json", 'w') as f:
json.dump(users, f)
return True
async def open_inventory(userinv):
usersinv = await get_inventory_data()
if str(userinv.id) in usersinv:
return False
else:
usersinv[str(userinv.id)] = {}
usersinv[str(userinv.id)]["Inventory"] = 0
with open("inventory.json", "w") as f:
json.dump(usersinv, f)
async def get_bank_data():
with open("bank.json", 'r') as f:
users = json.load(f)
return users
async def get_inventory_data():
with open("inventory.json", 'r') as f:
userinv = json.load(f)
return userinv
async def update_bank(user,change = 0,mode = "Wallet"):
users = await get_bank_data()
users[str(user.id)][mode] += change
with open("bank.json","w") as f :
json.dump(users,f)
bal = [users[str(user.id)] ["Wallet"],users[str(user.id)]["Bank"]]
return bal
async def setmoney(user,change = 0,mode = "wallet"):
users = await get_bank_data()
users[str(user.id)][mode] = change
with open("bank.json","w") as f :
json.dump(users,f)
bal = [users[str(user.id)] ["Wallet"],users[str(user.id)]["Bank"]]
return bal
@client.command(description="Set someones balance")
@commands.has_permissions(administrator=True)
async def set(ctx,member:discord.Member,amount:int,mode="Wallet"):
possible = ["Wallet","Bank"]
if mode not in possible :
await ctx.respond(f":x: Where is {mode} ? Please enter bank or wallet.")
return
await open_account(member)
await setmoney(member,amount,mode)
await ctx.respond(f":white_check_mark: Set {member.mention}'s {mode} to {amount}")
return
@client.command(description="See your bank balance!")
async def balance(ctx):
await open_account(ctx.author)
user = ctx.author
users = await get_bank_data()
wallet_amt = users[str(user.id)]["Wallet"]
bank_amt = users[str(user.id)]["Bank"]
em = discord.Embed(title=f"{ctx.author.name}'s balance.", color=discord.Color.teal())
em.add_field(name="Wallet Balance", value=wallet_amt)
em.add_field(name="Bank Balance", value=bank_amt)
await ctx.respond(embed=em)
@client.command(description="See another members' balance")
async def memberbalance(ctx,member:discord.Member):
await open_account(member)
user = member
users = await get_bank_data()
wallet_amt = users[str(user.id)]["Wallet"]
bank_amt = users[str(user.id)]["Bank"]
em = discord.Embed(title=f"{member.name}'s balance.", color=discord.Color.teal())
em.add_field(name="Wallet Balance", value=wallet_amt)
em.add_field(name="Bank Balance", value=bank_amt)
await ctx.respond(embed=em)
@client.command(description="View your inventory")
async def inventory(ctx):
await open_inventory(ctx.author)
userinv = ctx.author
usersinv = await get_inventory_data()
items = usersinv[str(userinv.id)]["Inventory"]
if items==1:
items="Gun"
elif items==2:
items="Armour"
elif items==3:
items="Mouse"
em = discord.Embed(title=f"{ctx.author.name}s inventory", color=discord.Color.teal())
em.add_field(name="Inventory", value=items)
await ctx.respond(embed=em)
@client.command(description="View another members' inventory")
async def memberinventory(ctx,member:discord.Member):
await open_inventory(member)
userinv = member
usersinv = await get_inventory_data()
items = usersinv[str(userinv.id)]["Inventory"]
if items==1:
items="Gun"
elif items==2:
items="Armour"
elif items==3:
items="Mouse"
em = discord.Embed(title=f"{member.name}s inventory", color=discord.Color.teal())
em.add_field(name="Inventory", value=items)
await ctx.respond(embed=em)
@client.command(description="Beg for coins!")
@commands.cooldown(1, 300, commands.BucketType.user)
async def beg(ctx):
await open_account(ctx.author)
user = ctx.author
users = await get_bank_data()
earnings = random.randint(1, 21)
await ctx.respond(f"Someone gave you {earnings} coins")
users[str(user.id)]["Wallet"] += earnings
with open("bank.json", 'w') as f:
json.dump(users, f)
@client.command(description="Get your daily reward!")
@commands.cooldown(1, 86400, commands.BucketType.user)
async def daily(ctx):
await open_account(ctx.author)
user = ctx.author
users = await get_bank_data()
earnings = random.randint(50, 101)
await ctx.respond(f"You earned {earnings} from selling some stuff online!")
users[str(user.id)]["Bank"] += earnings
with open("bank.json", 'w') as f:
json.dump(users, f)
@client.command(description="Do a bank robbery!")
@commands.cooldown(1, 2000, commands.BucketType.user)
async def rob(ctx):
await open_account(ctx.author)
user = ctx.author
users = await get_bank_data()
earnings = random.randint(300, 800)
wallet_amt = users[str(user.id)]["Wallet"]
decider = random.randint(0,1)
if decider == 1:
await ctx.respond(f"You just robbed the bank and got {earnings}!")
users[str(user.id)]["Wallet"] += earnings
with open("bank.json", 'w') as f:
json.dump(users, f)
else:
if wallet_amt > 500:
await ctx.respond("The police managed to catch you when you robbed the bank :pensive: They also took 500 credits from you")
users[str(user.id)]["Wallet"] -=500
with open("bank.json", 'w') as f:
json.dump(users, f)
else:
await ctx.respond(f"The police managed to catch you when you robbed the bank, and they also took {wallet_amt} credits from you! :pensive:")
users[str(user.id)]["Wallet"] -=wallet_amt
with open("bank.json", 'w') as f:
json.dump(users, f)
@client.command(description="Give some of your money to another member!")
async def pay(ctx,amount,member:discord.Member):
if amount == None :
return await ctx.respond(":x: Please enter a proper amount of money!")
try :
int(amount)
except :
return await ctx.respond(":x: Amount can only be a number!")
await open_account(ctx.author)
await open_account(member)
if member == ctx.author :
await ctx.respond("It's not a good idea to pay yourself")
return
bal = await update_bank(ctx.author)
if amount == "all":
amount = bal[0]
try :
amount = int(amount)
except :
await ctx.respond("Please enter a valid number")
return
if amount>bal[0]:
await ctx.respond("Please make sure you have enough money in your wallet!")
return
if amount<0:
await ctx.respond("Please enter a number bigger than 1")
return
await update_bank(ctx.author,-1*amount,"Wallet")
await update_bank(member,amount,"Wallet")
await ctx.respond(f":white_check_mark: Transaction completed! {amount} has been transfered to {member.name}")
@client.command(description="Rob another member!")
@commands.cooldown(1, 1000, commands.BucketType.user)
async def robmember(ctx,member:discord.Member):
await open_account(ctx.author)
await open_account(member)
user = ctx.author
mem = member