-
Notifications
You must be signed in to change notification settings - Fork 2
/
discord bot.py
650 lines (565 loc) · 25.9 KB
/
discord bot.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
import discord
from discord.ext import commands,tasks
from discord.utils import get
from googlesearch import search
from dotenv import load_dotenv
import os
import asyncio
import youtube_dl
from youtubesearchpython import SearchVideos
from youtube_transcript_api import YouTubeTranscriptApi
import spotipy
from spotipy.oauth2 import SpotifyClientCredentials
import random
import sports
from pycricbuzz import Cricbuzz
import ratings
from datetime import datetime
bot = commands.Bot(command_prefix = '.')
@bot.event
async def on_ready():
print(f"{bot.user} has connected to discord...\n")
@bot.event
async def on_command_error(ctx , error):
await ctx.send(f'abe mandbuddhi {ctx.message.author.mention}')
await ctx.send(error)
load_dotenv()
servers = (os.getenv('server1'),os.getenv('server2'),os.getenv('server3'),os.getenv('server4'),os.getenv('server5'),os.getenv('server6'),os.getenv('server7'))
song_list = dict.fromkeys(servers,[])
Pause_list = dict.fromkeys(servers, False)
current_list = dict.fromkeys(servers,[])
@bot.command(aliases=['seru'])
async def join(ctx):
global song_list
global Pause_list
song_list[ctx.guild.id] = []
Pause_list[ctx.guild.id] = False
if ctx.guild.voice_client in bot.voice_clients:
await ctx.send('abbe hum tumhare baap he, tumhare kehne se pehle aa gaye')
return
try:
await ctx.message.author.voice.channel.connect()
await ctx.send('swagat to karo humara')
except:
await ctx.send('abbe mandbuddhi, VC to join karo')
@bot.command(aliases=['kalikukka','p'])
async def play(ctx,*args):
if ctx.message.author.voice!=None and (ctx.guild.voice_client in bot.voice_clients):
global song_list
global Pause_list
songa = ' '.join(args)
if 'https://open.spotify.com/' in songa:
songa = spotify_queue(ctx,songa)
else:
song_list[ctx.guild.id].append(songa)
if len(song_list[ctx.guild.id])!=1 or ctx.message.guild.voice_client.is_playing()==True or Pause_list[ctx.guild.id]==True:
await ctx.send(f'**`{songa}` ko line me lagwa diye he**')
if ctx.message.guild.voice_client.is_playing()==False and Pause_list[ctx.guild.id]==False:
download(ctx,ctx.message.guild.voice_client,ctx.guild.id)
else:
await ctx.send('abbe mandbuddhi, VC to join karo')
def download(ctx,voice_client,server_id):
asyncio.run_coroutine_threadsafe(playing_song(ctx,voice_client,server_id),bot.loop)
pass
async def playing_song(ctx,voice_client,server_id):
global song_list
radio = {'HiFM':os.getenv('HiFM'),
'Merge':os.getenv('Merge'),
'Virgin':os.getenv('Virgin') }
try:
song = song_list[server_id].pop(0)
except:
return
print('return not executed')
if song in radio.keys():
voice_client.play(discord.FFmpegPCMAudio(radio[song]),after =lambda e: download(ctx,voice_client,server_id))
await ctx.send(f'Now Playing : {song} Radio')
return
results = SearchVideos(song,offset=1,mode='dict',max_results=1)
x = results.result()
for I in x['search_result']:
ytdl_format_options = {
'format' : 'bestaudio/best' ,
'postprocessors' : [{
'key' : 'FFmpegExtractAudio' ,
'preferredcodec' : 'mp3' ,
'preferredquality' : '192' ,
}]
}
ytdl = youtube_dl.YoutubeDL(ytdl_format_options)
#ytdl.download([I['link']])
current_list[ctx.guild.id] = []
current_list[ctx.guild.id].append(I)
embed = discord.Embed(title=f"*ab suno\n`{I['title']}`\naur apna manorajan karo*", colour=discord.Colour.red())
embed.set_thumbnail(url = I['thumbnails'][0])
embed.add_field( name='Duration' , value = I['duration'])
await ctx.send(embed=embed)
if voice_client.is_playing()==False:
audio = ytdl.extract_info(I['link'],download = False)
streamable_url = audio['formats'][0]['url']
before_options = "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5"
voice_client.play(discord.FFmpegPCMAudio(streamable_url,before_options = before_options),after =lambda e: download(ctx,voice_client,server_id))
else:
return
def spotify_queue(ctx,link):
global song_list
sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials(client_id=os.getenv('Spotify_id'),client_secret=os.getenv('Spotify_secret')))
L = link.split('/')
if 'https://open.spotify.com/playlist/' in link:
tracks = sp.playlist_tracks(L.pop())
for I in tracks['tracks']["items"]:
song_list[ctx.guild.id].append(f"{I['track']['name']} lyrics")
return f"{tracks['tracks']['total']} gaane from spotify playlist"
elif 'https://open.spotify.com/track/' in link:
track = sp.track(L.pop())
song_list[ctx.guild.id].append(f"{track['name']} lyrics")
return track['name']
elif 'https://open.spotify.com/album/' in link:
album_id = L.pop().split('?')[0]
album = sp.album(album_id)
for track in album['tracks']['items']:
song_list[ctx.guild.id].append(f"{track['name']} lyrics")
return f"Spotify album {album['name']} se {album['total_tracks']} gaano"
@bot.command(aliases=['np'])
async def now_playing(ctx):
I = current_list[ctx.guild.id][0]
embed = discord.Embed(title=f"*NOW PLAYING\n`{I['title']}`*", colour=discord.Colour.red())
embed.set_thumbnail(url = I['thumbnails'][0])
embed.add_field( name='Duration' , value = I['duration'])
await ctx.send(embed=embed)
@bot.command(aliases=['line','q'])
async def queue(ctx):
global song_list
if ctx.message.author.voice!=None:
if song_list[ctx.guild.id] == []:
await ctx.send('jab koi line he hi nahi to kya dekho ge be')
return
for i,s in enumerate(song_list[ctx.guild.id]):
await ctx.send(f'*{i+1})*: **`{s}`**')
else:
await ctx.send('abbe mandbuddhi, VC to join karo')
@bot.command(aliases = ['hatt','r'])
async def remove(ctx,position : int):
global song_list
if ctx.message.author.voice!=None:
if song_list[ctx.guild.id] == []:
await ctx.send('jab koi line he hi nahi to kya hatao ge be')
return
try :
await ctx.send(f'kya yaar, `{song_list[ctx.guild.id][position-1]}` humse hi hatwana tha')
song_list[ctx.guild.id].pop(position-1)
except:
await ctx.send('ek minute... ye kya, tumhara to number hi line ke bahar he')
else:
await ctx.send('abbe mandbuddhi, VC to join karo')
@bot.command(aliases = ['niruthu'])
async def pause(ctx):
global Pause_list
if ctx.message.author.voice == None:
await ctx.send('abbe mandbuddhi, VC to join karo')
return
ctx.message.guild.voice_client.pause()
Pause_list[ctx.guild.id] = True
await ctx.send('kya yaar beech me rok kar poora maza kharab kar diye')
@bot.command(aliases = ['thodurum'])
async def resume(ctx):
global Pause_list
if ctx.message.author.voice == None:
await ctx.send('abbe mandbuddhi, VC to join karo')
return
ctx.message.guild.voice_client.resume()
Pause_list[ctx.guild.id] = False
await ctx.send('je hui na baat ab maze karo')
@bot.command(aliases = ['poda_patti','s'])
async def skip(ctx):
global Pause_list
if ctx.message.author.voice == None:
await ctx.send('abbe mandbuddhi, VC to join karo')
return
Pause_list[ctx.guild.id] = False
ctx.message.guild.voice_client.stop()
await ctx.send('kya yaar, itne badhiya gane ko hata diya')
@bot.command(aliases = ['poda','d'])
async def disconnect(ctx):
global Pause_list
global song_list
for x in bot.voice_clients:
if(x.guild == ctx.message.guild):
song_list[ctx.guild.id]=[]
Pause_list[ctx.guild.id] = False
current_list[ctx.guild.id]=[]
await ctx.send('phir milte he')
return await x.disconnect()
if bot.voice_clients==[]:
await ctx.send('abbe hum gaye hi kab jo tum humko nikaloge')
@bot.command()
async def kick(ctx, member : discord.Member):
await member.kick(reason = None)
await ctx.send(f'{member.mention} ko dhakke maar ke nikal diye he be')
@bot.command()
async def b(ctx , no : int):
if ctx.message.author.discriminator not in ['9431','2961','4777']:
await ctx.send('sorry sarr u r not qualified')
return
await ctx.message.channel.purge(limit=no)
@bot.command()
async def member_count(ctx):
await ctx.send(ctx.message.guild.member_count)
@bot.command()
async def all_members(ctx):
duplicate = []
for I in bot.get_all_members():
if ctx.guild == I.guild:
if I.name in duplicate:
continue
await ctx.send(I.name)
duplicate.append(I.name)
@bot.command()
async def change(ctx, member : discord.Member, *args):
new = ' '.join(args)
await member.edit(nick = new)
@bot.command()
async def avatar(ctx, user: discord.User = None):
if user==None:
user = ctx.message.author
await ctx.send(user.avatar_url_as())
@bot.command()
async def Q(ctx,*args):
question= ' '.join(args)
for j in search(question, tld="co.in", num=1, stop=1, pause=2):
await ctx.send(j)
@bot.command()
async def roast(ctx,arg):
roasts = {
'krishna': 'Smoking will kill you... meth will kill you... But, smoking meth will cure it.',
'vivek' : 'vivek got stuck in the shower because the instructions on the shampoo bottle said: Lather, Rinse, Repeat',
'ramanan' : 'What did the ramanan write on his Valentine card? You make me and my ice cream melt.',
'ramil' : 'why does ramil have white teeth ... because he loves to floss',
'harshal' : 'harshal has a new theory on inertia but it doesnt seem to go anywhere',
'rounak' : 'i am gorgeus and so am i a chirkut .... thats what she says',
'ayaan' : 'mere selmon bhoi ke bare me kya boli',
'nitishna' : 'my relationship with abi in NY was basically ''money heist'' ... IYKWIM',
'abishai':'absishais favourite tea .... penal-tea',
'jerin' : 'im a rider,provider,bring my bed now imma sleep right here',
'shane' : 'I will have a English Breakfast Tea with a pinch of sugar and a tinge of mint in it, you peasant worker',
'manav' : 'even my mom ignores me and only asks if u have any khakras left after i return from school',
'ujjwal' : 'naam he mera ujjwal babu aur me lollipop lagelu',
'vineet' : 'even mcdonalds had to shut down their farms coz you ate all their poultry'
}
await ctx.send(roasts.get(arg.lower(),"kiska naam diya hai <:abeysaale:731486907208433724>"),tts = True)
@bot.command()
async def proifucts(ctx):
hershel=['https://cdn.discordapp.com/emojis/742244405523513344.png?v=1',
'https://cdn.discordapp.com/emojis/735902946432254083.png?v=1',
'https://cdn.discordapp.com/emojis/727173056073564220.png?v=1']
await ctx.send('https://cdn.discordapp.com/emojis/736858611627851787.png?v=1')
await ctx.send('https://cdn.discordapp.com/emojis/736858136790564966.png?v=1')
await ctx.send(random.choice(hershel))
@bot.command()
async def SC(ctx):
sc = ['https://cdn.discordapp.com/emojis/726719083076255755.png?v=1',
'https://cdn.discordapp.com/emojis/727172647519125544.png?v=1',
'https://cdn.discordapp.com/emojis/750210732184043580.png?v=1',
'https://cdn.discordapp.com/emojis/760778635937841153.png?v=1']
await ctx.send(random.choice(sc))
@bot.command()
async def NizwaHC(ctx):
romir = ['https://cdn.discordapp.com/emojis/728912662083403847.png?v=1',
'https://cdn.discordapp.com/attachments/674567305291890701/760782607373303828/unknown.png']
await ctx.send(random.choice(romir))
@bot.command()
async def MuscatHC(ctx):
ramna=['https://cdn.discordapp.com/emojis/743124529471160401.png?v=1',
'https://cdn.discordapp.com/emojis/727881883987476490.png?v=1',
'https://cdn.discordapp.com/emojis/760779912587509771.png?v=1']
ronek=['https://cdn.discordapp.com/emojis/727889938674352169.png?v=1',
'https://cdn.discordapp.com/emojis/727890732190531644.png?v=1']
await ctx.send(random.choice(ramna))
await ctx.send(random.choice(ronek))
@bot.command()
async def meme(ctx):
memes = ['https://media.discordapp.net/attachments/674638164467515432/753290676351008928/4bpjdv.png?width=362&height=406',
'https://media.discordapp.net/attachments/674567305291890701/763840048151396374/momcanweabi.jpg?width=508&height=480',
'https://cdn.discordapp.com/attachments/674567305291890701/762948863513722890/SPOILER_Z.png',
'https://media.discordapp.net/attachments/674638164467515432/753290636093948084/Z.png?width=412&height=406',
'https://media.discordapp.net/attachments/674638164467515432/753290581677178920/20200820_093621.png?width=356&height=406',
'https://media.discordapp.net/attachments/674638164467515432/753290525259464844/SPOILER_bruh.png',
'https://media.discordapp.net/attachments/674638164467515432/753290466430025798/SPOILER_Z.png',
'https://media.discordapp.net/attachments/674638164467515432/753290416861872278/9k.png',
'https://media.discordapp.net/attachments/674638164467515432/753290299165507634/SPOILER_9k.png',
'https://media.discordapp.net/attachments/674638164467515432/753290251254104094/SPOILER_Z.png',
'https://media.discordapp.net/attachments/674638164467515432/753290178944172102/SPOILER_Z.png?width=817&height=406',
'https://media.discordapp.net/attachments/674638164467515432/753290066515853332/SPOILER_lmaoooo.png',
'https://images-ext-1.discordapp.net/external/b2bXXz8lOxAnfYAbXuVYRxGAEuGT984QVhkWu96H5OQ/%3Fwidth%3D313%26height%3D375/https/media.discordapp.net/attachments/674567305291890701/752818609994203186/SPOILER_MR_CHIRKU.png',
'https://media.discordapp.net/attachments/674638164467515432/753289976589975753/SPOILER_9k.png',
'https://media.discordapp.net/attachments/674567305291890701/760773029193318440/Z.png?width=400&height=251',
'https://media.discordapp.net/attachments/674567305291890701/760917676422856714/2.jpg?width=279&height=375',
'https://cdn.discordapp.com/attachments/674567305291890701/762946040894455808/4hhmhx.jpg']
await ctx.send(random.choice(memes))
@bot.command()
async def girlfriend(ctx, arg):
gfs = {
'salman' : 'https://akm-img-a-in.tosshub.com/indiatoday/images/story/201310/salman-kat-and-ash_story-size_660_100813113758.jpg'
}
await ctx.send(gfs.get(arg.lower(), "kiski girlfriend pooch rahe ho <:abeysaale:731486907208433724>"))
@bot.command()
async def pingu(ctx, member:discord.Member):
if member.discriminator == '4777':
await ctx.send('poda patti')
return
n=0
while n<6:
await ctx.send(member.mention)
n=n+1
@bot.command()
async def everyone(ctx):
L = [os.getenv('Vivek'),
os.getenv('Dannyboi'),
os.getenv('ValdyFox'),
os.getenv('FractalsAreBae'),
os.getenv('Silent_Killer'),
os.getenv('SKULL_TROOPER'),
os.getenv('jetso'),
os.getenv('yallaboi'),]
for I in L:
if I == ctx.message.author.id :
continue
await ctx.send(f'<@!{I}>')
@bot.command()
async def poll(ctx,*args):
embed = discord.Embed(title = f"POLLING\n{' '.join(args)}" , colour = discord.Colour.red())
embed.description = f"YES: 🇾 \n\nNO : 🇳 "
#embed.set_image(url = 'https://th.thgim.com/migration_catalog/article11163206.ece/alternates/FREE_435/modi%20symbol')
message = await ctx.send(embed = embed)
await message.add_reaction(emoji = '🇾')
await message.add_reaction(emoji = '🇳')
@bot.command()
async def ipl(ctx):
matches = sports.get_sport(sports.CRICKET)
for match in matches:
if match.league == 'IND-IPL':
if match.match_time == 'Match Finished':
await ctx.send('abe saale abhi to koi game nahi chal raha hai')
return
embed = discord.Embed(title='IPL 2020', colour=discord.Colour.gold())
embed.add_field(name=match.away_team , value=match.away_score , inline = False)
embed.add_field(name=match.home_team , value=match.home_score , inline = False)
await ctx.send(embed = embed)
return
@bot.command()
async def current_score(ctx):
match = Cricbuzz()
try:
details = match.livescore(match_id())
embed1 = discord.Embed(title=f"Current Batting Team : {details['batting']['team']}", colour=discord.Colour.red())
except:
await ctx.send('abe saale abhi to koi game nahi chal raha hai')
return
embed1.add_field(
name = f"Batsman Name : {details['batting']['batsman'][0]['name']}",
value = f"Runs Scored : {details['batting']['batsman'][0]['runs']}\n"
f"Balls Faced : {details['batting']['batsman'][0]['balls']}\n"
f"Fours Hit : {details['batting']['batsman'][0]['fours']}\n"
f"Sixes Hit : {details['batting']['batsman'][0]['six']}\n",
inline = False)
embed1.add_field(
name = f"Batsman Name : {details['batting']['batsman'][1]['name']}",
value = f"Runs Scored : {details['batting']['batsman'][1]['runs']}\n"
f"Balls Faced : {details['batting']['batsman'][1]['balls']}\n"
f"Fours Hit : {details['batting']['batsman'][1]['fours']}\n"
f"Sixes Hit : {details['batting']['batsman'][1]['six']}\n",
inline = False)
await ctx.send(embed = embed1)
embed2 = discord.Embed(title=f"Current Bowling Team : {details['bowling']['team']}", colour=discord.Colour.green())
embed2.add_field(
name = f"Bowler Name : {details['bowling']['bowler'][0]['name']}",
value = f"Overs Done : {details['bowling']['bowler'][0]['overs']}\n"
f"Runs Given : {details['bowling']['bowler'][0]['runs']}\n"
f"Wickets Taken : {details['bowling']['bowler'][0]['wickets']}",
inline = False)
await ctx.send(embed = embed2)
def match_id():
c = Cricbuzz()
matches = c.matches()
for I in matches:
if I['srs']=='Indian Premier League 2020' and (I['mchstate']=='toss' or I['mchstate']=='inprogress' or I['mchstate']=='innings break'):
return I['id']
@bot.command()
async def teams(ctx):
c = Cricbuzz()
try:
I = c.matchinfo(match_id())
except:
await ctx.send('abe saale abhi to koi game nahi chal raha hai')
return
embed1 = discord.Embed(title= I['team1']['name'], colour=discord.Colour.blue())
for X,J in enumerate(I['team1']['squad']):
embed1.add_field(name = J,value = f'{X+1}',inline = False)
embed2 = discord.Embed(title= I['team2']['name'], colour=discord.Colour.gold())
for X,J in enumerate(I['team2']['squad']):
embed2.add_field(name = J,value = f'{X+1}',inline = False)
await ctx.send(embed = embed1)
await ctx.send(embed = embed2)
@bot.command()
async def status(ctx):
c = Cricbuzz()
try:
I = c.matchinfo(match_id())
except:
await ctx.send('abe saale abhi to koi game nahi chal raha hai')
return
await ctx.send(I['status'])
@bot.command()
async def toss(ctx):
c = Cricbuzz()
try:
I = c.matchinfo(match_id())
except:
await ctx.send('abe saale abhi to koi game nahi chal raha hai')
return
await ctx.send(I['toss'])
@bot.command()
async def venue(ctx):
c = Cricbuzz()
try:
match = c.matchinfo(match_id())
except:
await ctx.send('abe saale abhi to koi game nahi chal raha hai')
return
match = c.matchinfo(match_id())
await ctx.send(match["venue_name"])
await ctx.send(match['venue_location'])
@bot.command()
async def score_card(ctx):
c = Cricbuzz()
try:
scorecard = c.scorecard(match_id())['scorecard'][0]
except:
await ctx.send('abe saale abhi to koi game nahi chal raha hai')
return
embed1 = discord.Embed(title = f"Batting Team : {scorecard['batteam']}" , colour=discord.Colour.blue())
embed1.description = f"Score {scorecard['runs']}/{scorecard['wickets']}, Overs {scorecard['overs']}"
for I in scorecard['batcard']:
embed1.add_field(
name=I['name'],
value=f"Runs{I['runs']}\n"
f"Balls Faced {I['balls']}\n"
f"Fours {I['fours']}\n"
f"Sixes {I['six']}\n"
f"{I['dismissal']}",
inline = False)
embed2 = discord.Embed(title = f"Bowling Team : {scorecard['bowlteam']}" , colour=discord.Colour.gold())
for I in scorecard['bowlcard']:
embed2.add_field(
name=I['name'],
value=f"Overs : {I['overs']}\n"
f"Maidens : {I['maidens']}\n"
f"Runs Given : {I['runs']}\n"
f"Wickets Taken : {I['wickets']}\n"
f"wides : {I['wides']}\n"
f"no balls : {I['nballs']}",
inline = False)
await ctx.send(embed = embed1)
await ctx.send(embed = embed2)
@bot.command()
async def prev_match(ctx):
c = Cricbuzz()
matches = c.matches()
for I in matches:
if I['srs']=='Indian Premier League 2020' and I['mchstate']=='mom':
embed = discord.Embed(title = f"{I['team1']['name']} vs {I['team2']['name']}" , colour = discord.Colour.blue())
embed.description = f"{I['status']}"
await ctx.send(embed = embed)
@bot.command()
async def next_match(ctx):
c = Cricbuzz()
matches = c.matches()
for I in matches:
if I['srs']=='Indian Premier League 2020' and I['mchstate']=='preview':
embed = discord.Embed(title = f"{I['team1']['name']} vs {I['team2']['name']}" , colour = discord.Colour.blue())
embed.description = f"{I['status']}"
await ctx.send(embed = embed)
@bot.command()
async def ipl_poll(ctx):
c = Cricbuzz()
matches = c.matches()
for I in matches:
if I['srs']=='Indian Premier League 2020' and (I['mchstate']=='inprogress' or I['mchstate']=='preview' or I['mchstate']=='toss'):
embed = discord.Embed(title = f"IPL POLLING\n{I['team1']['name']} vs {I['team2']['name']}" , colour = discord.Colour.blue())
embed.description = f"{I['team1']['name']} : 1️⃣\n\n{I['team2']['name']} : 2️⃣ "
message = await ctx.send(embed = embed)
await message.add_reaction(emoji = '1️⃣')
await message.add_reaction(emoji = '2️⃣')
old_message = ''
@bot.command(aliases = ['comm'])
async def start(ctx):
commentary.start(ctx)
@tasks.loop(seconds = 60)
async def commentary(ctx):
global old_message
c = Cricbuzz()
try:
com = c.commentary(match_id())['commentary']
except:
await ctx.send('commentary not found sarr')
old_message = ''
commentary.stop()
message = com[0]['comm']
if message == old_message:
return
message1 = message.replace('<b>',' ').replace('</b>',' ')
embed = discord.Embed(title = "COMMENTARY" , colour = discord.Colour.gold())
embed.description = f"{message1} "
if com[0]['over'] != None:
embed.add_field(name='Overs',value=f"{com[0]['over']}",inline = False)
await ctx.send(embed = embed)
old_message = message
@bot.command()
async def stop(ctx):
global old_message
commentary.stop()
old_message = ''
await ctx.send('chalo bacho commentary khallas, padhai karo')
@bot.command()
async def football(ctx,*args):
if args == ():
matches = sports.get_sport(sports.SOCCER)
embed = discord.Embed(title = 'LIVE MATCHES', colour=discord.Colour.blurple())
for I in matches:
embed.add_field( name = f'{I}', value = f'{I.league}')
await ctx.send(embed = embed)
return
try:
match = sports.get_match(sports.SOCCER, args[0], args[2])
except:
await ctx.send('abe shuru to hone do')
return
embed = discord.Embed(title = ' '.join(args).upper(), colour=discord.Colour.blurple())
embed.description = f'{match.league}'
embed.add_field( name = f'{match.away_team}', value = f'{match.away_score}')
embed.add_field( name = f'{match.home_team}' , value = f'{match.home_score}')
await ctx.send(embed = embed)
@bot.command()
async def rating(ctx,*args):
key = ratings.get_player(' '.join(args))
if key == None:
await ctx.send('sorry yaar player not found')
return
elif type(key)==int:
await ctx.send(f'https://media.contentapi.ea.com/content/dam/ea/fifa/fifa-21/ratings-collective/f20assets/player-shields/{key}.png')
else:
await ctx.send(key)
@bot.command()
async def ping(ctx):
await ctx.send(f'rukawat ki khed he\nping : {round(bot.latency,2)}')
@bot.command()
async def dhanyavaad(ctx):
if ctx.message.author.discriminator == '4777' :
await ctx.send('aate hai')
await ctx.bot.logout()
else :
await ctx.send('bhediyon me itna dam nahi ki sheron ko bhaga sake')
#user = get(bot.get_all_members(), id=123456789)
#await user.send("<@!123456789>")
token=os.getenv('token')
bot.run(token)