-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandy.py
1281 lines (1120 loc) · 54.7 KB
/
Randy.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 smtplib
import ssl
import discord
import time
import requests
import random
import re
from discord.ext import commands
from discord.ext.commands import MissingPermissions
from discord.ext.commands import has_permissions
from googletrans import Translator
import os
import json
import sqlite3
global tokens
with open('tokens.json', 'r') as l:
tokens = json.load(l)
TOKEN = tokens['bottoken']
client = commands.Bot(command_prefix=">")
translator = Translator()
@client.command()
async def userinfo(ctx, member: discord.Member = None):
if not member:
member = ctx.author
roles = [role for role in member.roles]
embed = discord.Embed(title='User Info', colour=member.color, timestamp=ctx.message.created_at)
embed.set_thumbnail(url=member.avatar_url)
embed.set_author(name=f'{member}', icon_url=member.avatar_url)
embed.set_footer(text=f'Requested by {ctx.author}')
embed.add_field(name='Name', value=f'{member}', inline=True)
embed.add_field(name='ID:', value=member.id, inline=True)
embed.add_field(name='Guild Name:', value=member.display_name, inline=False)
embed.add_field(name='Created At:', value=member.created_at.strftime('%a, %#d %B %Y, %I:%M %p UTC'), inline=False)
embed.add_field(name='Joined At:', value=member.joined_at.strftime('%a, %#d %B %Y, %I:%M %p UTC'), inline=False)
embed.add_field(name=f'Roles ({len(roles)})', value=" ".join([role.mention for role in roles]), inline=False)
embed.add_field(name='Top Role:', value=member.top_role.mention, inline=False)
await ctx.send(embed=embed)
@client.event
async def on_member_join(member):
for channel in member.guild.channels:
if str(channel) == "member-log":
await channel.send(f"""Welcome to the server {member.mention}!""")
await update_data(member)
@client.event
async def on_message(message):
if message.author.bot == False:
await update_data(message.author)
await add_experience(message.author, 5)
await level_up(message.author, message)
await client.process_commands(message)
async def update_data(user):
sqliteConnection = sqlite3.connect(r'C:\sqlite\users.db')
cursor = sqliteConnection.cursor()
a = user.id
a = str(a)
b = cursor.execute('Select userid from usersjson where userid = ?', (a,))
c = b.fetchone()
if c is None:
cursor.execute("INSERT INTO usersjson (userid, experience, level) VALUES(?, ?, ?)",
(a, 0, 1))
sqliteConnection.commit()
cursor.close()
async def add_experience(user, exp):
sqliteConnection = sqlite3.connect(r'C:\sqlite\users.db')
cursor = sqliteConnection.cursor()
a = user.id
a = str(a)
c = cursor.execute('Select experience from usersjson where userid = ?', (a,))
c = c.fetchone()
c = c[0]
c = c + 5
cursor.execute('Update usersjson SET experience = ? where userid = ?', (c, a))
sqliteConnection.commit()
cursor.close()
async def level_up(user, message):
sqliteConnection = sqlite3.connect(r'C:\sqlite\users.db')
cursor = sqliteConnection.cursor()
a = user.id
a = str(a)
c = cursor.execute('Select experience from usersjson where userid = ?', (a,))
c = c.fetchone()
c = c[0]
experience = c
d = cursor.execute('Select level from usersjson where userid = ?', (a,))
d = d.fetchone()
d = d[0]
lvl_start = d
lvl_end = int(experience ** (1 / 4))
sqliteConnection.commit()
cursor.close()
if lvl_start < lvl_end:
sqliteConnection = sqlite3.connect(r'C:\sqlite\users.db')
cursor = sqliteConnection.cursor()
cursor.execute('Update usersjson SET level = ? where userid = ?', (lvl_end, a,))
guild = message.guild
f = guild.id
sqliteConnection.commit()
cursor.close()
sqliteConnection = sqlite3.connect(r'C:\sqlite\users.db')
cursor = sqliteConnection.cursor()
e = cursor.execute('Select * from levelsjson where guildid = ?', (f,))
e = e.fetchall()
e = e[0][1]
sqliteConnection.commit()
cursor.close()
if e == 'on':
sqliteConnection = sqlite3.connect(r'C:\sqlite\users.db')
cursor = sqliteConnection.cursor()
d = cursor.execute('Select level from usersjson where userid = ?', (a,))
d = d.fetchone()
d = d[0]
lvl = d
sqliteConnection.commit()
cursor.close()
await message.add_reaction('lev: 712873162437820427')
await message.add_reaction('🇻')
await message.add_reaction('🇱')
a = list(str(lvl))
n = 1
o = 1
p = 1
q = 1
r = 1
s = 1
t = 1
u = 1
v = 1
w = 1
for i in a:
if i == '1':
if n == 1:
await message.add_reaction('1️⃣')
n = n + 1
elif n == 2:
await message.add_reaction('one: 712884652918177822')
if i == '2':
if o == 1:
await message.add_reaction('2️⃣')
o = o + 1
elif 0 == 2:
await message.add_reaction('two: 712887818111680513')
if i == '3':
if p == 1:
await message.add_reaction('3️⃣')
p = p + 1
elif p == 2:
await message.add_reaction('three: 712887844300914738')
if i == '4':
if q == 1:
await message.add_reaction('4️⃣')
q = q + 1
elif q == 2:
await message.add_reaction('four: 712887869244571658')
if i == '5':
if r == 1:
await message.add_reaction('5️⃣')
r = r + 1
elif r == 2:
await message.add_reaction('five: 712887892547993660')
if i == '6':
if s == 1:
await message.add_reaction('6️⃣')
s = s + 1
elif s == 2:
await message.add_reaction('six: 712887915218206741')
if i == '7':
if t == 1:
await message.add_reaction('7️⃣')
t = t + 1
elif t == 2:
await message.add_reaction('seven: 712887949284343840')
if i == '8':
if u == 1:
await message.add_reaction('8️⃣')
u = u + 1
elif u == 2:
await message.add_reaction('eight: 712887971434725404')
if i == '9':
if v == 1:
await message.add_reaction('9️⃣')
v = v + 1
elif v == 2:
await message.add_reaction('nine: 712887993102237790')
if i == '0':
if w == 1:
await message.add_reaction('0️⃣')
w = w + 1
elif w == 2:
await message.add_reaction('zero: 712888015869050919')
@client.command()
async def removemydata(ctx):
await ctx.send(
'Are you sure you want to delete your data? All your progress in the level system will be lost! (Y/N)')
a = await get_input_of_type(str, ctx)
a = a.capitalize()
if a == 'Y':
a = ctx.message.author.id
sqliteConnection = sqlite3.connect(r'C:\sqlite\users.db')
cursor = sqliteConnection.cursor()
cursor.execute("DELETE FROM usersjson WHERE userid = ?",
(a,))
sqliteConnection.commit()
cursor.close()
await ctx.send('Your data has been successfully deleted!')
if a == 'N':
await ctx.send("Alright, let's pretend that never happened!")
@client.command(aliases=['top'])
async def globalleaderboard(ctx):
sqliteConnection = sqlite3.connect(r'C:\sqlite\users.db')
cursor = sqliteConnection.cursor()
c = cursor.execute('select * from usersjson order by experience desc limit 3')
c = c.fetchall()
b = c[0][0]
d = c[1][0]
f = c[2][0]
red = random.randint(0, 255)
green = random.randint(0, 255)
blue = random.randint(0, 255)
embed = discord.Embed(title='Leaderboard', description='Top Globally',
color=discord.Colour.from_rgb(red, green, blue), )
user1 = client.get_user(int(b))
user2 = client.get_user(int(d))
user3 = client.get_user(int(f))
embed.add_field(name='1st Place',
value=str(user1) + ' with ' + str(c[0][1]) + ' experience points (level ' + str(c[0][2]) + ')')
embed.add_field(name='2nd Place',
value=str(user2) + ' with ' + str(c[1][1]) + ' experience points (level ' + str(c[1][2]) + ')')
embed.add_field(name='3rd Place',
value=str(user3) + ' with ' + str(c[2][1]) + ' experience points (level ' + str(c[2][2]) + ')')
await ctx.send(embed=embed)
sqliteConnection.commit()
cursor.close()
@client.command()
async def level(ctx, member: discord.Member = None):
if not member:
id = ctx.message.author.id
id = str(id)
sqliteConnection = sqlite3.connect(r'C:\sqlite\users.db')
cursor = sqliteConnection.cursor()
c = cursor.execute('Select level from usersjson where userid = ?', (id,))
c = c.fetchone()
c = c[0]
lvl = c
await ctx.send(f'You are at level {lvl}!')
sqliteConnection.commit()
cursor.close()
else:
id = member.id
id = str(id)
sqliteConnection = sqlite3.connect(r'C:\sqlite\users.db')
cursor = sqliteConnection.cursor()
c = cursor.execute('Select level from usersjson where userid = ?', (id,))
c = c.fetchone()
c = c[0]
lvl = c
await ctx.send(f'{member} is at level {lvl}!')
sqliteConnection.commit()
cursor.close()
@client.command()
@has_permissions(manage_messages=True)
async def levels(ctx, arg):
if arg == 'on':
a = ctx.guild.id
sqliteConnection = sqlite3.connect(r'C:\sqlite\users.db')
cursor = sqliteConnection.cursor()
cursor.execute('update levelsjson set tf = ? where guildid = ?', ('on', a))
sqliteConnection.commit()
cursor.close()
await ctx.send('Levelling reactions have been turned on!')
if arg == 'off':
a = ctx.guild.id
sqliteConnection = sqlite3.connect(r'C:\sqlite\users.db')
cursor = sqliteConnection.cursor()
cursor.execute('update levelsjson set tf = ? where guildid = ?', ('off', a))
sqliteConnection.commit()
cursor.close()
await ctx.send('Levelling reactions have been turned off.')
@levels.error
async def levels_error(ctx, error):
if isinstance(error, MissingPermissions):
await ctx.send("Sorry, you do not have permissions to change this setting!")
@client.event
async def on_guild_join(guild):
a = guild.id
sqliteConnection = sqlite3.connect(r'C:\sqlite\users.db')
cursor = sqliteConnection.cursor()
cursor.execute("INSERT INTO levelsjson (guildid, tf) VALUES(?, ?)",
(a, "off"))
sqliteConnection.commit()
cursor.close()
@client.event
async def on_guild_remove(guild):
a = guild.id
sqliteConnection = sqlite3.connect(r'C:\sqlite\users.db')
cursor = sqliteConnection.cursor()
cursor.execute("DELETE FROM levelsjson WHERE guildid = ?",
(a,))
sqliteConnection.commit()
cursor.close()
@client.command()
async def servers(ctx):
servers = list(client.guilds)
await ctx.send(f"Connected on {str(len(servers))} servers!")
@client.command()
async def rip(ctx):
await ctx.send("Guilds with <3 users:")
for guild in client.guilds:
if len(guild.members) < 3:
await ctx.send(f"{guild.name}")
@client.command(aliases=['guess', 'guessnum', 'guessnumber'])
async def ngg(ctx):
await ctx.send("Number guessing game!")
number = random.randint(1, 9)
chances = 0
await ctx.send("Guess a number (between 1 and 9):")
while chances < 3:
guess = await get_input_of_type(int, ctx)
if guess == number:
await ctx.send("Congratulation YOU WON!!!")
break
elif guess < number:
await ctx.send("Your guess was too low: Guess a number higher than " + str(guess))
chances += 1
else:
await ctx.send("Your guess was too high: Guess a number lower than " + str(guess))
chances += 1
if not chances < 3:
await ctx.send("YOU LOSE!!! The number is " + str(number))
@client.command(aliases=['black', 'bj', 'blacks'])
async def blackjack(ctx):
deck = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] * 4
async def deal(deck):
hand = []
for i in range(2):
random.shuffle(deck)
card = deck.pop()
if card == 11:
card = "J"
if card == 12:
card = "Q"
if card == 13:
card = "K"
if card == 14:
card = "A"
hand.append(card)
return hand
async def total(hand):
total = 0
for card in hand:
if card == "J" or card == "Q" or card == "K":
total += 10
elif card == "A":
if total >= 11:
total += 1
else:
total += 11
else:
total += card
return total
async def hit(hand):
card = deck.pop()
if card == 11:
card = "J"
if card == 12:
card = "Q"
if card == 13:
card = "K"
if card == 14:
card = "A"
hand.append(card)
return hand
async def print_results(dealer_hand, player_hand):
await ctx.send("The dealer has a " + str(dealer_hand) + " for a total of " + str(await total(dealer_hand)))
await ctx.send("You have a " + str(player_hand) + " for a total of " + str(await total(player_hand)))
async def blackjack(dealer_hand, player_hand):
if await total(player_hand) == 21:
await print_results(dealer_hand, player_hand)
await ctx.send("Congratulations! You got a Blackjack!\n")
elif await total(dealer_hand) == 21:
await print_results(dealer_hand, player_hand)
await ctx.send("Sorry, you lose. The dealer got a blackjack.\n")
async def score(dealer_hand, player_hand):
if await total(player_hand) == 21:
await print_results(dealer_hand, player_hand)
await ctx.send("Congratulations! You got a Blackjack!\n")
elif await total(dealer_hand) == 21:
await print_results(dealer_hand, player_hand)
await ctx.send("Sorry, you lose. The dealer got a blackjack.\n")
elif await total(player_hand) > 21:
await print_results(dealer_hand, player_hand)
await ctx.send("Sorry. You busted. You lose.\n")
elif await total(dealer_hand) > 21:
await print_results(dealer_hand, player_hand)
await ctx.send("Dealer busts. You win!\n")
elif total(player_hand) < total(dealer_hand):
await print_results(dealer_hand, player_hand)
await ctx.send("Sorry. Your score isn't higher than the dealer. You lose")
elif await total(player_hand) > total(dealer_hand):
await print_results(dealer_hand, player_hand)
await ctx.send("ur score is higher than the dealer. You win")
def check(ctx):
return lambda m: m.author == ctx.author and m.channel == ctx.channel
async def get_input_of_type(func, ctx):
while True:
try:
msg = await client.wait_for('message', check=check(ctx))
return func(msg.content)
except ValueError:
continue
await ctx.send("WELCOME TO BLACKJACK!")
dealer_hand = await deal(deck)
player_hand = await deal(deck)
await ctx.send("The dealer is showing a " + str(dealer_hand[0]))
await ctx.send("You have a " + str(player_hand) + " for a total of " + str(await total(player_hand)))
await blackjack(dealer_hand, player_hand)
quit = False
while not quit:
await ctx.send("Do you want to [H]it, [S]tand, or [Q]uit")
choice = await get_input_of_type(str, ctx)
choice = choice.lower()
if choice == 'h':
await hit(player_hand)
await ctx.send(player_hand)
await ctx.send("Hand total: " + str(await total(player_hand)))
if await total(player_hand) > 21:
await ctx.send('You busted')
quit = True
elif choice == 's':
while await total(dealer_hand) < 17:
await hit(dealer_hand)
await ctx.send(dealer_hand)
if await total(dealer_hand) > 21:
await ctx.send('Dealer busts, you win!')
quit = True
await score(dealer_hand, player_hand)
elif choice == "q":
await ctx.send("Bye!")
quit = True
@client.command(brief='Trivia')
async def trivia(ctx):
results = requests.get('https://opentdb.com/api.php?amount=1&type=boolean').json()
y = results['results'][0]['question'] + ' (T/F)'
y = re.sub('"', '"', y)
await ctx.send(str(y))
ans = results['results'][0]['correct_answer']
us_ans = await get_input_of_type(str, ctx)
if ans == 'True':
ans = 'T'
elif ans == 'False':
ans = 'F'
if ans == us_ans:
await ctx.send('You are correct!')
else:
await ctx.send('You are wrong.')
@client.command(pass_context=True, aliases=['nickname'])
@has_permissions(manage_nicknames=True)
async def nick(ctx, member: discord.Member = None):
if not member:
member = ctx.message.author
await ctx.send('Enter nickname: ')
nick = await get_input_of_type(str, ctx)
await member.edit(nick=nick)
await ctx.send(f'Nickname was changed for {member.mention} ')
@nick.error
async def nick_error(ctx, error):
if isinstance(error, MissingPermissions):
await ctx.send("Sorry, you do not have permissions to change users' nickname!")
def check(ctx):
return lambda m: m.author == ctx.author and m.channel == ctx.channel
async def get_input_of_type(func, ctx):
while True:
try:
msg = await client.wait_for('message', check=check(ctx))
return func(msg.content)
except ValueError:
continue
@client.command()
async def add(ctx):
await ctx.send("What is the first number?")
firstnum = await get_input_of_type(float, ctx)
await ctx.send("What is the second number?")
secondnum = await get_input_of_type(float, ctx)
await ctx.send(f"{firstnum} + {secondnum} = {firstnum + secondnum}")
@client.command(aliases=['sub'])
async def subtract(ctx):
await ctx.send("What is the first number?")
firstnum = await get_input_of_type(float, ctx)
await ctx.send("What is the second number?")
secondnum = await get_input_of_type(float, ctx)
await ctx.send(f"{firstnum} - {secondnum} = {firstnum - secondnum}")
@client.command(aliases=['multiply'])
async def mult(ctx):
await ctx.send("What is the first number?")
firstnum = await get_input_of_type(float, ctx)
await ctx.send("What is the second number?")
secondnum = await get_input_of_type(float, ctx)
await ctx.send(f"{firstnum} * {secondnum} = {firstnum * secondnum}")
@client.command(aliases=['division', 'div'])
async def divide(ctx):
await ctx.send("What is the first number?")
firstnum = await get_input_of_type(float, ctx)
await ctx.send("What is the second number?")
secondnum = await get_input_of_type(float, ctx)
await ctx.send(f"{firstnum} / {secondnum} = {firstnum / secondnum}")
@client.command(brief='Lyrics')
async def lyrics(ctx, *, song):
song = 'http://some-random-api.ml/lyrics?title=' + song
song = re.sub(' ', '%20', song)
lyrics = requests.get(song).json()
lyrics = lyrics['lyrics']
await ctx.send(lyrics[0:1900])
await ctx.send(lyrics[1900:-1])
@client.command()
async def email(ctx, email, *, content):
port = 587
smtp_server = "smtp.gmail.com"
sender_email = tokens['email']
receiver_email = email
message = """\
Subject: Sent from Randy-Discord Bot
""" + content
context = ssl.create_default_context()
with smtplib.SMTP(smtp_server, port) as server:
server.ehlo()
server.starttls(context=context)
server.ehlo()
server.login(sender_email, tokens['password'])
server.sendmail(sender_email, receiver_email, message)
await ctx.send('Email has been sent!')
@client.command()
async def vote(ctx):
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
embed = discord.Embed(
title='Vote for Randy',
description='Vote for Randy',
color=discord.Colour.from_rgb(r, g, b),
)
embed.add_field(name='BFD', value='[Vote here](https://botsfordiscord.com/bot/696185454759903264/vote)')
embed.add_field(name='top.gg', value='[Vote here](https://top.gg/bot/696185454759903264/vote)')
embed.set_thumbnail(
url='https://cdn.discordapp.com/attachments/706338290693046283/707085433552764968/RandyLogo.png')
embed.add_field(name='DBL', value='[Vote here](https://discordbotlist.com/bots/randy/upvote)')
embed.add_field(name='Bulkypanda Discord Bio', value='[Vote here](https://dsc.bio/bulkypanda)')
embed.add_field(name='Hvhvuu Discord Bio', value='[Vote here](https://dsc.bio/hvhvuu)')
await ctx.send(embed=embed)
@client.command()
async def chat(ctx):
await ctx.send('Hello!')
text = await get_input_of_type(str, ctx)
if text == 'stop':
await ctx.send('Nice talking to you, cya!')
result = requests.get('https://some-random-api.ml/chatbot?message=' + text).json()
response = result['response']
try:
await ctx.send(response)
except:
await ctx.send('ok')
inp = await get_input_of_type(str, ctx)
if inp == 'stop':
await ctx.send('Nice talking to you, cya!')
while inp != 'stop':
result = requests.get('https://some-random-api.ml/chatbot?message=' + inp).json()
response = result['response']
try:
await ctx.send(response)
except:
await ctx.send('ok')
inp = await get_input_of_type(str, ctx)
if inp == 'stop':
await ctx.send('Nice talking to you, cya!')
@client.command(brief='Translations')
async def trans(ctx, src, dest, tim):
await ctx.send('Translation has started!')
x = float(tim) * 60
y = time.time()
while str(y) < str(x):
inp = await get_input_of_type(str, ctx)
translated = translator.translate(inp, src=src, dest=dest)
await ctx.send(translated.text)
end = time.time()
y = int(end) - int(y)
y = str(y)
await ctx.send('Translation has ended!')
@client.command()
async def load(ctx, extension):
client.load_extension(f'cogs.{extension}')
@client.command()
async def unload(ctx, extension):
client.unload_extension(f'cogs.{extension}')
@client.command()
async def reload(ctx, extension):
client.load_extension(f'cogs.{extension}')
client.unload_extension(f'cogs.{extension}')
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')
@client.command(brief='Kick')
@has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member, *, reason='None'):
await member.kick(reason=reason)
await ctx.send('Kicked!')
@kick.error
async def kick_error(ctx, error):
if isinstance(error, MissingPermissions):
await ctx.send('Sorry, you do not have permissions to kick users!')
@client.command(brief='Ban')
@has_permissions(ban_members=True)
async def ban(ctx, member: discord.Member, *, reason='None'):
await member.ban(reason=reason)
await ctx.send('Banned!')
@ban.error
async def ban_error(ctx, error):
if isinstance(error, MissingPermissions):
await ctx.send('Sorry, you do not have permissions to ban users!')
@client.command(brief='Unban')
@has_permissions(ban_members=True)
async def unban(ctx, *, member):
banned_users = await ctx.guild.bans()
member_name, member_discriminator = member.split("#")
for ban_entry in banned_users:
user = ban_entry.user
if (user.name, user.discriminator) == (member_name, member_discriminator):
await ctx.guild.unban(user)
await ctx.send(f'Unbanned {user.mention}')
return
@unban.error
async def unban_error(ctx, error):
if isinstance(error, MissingPermissions):
await ctx.send('Sorry, you do not have permissions to unban users!')
@client.command()
@has_permissions(manage_roles=True)
async def mute(ctx, members: commands.Greedy[discord.Member], *, reason=""):
if len(members) < 1:
return await ctx.send("Please specify a user!")
for member in members:
await ctx.channel.set_permissions(member, send_messages=False, reason=reason)
await ctx.send("Successfully muted {1} {0}".format("for " + reason if not reason == "" else "",
", ".join(["<@" + str(member.id) + ">" for member in members])))
@mute.error
async def mute_error(ctx, error):
if isinstance(error, MissingPermissions):
await ctx.send('Sorry, you do not have permissions to mute users!')
@client.command()
@has_permissions(manage_roles=True)
async def unmute(ctx, members: commands.Greedy[discord.Member], *, reason=""):
if len(members) < 1:
return await ctx.send("Please specify a user!")
for member in members:
await ctx.channel.set_permissions(member, send_messages=None, reason=reason)
await ctx.send("Successfully unmuted {1} {0}".format("for " + reason if not reason == "" else "", ", ".join(
["<@" + str(member.id) + ">" for member in members])))
@unmute.error
async def unmute_error(ctx, error):
if isinstance(error, MissingPermissions):
await ctx.send('Sorry, you do not have permissions to unmute users!')
@client.command()
@has_permissions(manage_messages=True)
async def lock(ctx):
await ctx.channel.set_permissions(ctx.guild.default_role, send_messages=False)
await ctx.send('Locked!')
@lock.error
async def lock_error(ctx, error):
if isinstance(error, MissingPermissions):
await ctx.send('Sorry, you do not have permissions to lock channels!')
@client.command()
@has_permissions(manage_messages=True)
async def unlock(ctx):
await ctx.channel.set_permissions(ctx.guild.default_role, send_messages=True)
await ctx.send('Unlocked!')
@unlock.error
async def unlock_error(ctx, error):
if isinstance(error, MissingPermissions):
await ctx.send('Sorry, you do not have permissions to unlock channels!')
@client.command(aliases=["arya", "Clear"], brief='Clear Messages')
@has_permissions(manage_messages=True)
async def clear(ctx, amount):
amount = int(amount) + 1
await ctx.channel.purge(limit=amount)
@clear.error
async def clear_error(ctx, error):
if isinstance(error, MissingPermissions):
await ctx.send('Sorry, you do not have permissions to clear messages!')
@client.command(aliases=['msg', 'Message', 'broadcast', 'broad'], brief='Only for admins!')
@has_permissions(administrator=True)
async def message(ctx, *, message):
amount = 1
await ctx.channel.purge(limit=amount)
await ctx.channel.send(message)
@message.error
async def message_error(ctx, error):
if isinstance(error, MissingPermissions):
await ctx.send('Sorry, you do not have permissions to broadcast!')
@client.command(aliases=['dev'])
async def script(ctx):
await ctx.send('https://github.com/bulkypanda/RandyDev')
async def cv(ctx, id):
bruh = {"Authorization": tokens['topgg']}
url = requests.get("https://top.gg/api/bots/696185454759903264/check?userId=" + str(id), headers=bruh).json()
if url['voted'] == 1:
return True
@client.command(brief="About the bot!", aliases=['About'], pass_context='True')
async def about(ctx):
aryaid = '<@626913781779267594>'
ishaanid = '<@469939274783916032>'
adityaid = '<@410943247754592256>'
razaid = '<@425315544070356992>'
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
embed = discord.Embed(color=discord.Colour.from_rgb(r, g, b))
embed.set_author(name="Credits")
embed.add_field(name='Bot Commands', value=aryaid + ', ' + ishaanid, inline=False)
embed.add_field(name='Website', value=aryaid, inline=False)
embed.add_field(name='Graphics', value=razaid, inline=False)
await ctx.send(embed=embed)
@client.event
async def on_member_remove(member):
for channel in member.guild.channels:
if str(channel) == "member-log": # We check to make sure we are sending the message in the general channel
await channel.send(f"""Bye Bye {member.mention}!""")
@client.remove_command("help")
@client.command(pass_context=True)
async def help(ctx, arg='yo'):
if arg == 'yo':
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
embed = discord.Embed(title="Randy Command List", color=discord.Colour.from_rgb(r, g, b))
embed.set_author(name=f'Randy',
icon_url='https://cdn.discordapp.com/attachments/711007670924083221/719285425008803910/RandyPFP.png')
embed.add_field(name='`>about`', value=':eyes: About!', inline=True)
# embed.add_field(name='`>changeprefix (prefix)`', value=':100: Change the bot prefix!', inline=True)
embed.add_field(name='`>email (to) (message)`', value=':e_mail: Send an email!', inline=True)
embed.set_thumbnail(
url='https://cdn.discordapp.com/attachments/706665974484566138/717442170214154320/1200px-Fist.svg.webp')
# embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/706338290693046283/707085433552764968/RandyLogo.png')
embed.add_field(name='`>vote`', value=':v: Vote for Randy!', inline=True)
embed.add_field(name='`>feedback (feedback)`', value=':incoming_envelope: Feedback for devs.',
inline=True)
embed.add_field(name='`>server`', value='Link to invite Randy & help server', inline=True)
embed.add_field(name='`>help fun`', value=':smile: Fun Commands', inline=True)
embed.add_field(name='`>help image`', value=':yum: Image Commands', inline=True)
embed.add_field(name='`>help info`', value=':newspaper: General Information', inline=True)
embed.add_field(name='`>help lang`', value=':blue_book: Language Commands', inline=True)
embed.add_field(name='`>help level`', value='🆙 Level System Commands', inline=True)
embed.add_field(name='`>help math`', value=':regional_indicator_m: Math Commands', inline=True)
embed.add_field(name='`>help mg`', value=':video_game: Minigames!', inline=True)
embed.add_field(name='`>help mod`', value=':hammer_pick: Moderation Commands', inline=True)
embed.add_field(name='`>help money`', value=':moneybag: Money Commands', inline=True)
embed.add_field(name='`>help music`', value=':musical_note: Music Commands', inline=True)
embed.add_field(name='`>help text`', value=':regional_indicator_t: Text Manipulation Commands',
inline=True)
embed.add_field(name='`>help util`', value=':fork_and_knife: Utility Commands', inline=True)
embed.add_field(name='`>help weather`', value=':cloud_tornado: Weather Commands', inline=True)
await ctx.send(embed=embed)
elif arg == 'fun':
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
embed = discord.Embed(color=discord.Colour.from_rgb(r, g, b))
embed.set_author(name='Fun Commands')
embed.add_field(name='`>8ball (question)`', value=':8ball: Predictions', inline=True)
embed.add_field(name='`>animal (animal)`',
value=':dog: Animal images (Dog, Cat, Panda, Red Panda, Birb, Fox, Koala, Kngaroo, Racoon)',
inline=True)
embed.add_field(name='`>anime (anime)`', value=':tv: Anime Info', inline=True)
embed.set_thumbnail(
url='https://cdn.discordapp.com/attachments/706665974484566138/717442170214154320/1200px-Fist.svg.webp')
# embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/706338290693046283/707085433552764968/RandyLogo.png')
embed.add_field(name='`>avatar (user)`', value=':clown: Avatar', inline=True)
embed.add_field(name='`>chat`', value=":speech_balloon: Chat with the bot, 'stop' to stop", inline=True)
embed.add_field(name='`>dice`', value=':1234: Roll dice', inline=True)
embed.add_field(name='`>fact (animal)`',
value=':paperclip: Animal facts (Dog, Cat, Panda, Bird, Koala, Racoon, Kangaroo, Elephant, Giraffe, Whale)',
inline=True)
embed.add_field(name='`>flip`', value=':first_place: Flip coin', inline=True)
embed.add_field(name='`>gif (gif)`', value=':gift: GIFs', inline=True)
embed.add_field(name='`>img (image)`', value=':flag_im: Google Image Search', inline=True)
embed.add_field(name='`>userinfo (user)`', value=':frame_photo: User Info', inline=True)
embed.add_field(name='`>joke`', value=':black_joker: Joke', inline=True)
embed.add_field(name='`>meme`', value=':stuck_out_tongue_winking_eye: Sends a meme', inline=True)
embed.add_field(name='`>pokemon (pokemon)`', value=':lion_face: Pokemon Info', inline=True)
# embed.add_field(name='`>trivia`', value=':smirk: Trivia!', inline=True)
embed.add_field(name='`>xkcd`', value=':bookmark_tabs: Comics!', inline=True)
embed.add_field(name='`>yt (name)`', value=':paperclips: Youtube Search', inline=True)
await ctx.send(embed=embed)
elif arg == 'image' or arg == 'img':
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
embed = discord.Embed(color=discord.Colour.from_rgb(r, g, b))
embed.set_author(name='Image Fun Commands')
embed.add_field(name='`>blur (user)`', value=':blush: Blurred image of a user', inline=True)
embed.add_field(name='`>blurple (user)`', value=':purple_circle: Blurple tinted image of a user',
inline=True)
embed.set_thumbnail(
url='https://cdn.discordapp.com/attachments/706665974484566138/717442170214154320/1200px-Fist.svg.webp')
# embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/706338290693046283/707085433552764968/RandyLogo.png')
embed.add_field(name='`>glass (user)`', value=':wine_glass: Image of a user behind a glass',
inline=True)
embed.add_field(name='`>invert (user)`', value=':blue_circle: Tinted image of a user', inline=True)
embed.add_field(name='`>pixelate (user)`', value=':smiley_cat: Pixelated image of a user', inline=True)
embed.add_field(name='`>sepia (user)`', value=':yellow_circle: Yellowish tinted image of a user',
inline=True)
embed.add_field(name='`>spin (user)`', value=':carousel_horse: Spinning gif of a user', inline=True)
embed.add_field(name='`>triggered (user)`',
value=":triangular_flag_on_post: User's image with the triggered tag", inline=True)
embed.add_field(name='`>wasted (user)`', value=":wastebasket: Wasted tag on a user's image",
inline=True)
embed.add_field(name='`>pat (user)`', value=":man_gesturing_ok:Pat another user",
inline=True)
embed.add_field(name='`>wink (user)`', value=":wink:Wink at another user",
inline=True)
embed.add_field(name='`>hug (user)`', value=":hugging:Hug another user",
inline=True)
await ctx.send(embed=embed)
elif arg == 'info':
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
embed = discord.Embed(color=discord.Colour.from_rgb(r, g, b))
embed.set_author(name='General Information Commands')
embed.add_field(name='`>covid (place)`', value=':mask: Covid-19 Related info', inline=True)
embed.add_field(name='`>github user (username)`', value=':ghost: User Info', inline=True)
embed.add_field(name='`>github repo (repository)`', value=':file_folder: Repository Info', inline=True)
embed.add_field(name='`>news (topic)`', value=':newspaper: News', inline=True)
embed.add_field(name='`>NYT`', value=':newspaper2: News from NYT', inline=True)
embed.set_thumbnail(
url='https://cdn.discordapp.com/attachments/706665974484566138/717442170214154320/1200px-Fist.svg.webp')
# embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/706338290693046283/707085433552764968/RandyLogo.png')
embed.add_field(name='`>wiki (noun)`', value=':bookmark: Wikipedia', inline=True)
await ctx.send(embed=embed)
elif arg == 'language' or arg == 'lang':
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
embed = discord.Embed(color=discord.Colour.from_rgb(r, g, b))
embed.set_author(name='Language Commands')
# embed.add_field(name='`>ant (word)`', value=':bookmark_tabs: Antonym', inline=True)
embed.add_field(name='`>define (word)`', value=':notebook_with_decorative_cover: Dictionary',
inline=True)
embed.add_field(name='`>quote`', value=':orange_book: Quote', inline=True)
embed.set_thumbnail(
url='https://cdn.discordapp.com/attachments/706665974484566138/717442170214154320/1200px-Fist.svg.webp')
# embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/706338290693046283/707085433552764968/RandyLogo.png')
# embed.add_field(name='`>syn (word)`', value=':bookmark_tabs: Synonym', inline=True)
embed.add_field(name='`>translate (src) (dest) (word)`', value=':earth_americas: Translate',
inline=True)
embed.add_field(name='`>trans (src) (dest) (time-mins)`',
value=':earth_africa: Translate for specified number of minutes', inline=True)
embed.add_field(name='`>urban (word)`', value=':closed_book: Urban Dictionary', inline=True)
embed.add_field(name='`>wordoftheday`', value=':blue_book: Word of the day', inline=True)
await ctx.send(embed=embed)
elif arg == 'math':
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
embed = discord.Embed(color=discord.Colour.from_rgb(r, g, b))
embed.set_author(name='Maths Commands')
embed.add_field(name='`>add`', value=':heavy_plus_sign: Add numbers', inline=True)
embed.add_field(name='`>sub`', value=':heavy_minus_sign: Subtract numbers', inline=True)