-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
3061 lines (2595 loc) · 118 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 nextcord
from nextcord import (
Interaction
)
from nextcord.ext import commands
from nextcord.ext.commands import (
BucketType,
Cooldown,
CooldownMapping,
)
from nextcord.ui import (
Button,
View,
button
)
from nextcord.errors import Forbidden
import os
import datetime
import random
from typing import (
List,
Callable,
)
import logging
import aiohttp
import humanfriendly
import yarsaw
import asyncio
import gtts
import motor
import motor.motor_asyncio
class FamuClient(commands.Bot):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
from urllib.parse import quote_plus
logging.basicConfig(level=logging.INFO)
logging.basicConfig(level=logging.WARNING)
logging.basicConfig(level=logging.CRITICAL)
logging.basicConfig(level=logging.ERROR)
logging.basicConfig(level=logging.DEBUG)
def edited_cooldown(rate, per, type=BucketType.default):
cooldown = Cooldown(rate, per)
cooldown_mapping = CooldownMapping(cooldown, type=type)
ApplicationCommand = nextcord.application_command.ApplicationCommand
ApplicationSubcommand = nextcord.application_command.ApplicationSubcommand
def decorator(func: Callable):
if isinstance(func, (ApplicationCommand, ApplicationSubcommand)):
func.callback._buckets = cooldown_mapping
else:
raise ValueError("Decorator must be applied to the command decorator, not the command function.")
return func
return decorator
bot = yarsaw.Client("ybSHEatbivek", "0fc8104d3bmsh9fcc7b9c2a86b3fp14c1ebjsn3b44d7af5e86")
guilds = 914050761917362186
intents = nextcord.Intents.all()
intents.members = True
intents.guilds = True
client = FamuClient(
command_prefix="?",
intents=intents,
help_command=None,
status=nextcord.Status.dnd,
owner_id=852485677777682432
)
cluster = motor.motor_asyncio.AsyncIOMotorClient("mongodb+srv://FlameyosFlow:reZPy4ZKz5YqumS@discord.fm5pk.mongodb.net/discord?retryWrites=true&w=majority&ssl_cert_reqs=CERT_NONE")
db = cluster.discord
collection = db.bank
companyaa = db.company
crates = db.crates
serverlevels = db.leveling
memberlevels = db.level
client.activity = nextcord.Game(name=f"Prefix - Slash Commands / | In {len([guild for guild in client.guilds])} guilds")
@client.event
async def on_ready():
"""Called upon the bot being ready"""
print('We are logged in as Famurai#5159 by FlameyosFlow#8894!')
class Google(View):
def __init__(self, query: str):
super().__init__()
query = quote_plus(query)
url = f"https://www.google.com/search?q={query}"
self.add_item(Button(label='Results From Google', url=url))
@client.slash_command(description="Search on google directly using this command!")
async def google(
interaction: Interaction,
query: str = nextcord.SlashOption(
name="search",
description="What would you like to search on google?",
required = True
)
):
view = Google(query)
async with interaction.channel.typing():
await interaction.send(f"Google Results for: `{query}`", view=view)
@client.slash_command(description="Greentext your text!")
async def greentext(
interaction: Interaction,
text: str = nextcord.SlashOption(
name="text",
description="What would you like to greentext?",
required=True
)
):
async with interaction.channel.typing():
await interaction.send(
"```"
f"{text}"
"```"
)
return
@client.slash_command(description="Set a reminder!")
async def remindme(
interaction: Interaction,
time = nextcord.SlashOption(
name="time",
description="How long is the timer? ex: 6h or 7d",
required=True
),
message = nextcord.SlashOption(
name="message",
description="What is your reminder message?",
required=True
),
):
duration = humanfriendly.parse_timespan(time)
await interaction.send(
f"Set reminder for {interaction.user.mention} \n{message} \n||Set for {time}||"
)
await asyncio.sleep(duration)
await interaction.channel.send(
f"Reminder for {interaction.user.mention} \n{message}"
)
@client.slash_command(description="Random birbs from the internet!")
async def birbs(interaction):
async with interaction.channel.typing():
async def get_birbs():
async with aiohttp.ClientSession() as cs:
async with cs.get("https://www.reddit.com/r/Birbs/new.json") as r:
res = await r.json()
return res['data']['children'][random.randint(0, 25)]['data']['url']
async def btncallback(interaction):
birbs = await get_birbs()
emb = interaction.message.embeds[0].set_image(url=birbs)
emb.set_footer(text=f"🤩: {random.randint(1, 10000)} 😢: {random.randint(1, 1000)}")
await interaction.response.edit_message(embed=emb)
async def delcallback(interaction):
await interaction.message.delete()
btn1 = Button(
label="Next Birb",
style=nextcord.ButtonStyle.green,
)
btn2 = Button(
style=nextcord.ButtonStyle.gray,
emoji="🗑️"
)
btn1.callback = btncallback
btn2.callback = delcallback
view=View()
view.add_item(btn1)
view.add_item(btn2)
embed = nextcord.Embed(title="These can talk, cool right?")
embed.set_image(url=await get_birbs())
embed.set_footer(text=f"🤩: {random.randint(1, 10000)} 😢: {random.randint(1, 1000)}")
await interaction.send(embed=embed, view=view)
@client.slash_command(description="Random pandas from the internet!")
async def aww(interaction):
async with interaction.channel.typing():
async def get_birbs():
async with aiohttp.ClientSession() as cs:
async with cs.get("https://www.reddit.com/r/aww/new.json") as r:
res = await r.json()
return res['data']['children'][random.randint(0, 25)]['data']['url']
async def btncallback(interaction):
birbs = await get_birbs()
emb = interaction.message.embeds[0].set_image(url=birbs)
emb.set_footer(text=f"🤩: {random.randint(1, 10000)} 😢: {random.randint(1, 1000)}")
await interaction.response.edit_message(embed=emb)
async def delcallback(interaction):
await interaction.message.delete()
btn1 = Button(
label="Next Cute Animal",
style=nextcord.ButtonStyle.green,
)
btn2 = Button(
style=nextcord.ButtonStyle.gray,
emoji="🗑️"
)
btn1.callback = btncallback
btn2.callback = delcallback
view=View()
view.add_item(btn1)
view.add_item(btn2)
embed = nextcord.Embed(title="These are SOOO CUTEEE")
embed.set_image(url=await get_birbs())
embed.set_footer(text=f"🤩: {random.randint(1, 10000)} 😢: {random.randint(1, 1000)}")
await interaction.send(embed=embed, view=view)
@client.slash_command(description="Random pandas from the internet!")
async def pandas(interaction):
async with interaction.channel.typing():
async def get_birbs():
async with aiohttp.ClientSession() as cs:
async with cs.get("https://www.reddit.com/r/panda/new.json") as r:
res = await r.json()
return res['data']['children'][random.randint(0, 25)]['data']['url']
async def btncallback(interaction):
birbs = await get_birbs()
emb = interaction.message.embeds[0].set_image(url=birbs)
emb.set_footer(text=f"🤩: {random.randint(1, 10000)} 😢: {random.randint(1, 1000)}")
await interaction.response.edit_message(embed=emb)
async def delcallback(interaction):
await interaction.message.delete()
btn1 = Button(
label="Next Panda",
style=nextcord.ButtonStyle.green,
)
btn2 = Button(
style=nextcord.ButtonStyle.gray,
emoji="🗑️"
)
btn1.callback = btncallback
btn2.callback = delcallback
view=View()
view.add_item(btn1)
view.add_item(btn2)
embed = nextcord.Embed(title="Cutest animals in my opinion:")
embed.set_image(url=await get_birbs())
embed.set_footer(text=f"🤩: {random.randint(1, 10000)} 😢: {random.randint(1, 1000)}")
await interaction.send(embed=embed, view=view)
@client.slash_command(description="Random kittys from the internet")
async def kittys(interaction):
async with interaction.channel.typing():
async def get_kittys():
async with aiohttp.ClientSession() as cs:
async with cs.get("https://www.reddit.com/r/catpictures/new.json") as r:
res = await r.json()
return res['data']['children'][random.randint(1, 25)]['data']['url']
async def btncallback(interaction):
cat = await get_kittys()
emb = interaction.message.embeds[0].set_image(url=cat)
emb.set_footer(text=f"🤩: {random.randint(1, 10000)} 😢: {random.randint(1, 1000)}")
await interaction.response.edit_message(embed=emb)
async def delcallback(interaction):
await interaction.message.delete()
btn1 = Button(
label="Next Kittys",
style=nextcord.ButtonStyle.green,
)
btn2 = Button(
style=nextcord.ButtonStyle.gray,
emoji="🗑️"
)
btn1.callback = btncallback
btn2.callback = delcallback
view=View()
view.add_item(btn1)
view.add_item(btn2)
embed = nextcord.Embed(title="I got one of the cutiest one:")
embed.set_image(url=await get_kittys())
embed.set_footer(text=f"🤩: {random.randint(1, 10000)} 😢: {random.randint(1, 1000)}")
await interaction.response.send_message(embed=embed, view=view)
@client.slash_command(description="Random puppys from the internet!")
async def puppy(interaction):
async with interaction.channel.typing():
async def get_puppys():
async with aiohttp.ClientSession() as cs:
async with cs.get("https://www.reddit.com/r/dogpictures/new.json") as r:
res = await r.json()
return res['data']['children'][random.randint(0, 25)]['data']['url']
async def btncallback(interaction):
pup = await get_puppys()
emb = interaction.message.embeds[0].set_image(url=pup)
emb.set_footer(text=f"🤩: {random.randint(1, 10001)} 😢: {random.randint(0, 1000)}")
await interaction.response.edit_message(embed=emb)
async def delcallback(interaction):
await interaction.message.delete()
btn1 = Button(
label="Next Puppy",
style=nextcord.ButtonStyle.green,
)
btn2 = Button(
style=nextcord.ButtonStyle.gray,
emoji="🗑️"
)
btn1.callback = btncallback
btn2.callback = delcallback
view=View()
view.add_item(btn1)
view.add_item(btn2)
embed = nextcord.Embed(
title="I got a cute one for you!"
)
embed.set_image(url=await get_puppys())
embed.set_footer(text= f"🤩: {random.randint(1, 10000)} 😢: {random.randint(1, 1000)}")
await interaction.response.send_message(embed=embed, view=view)
@client.slash_command(description="Get some memes!")
async def meme(interaction):
async with interaction.channel.typing():
async def get_meme():
async with aiohttp.ClientSession() as session:
async with session.get("https://www.reddit.com/r/dankmemes/new.json") as r:
res = await r.json()
return res['data']['children'][random.randint(0, 25)]['data']['url']
async def button_callback(interaction):
meme = await get_meme()
emb = interaction.message.embeds[0].set_image(url=meme)
emb.set_footer(text=f"🤩: {random.randint(0, 75000)} 😢: {random.randint(0, 35000)}")
await interaction.response.edit_message(embed=emb)
async def delete_callback(interaction):
await interaction.message.delete()
button1 = Button(
label="Next Meme",
style=nextcord.ButtonStyle.green,
)
button2 = Button(
label="🗑️",
style=nextcord.ButtonStyle.gray,
)
button1.callback = button_callback
button2.callback = delete_callback
view=View()
view.add_item(button1)
view.add_item(button2)
embed = nextcord.Embed(title="Rate this bad boi.")
embed.set_image(url=await get_meme())
embed.set_footer(text=f"🤩: {random.randint(0, 55000)} 😢: {random.randint(0, 35000)}")
await interaction.send(embed=embed, view=view)
@client.slash_command(description="Random red pandas from the internet (cute)!")
async def redpandas(interaction):
async with interaction.channel.typing():
async def get_meme():
async with aiohttp.ClientSession() as session:
async with session.get("https://www.reddit.com/r/redpandas/new.json") as r:
res = await r.json()
return res['data']['children'][random.randint(0, 25)]['data']['url']
async def button_callback(interaction):
meme = await get_meme()
emb = interaction.message.embeds[0].set_image(url=meme)
emb.set_footer(text=f"🤩: {random.randint(0, 75000)} 😢: {random.randint(0, 35000)}")
await interaction.response.edit_message(embed=emb)
async def delete_callback(interaction):
await interaction.message.delete()
button1 = Button(
label="Next Red Panda",
style=nextcord.ButtonStyle.green,
)
button2 = Button(
label="🗑️",
style=nextcord.ButtonStyle.gray,
)
button1.callback = button_callback
button2.callback = delete_callback
view=View()
view.add_item(button1)
view.add_item(button2)
embed = nextcord.Embed(title="How cute!!")
embed.set_image(url=await get_meme())
embed.set_footer(text=f"🤩: {random.randint(0, 55000)} 😢: {random.randint(0, 35000)}")
await interaction.send(embed=embed, view=view)
@client.slash_command(description="Random food from the internet (really tasty looking)!")
async def tastyfood(interaction):
async with interaction.channel.typing():
async def get_meme():
async with aiohttp.ClientSession() as session:
async with session.get("https://www.reddit.com/r/food/new.json") as r:
res = await r.json()
return res['data']['children'][random.randint(0, 25)]['data']['url']
async def button_callback(interaction):
meme = await get_meme()
emb = interaction.message.embeds[0].set_image(url=meme)
emb.set_footer(text=f"🤩: {random.randint(0, 75000)} 😢: {random.randint(0, 35000)}")
await interaction.response.edit_message(embed=emb)
async def delete_callback(interaction):
await interaction.message.delete()
button1 = Button(
label="Next Dish",
style=nextcord.ButtonStyle.green,
)
button2 = Button(
label="🗑️",
style=nextcord.ButtonStyle.gray,
)
button1.callback = button_callback
button2.callback = delete_callback
view=View()
view.add_item(button1)
view.add_item(button2)
embed = nextcord.Embed(title="I am starving just looking at these")
embed.set_image(url=await get_meme())
embed.set_footer(text=f"🤩: {random.randint(0, 55000)} 😢: {random.randint(0, 35000)}")
await interaction.send(embed=embed, view=view)
@client.slash_command(name="dice", description="Roll The Dice And Bet From 1 to 6")
async def dice(
interaction: Interaction,
bet: int = nextcord.SlashOption(
name="bet",
description="What do you wanna bet? 1-6",
required=True
),
amount = nextcord.SlashOption(
name="amount",
description="What is the amount of money that you want to bet?",
required=True
)
):
async with interaction.channel.typing():
member = interaction.user
findbank = await collection.find_one({"_id": member.id})
if not findbank:
await collection.insert_one({"_id": member.id, "wallet": 0, "bank": 0})
wallet = findbank["wallet"]
f = random.randint(0, 6)
if amount == "all":
amount = int(wallet)
else:
amount = int(amount)
if amount <= 0:
await interaction.send(f"{amount} is 0 or negative.")
return
elif amount > 300000:
await interaction.send(f"{amount} is more than $300,000.")
return
elif bet < 1 or bet > 6:
await interaction.send(f"{bet} is not a valid dice number.")
return
if bet == f:
em = nextcord.Embed(
title="You Won!",
description=f"My bet was {f} and your bet was {bet}",
color=nextcord.Color.green()
)
updated_money = wallet + amount
await collection.update_one({"_id": member.id}, {"$set": {"wallet": updated_money}})
await interaction.send(embed=em)
return
em = nextcord.Embed(
title="You Lost!",
description="My bet was {:,} and your bet was {:,}".format(f, bet),
color=nextcord.Color.red()
)
updated_money = wallet - amount
await collection.update_one({"_id": member.id}, {"$set": {"wallet": updated_money}})
await interaction.send(embed=em)
@client.slash_command(name="adventure", description="Stop it, Go Travel.")
async def adventure(
interaction: Interaction,
direction = nextcord.SlashOption(
name="direction",
choices={"Left", "Right", "Middle"},
description="Which direction do you wanna go?",
)
):
async with interaction.channel.typing():
member = interaction.user
f = random.randint(1, 101)
findcrates = await crates.find_one({"_id": member.id})
if not findcrates:
await crates.insert_one({"_id": member.id, "crates": 0})
num_crates = findcrates["crates"]
user = interaction.user
if direction == "Left":
if f >= 78:
await interaction.response.send_message(f"{user.mention} You went left, and you got 3 crates, CONGRATULATIONS! :D")
crates_updated = num_crates + 3
await crates.update_one({"_id": user.id}, {"$set": {"crates": crates_updated}})
elif f >= 60:
await interaction.response.send_message(f"{user.mention} You went left, and you got 2 crates, CONGRATULATIONS! :D")
crates_updated = num_crates + 2
await crates.update_one({"_id": user.id}, {"$set": {"crates": crates_updated}})
elif f >= 50:
await interaction.response.send_message(f"{user.mention} You went left, and you got 1 crate, CONGRATULATIONS! :D")
crates_updated = num_crates + 1
await crates.update_one({"_id": user.id}, {"$set": {"crates": crates_updated}})
else:
await interaction.response.send_message(f"{user.mention} You went left, and found nothing.")
return
elif direction == "Right":
if f >= 78:
await interaction.response.send_message(f"{user.mention} You went right, and you got THREE 3 crates, CONGRATULATIONS! :D")
crates_updated = num_crates + 3
await crates.update_one({"_id": user.id}, {"$set": {"crates": crates_updated}})
elif f >= 60:
await interaction.response.send_message(f"{user.mention} You went right, and you got TWO 2 crates, CONGRATULATIONS! :D")
crates_updated = num_crates + 2
await crates.update_one({"_id": user.id}, {"$set": {"crates": crates_updated}})
elif f >= 50:
await interaction.response.send_message(f"{user.mention} You went right, and you got ONE 1 crate, CONGRATULATIONS! :D")
crates_updated = num_crates + 1
await crates.update_one({"_id": user.id}, {"$set": {"crates": crates_updated}})
else:
await interaction.response.send_message(f"{user.mention} You went right, and found nothing.")
return
elif direction == "Middle":
if f >= 78:
await interaction.response.send_message(f"{user.mention} You went middle, and you got 3 crates, CONGRATULATIONS! :D")
crates_updated = num_crates + 3
await crates.update_one({"_id": user.id}, {"$set": {"crates": crates_updated}})
elif f >= 60:
await interaction.response.send_message(f"{user.mention} You went middle, and you got 2 crates, CONGRATULATIONS! :D")
crates_updated = num_crates + 2
await crates.update_one({"_id": user.id}, {"$set": {"crates": crates_updated}})
elif f >= 50:
await interaction.response.send_message(f"{user.mention} You went middle, and you got 1 crate, CONGRATULATIONS! :D")
crates_updated = num_crates + 1
await crates.update_one({"_id": user.id}, {"$set": {"crates": crates_updated}})
else:
await interaction.response.send_message(f"{user.mention} You went middle, and found nothing.")
return
@client.slash_command(description="See someone's avatar!")
async def avatar(
interaction: Interaction,
member: nextcord.Member = nextcord.SlashOption(
name="member",
description="Who are we taking avatar's picture?",
required=False
)
):
await interaction.response.defer()
member = member or interaction.user
async with interaction.channel.typing():
await interaction.followup.send(embed=nextcord.Embed(title=f"Here is {member.name}'s avatar!").set_image(url=member.display_avatar.url))
return
@client.slash_command(name="bal", description="Check your balance!")
async def balance(
interaction: Interaction,
member: nextcord.Member = nextcord.SlashOption(
name="member",
description="Who's balance are we checking?",
required=False
)
):
await interaction.response.defer()
async with interaction.channel.typing():
if member == None:
member = interaction.user
else:
member = member
findbank = await collection.find_one({"_id": member.id})
if not findbank:
await collection.insert_one({"_id": member.id, "wallet": 0, "bank": 0})
wallet = findbank["wallet"]
bank = findbank["bank"]
em = nextcord.Embed(title=f"{member.name}'s Balance", color=member.color)
em.add_field(name="Wallet Balance:", value="{:,}".format(wallet))
em.add_field(name='Bank Balance:', value="{:,}".format(bank))
await interaction.followup.send(embed=em)
@client.slash_command(name="beg", description="Beg off the streets!")
@commands.cooldown(rate=2, per=30.0, type=BucketType.user)
async def beg(interaction: Interaction):
member = interaction.user
findbank = await collection.find_one({"_id": member.id})
if not findbank:
await collection.insert_one({"_id": member.id, "wallet": 0, "bank": 0})
wallet = findbank["wallet"]
earnings = random.randrange(1, 1001)
begchance = random.randint(1, 101)
if begchance > 55:
em = nextcord.Embed(title="oh um-", description=f"No one gave you any money.", color=nextcord.Color.red(), timestamp=datetime.datetime.utcnow())
em.set_footer(text="Maybe next time buddy.")
await interaction.response.send_message(embed=em)
elif begchance < 45:
updated_money = wallet + earnings
await collection.update_one({"_id": member.id}, {"$set": {"wallet": updated_money}})
em = nextcord.Embed(title="les goo!", description=f"Someone gave you ${earnings}, May god keep Them.", color=nextcord.Color.green())
await interaction.response.send_message(embed=em)
return
class ConfirmDEP(View):
def __init__(self):
super().__init__()
self.value = None
@button(label='Confirm', style=nextcord.ButtonStyle.green)
async def confirm(self, button: Button, interaction: Interaction):
await interaction.response.send_message("You have confirmed this deposit!", ephemeral=True)
self.value = True
self.stop()
@button(label='Cancel', style=nextcord.ButtonStyle.red)
async def cancel(self, button: Button, interaction: Interaction):
await interaction.response.send_message("You have cancelled this deposit!", ephemeral=True)
self.value = False
self.stop()
@client.slash_command(
name="deposit",
description="Deposit some money to your bank!"
)
async def deposit(
interaction: Interaction,
amount: int = nextcord.SlashOption(
name="amount",
description="How much do you want to deposit?",
required=True
)
):
async with interaction.channel.typing():
member = interaction.user
findbank = await collection.find_one({"_id": member.id})
if not findbank:
await collection.insert_one({"_id": member.id, "wallet": 0, "bank": 0})
wallet = findbank["wallet"]
bank = findbank["bank"]
if amount == 'all':
if int(wallet) > 0:
amount = int(wallet)
else:
await interaction.response.send_message("You don't have any funds in your Wallet")
if amount > int(wallet):
await interaction.response.send_message("You have insufficient funds in your Wallet.")
return
if amount < 0:
await interaction.response.send_message("Your amount must be positive")
return
else:
view=ConfirmDEP()
await interaction.response.send_message(content="Are you sure you want to do this?", view=view, ephemeral=True)
await view.wait()
if view.value is None:
return
elif view.value:
updated_wallet = wallet - amount
updated_bank = bank + amount
await collection.update_one({"_id": member.id}, {"$set": {"wallet": updated_wallet}})
await collection.update_one({"_id": member.id}, {"$set": {"bank": updated_bank}})
await interaction.response.send_message(f"You deposited ${amount} coins from your Wallet, {interaction.user.mention}!", ephemeral=True)
else:
await interaction.response.send_message("You have cancelled this deposit!", ephemeral=True)
@client.slash_command(name="daily", description="Get daily money!")
async def daily(interaction: Interaction):
async with interaction.channel.typing():
member = interaction.user
findbank = await collection.find_one({"_id": member.id})
if not findbank:
await collection.insert_one({"_id": member.id, "wallet": 0, "bank": 0})
wallet = findbank["wallet"]
uw = wallet + 10000
await collection.update_one({"_id": member.id}, {"$set": {"wallet": uw}})
await interaction.send(f"You have recieved 10000 from /daily, see you next day!")
@client.event
async def on_command_error(interaction: Interaction, error):
if isinstance(error, commands.CommandNotFound):
em = nextcord.Embed(
title = "That command was not found!",
color=nextcord.Color.red(),
timestamp=datetime.datetime.utcnow()
)
await interaction.reply(embed=em)
raise error
@client.event
async def on_application_command_error(interaction, error):
if isinstance(error, commands.CommandOnCooldown):
embed=nextcord.Embed(
title="Hold up bud.",
description=f"Try again in {error.retry_after:,}"
)
await interaction.send(embed=embed)
@client.event
async def on_ready():
print('We are logged in as {0.user} by FlameyosFlow#8894!'.format(client))
@client.slash_command(name="ping", description="Famurai latency!")
async def ping(interaction: Interaction):
async with interaction.channel.typing():
if round(client.latency * 1000) <= 50:
embed = nextcord.Embed(
title="PONG!",
description=f"The ping is **{round(client.latency *1000)}** milliseconds!",
color=nextcord.Color.green()
)
elif round(client.latency * 1000) <= 100:
embed = nextcord.Embed(
title="PONG!",
description=f"The ping is **{round(client.latency *1000)}** milliseconds!",
color=nextcord.Color.green()
)
elif round(client.latency * 1000) <= 200:
embed = nextcord.Embed(
title="PONG!",
description=f"The ping is **{round(client.latency *1000)}** milliseconds!",
color=nextcord.Color.yellow()
)
else:
embed = nextcord.Embed(
title="PONG!",
description=f"The ping is **{round(client.latency *1000)}** milliseconds!",
color=nextcord.Color.red()
)
await interaction.response.send_message(embed=embed)
@client.slash_command(name="8ball", description="You have called the 8ball to predict the future for you.")
async def _8ball(
interaction: Interaction, *,
question: str = nextcord.SlashOption(
name="question",
description="What question do you wanna ask the bot?",
required=True
)
):
async with interaction.channel.typing():
possibilities = [
"Yes.",
"Ofcourse!",
"Maybe.",
"Infact, you're right!",
"Facts!",
"I don't know, I'm just an 8ball",
"Use another 8ball I'm not worth it :(",
"Probably not.",
"Ofcourse not!",
"No."
"Never",
"Suck it up #$&@%, Never Ever Ever Never Ever!"
]
responses = random.choice(possibilities)
if question.startswith("should") or question.startswith("did") or question.startswith("were") or question.startswith("may") or question.startswith("could") or question.startswith("would") or question.startswith("can") or question.startswith("is") or question.startswith("are") or question.startswith("will") or question.startswith("what") or question.startswith("do") or question.startswith("does") or question.startswith("am") or question.startswith("Should") or question.startswith("May") or question.startswith("Could") or question.startswith("Would") or question.startswith("Can") or question.startswith("Is") or question.startswith("Are") or question.startswith("Will") or question.startswith("What") or question.startswith("Do") or question.startswith("Does") or question.startswith("Am") or question.startswith("Did") or question.startswith("Were"):
if question.endswith("?"):
e = nextcord.Embed(title="The 8ball has spoken", color = nextcord.Color.random(), timestamp=datetime.datetime.utcnow())
e.add_field(name="Question:", value=f"{question}")
e.add_field(name="🎱 Answer:", value=f"🎱 {responses}", inline=False)
else:
e = nextcord.Embed(title="The 8ball has spoken", color = nextcord.Color.random(), timestamp=datetime.datetime.utcnow())
e.add_field(name="Question:", value=f"{question}?")
e.add_field(name="Answer:", value=f"{responses}", inline=False)
await interaction.response.send_message(embed=e)
return
else:
await interaction.response.send_message("That could not have been a question, start with: \n`do`, `is`, `are`, `did`, `were`, `could`, `will`, `can`, `would`, `what`, `may`, `should`, `does` or `am`")
@client.slash_command(name="search", description="Search for coins all around the world!")
@commands.cooldown(1, 120, BucketType.user)
async def search(
interaction: Interaction, *,
where: str = nextcord.SlashOption(
name="area",
description="Where do you wanna search for money?",
required=True
)
):
async with interaction.channel.typing():
member = interaction.user
findbank = await collection.find_one({"_id": member.id})
if not findbank:
await collection.insert_one({"_id": member.id, "wallet": 0, "bank": 0})
wallet = findbank["wallet"]
f = random.randint(1, 101)
earnings = random.randint(1, 1001)
jackpot = random.randint(21000, 30001)
jackpot_e = wallet + jackpot
earnings_e = wallet + earnings
if where == "park":
if f > 50:
e = nextcord.Embed(
title="Hooray!",
description="You searched the park and found a wallet with ${:,}!".format(earnings),
color=nextcord.Color.random(),
timestamp=datetime.datetime.utcnow()
)
await interaction.response.send_message(embed=e)
await collection.update_one({"_id": member.id}, {"$set": {"wallet": earnings_e}})
elif f == 50:
e = nextcord.Embed(
title="HOLY-",
description="You searched the park and found a wallet with ${:,}!".format(jackpot),
color=nextcord.Color.random(),
timestamp=datetime.datetime.utcnow()
)
await interaction.response.send_message(embed=e)
await collection.update_one({"_id": member.id}, {"$set": {"wallet": jackpot_e}})
else:
e = nextcord.Embed(
title="ooh-",
description=f"You searched the park and found nothing.",
color=nextcord.Color.random(),
timestamp=datetime.datetime.utcnow()
)
await interaction.response.send_message(embed=e)
return
elif where == "closet":
if f > 50:
e = nextcord.Embed(
title="Hooray!",
description="You searched your closet and found ${:,}!".format(earnings),
color=nextcord.Color.random(),
timestamp=datetime.datetime.utcnow()
)
await interaction.response.send_message(embed=e)
return
await collection.update_one({"_id": member.id}, {"$set": {"wallet": earnings_e}})
elif f == 50:
e = nextcord.Embed(
title="HOLY-",
description="You searched your closet and found ${:,}!".format(jackpot),
color=nextcord.Color.random(),
timestamp=datetime.datetime.utcnow()
)
await interaction.response.send_message(embed=e)
return
await collection.update_one({"_id": member.id}, {"$set": {"wallet": jackpot_e}})
else:
e = nextcord.Embed(
title="ooh-",
description=f"You searched your closet and found nothing but clothes.",
color=nextcord.Color.random(),
timestamp=datetime.datetime.utcnow()
)
await interaction.response.send_message(embed=e)
return
elif where == "bed":
if f > 50:
e = nextcord.Embed(
title="Hooray!",
description="You searched under your bed and found ${:,}!".format(earnings),
color=nextcord.Color.random(),
timestamp=datetime.datetime.utcnow()
)
await interaction.response.send_message(embed=e)
return
await collection.update_one({"_id": member.id}, {"$set": {"wallet": earnings_e}})
elif f == 50: