async def gddaily(self, ctx): toEdit = await ctx.send( str(self.client.get_emoji(BotEmotes.loading)) + " | Retrieving Data...") if 'daily' in ctx.message.content: name = 'daily' else: name = 'weekly' data = myself.api("https://gdbrowser.com/api/level/" + name) image = 'https://gdbrowser.com/icon/' + data["author"] embed = discord.Embed(title=data["name"] + ' (' + str(data["id"]) + ')', description=data["description"], colour=discord.Colour.from_rgb(201, 160, 112)) embed.set_author(name=data["author"], icon_url=image) embed.add_field(name='Uploaded at', value=data["uploaded"], inline='True') embed.add_field(name='Updated at', value=data["updated"] + " (Version " + data["version"] + ")", inline='True') embed.add_field(name='Difficulty', value=data["difficulty"]) gesture = ':+1:' if data['disliked']: gesture = ':-1:' embed.add_field(name='Level Stats', value=str(data["likes"]) + ' ' + gesture + '\n' + str(data["downloads"]) + " :arrow_down:", inline='False') embed.add_field(name='Level Rewards', value=str(data["stars"]) + " :star:\n" + str(data["orbs"]) + " orbs\n" + str(data["diamonds"]) + " :gem:") await toEdit.edit(content='', embed=embed)
async def rhyme(self, ctx, *args): if len(list(args)) == 0: await message.channel.send( 'Please input a word! And we will try to find the word that best rhymes with it.' ) else: wait, words = await ctx.send( str(self.client.get_emoji(BotEmotes.loading)) + ' | Please wait... Searching...'), [] data = myself.api( 'https://rhymebrain.com/talk?function=getRhymes&word=' + str(myself.urlify(' '.join(list(args))))) if len(data) < 1: await wait.edit( content= 'We did not find any rhyming words corresponding to that letter.' ) else: for i in range(0, len(data)): if data[i]['flags'] == 'bc': words.append(data[i]['word']) words = myself.dearray(words) if len(words) > 1950: words = myself.limitify(words) embed = discord.Embed(title='Words that rhymes with ' + str(' '.join(list(args))) + ':', description=words, colour=discord.Colour.from_rgb( 201, 160, 112)) await wait.edit(content='', embed=embed)
async def gdsearch(self, ctx, *args): if len(list(args)) == 0: await ctx.send( str(self.client.get_emoji(BotEmotes.error)) + ' | Please input a query!') else: try: query = myself.urlify(' '.join(list(args))) data = myself.api('https://gdbrowser.com/api/search/' + str(query)) levels, count = '', 0 for i in range(0, len(data)): if data[count]['disliked']: like = ':-1:' else: like = ':+1:' levels += str( count + 1) + '. **' + data[count]['name'] + '** by ' + data[ count]['author'] + ' (`' + data[count][ 'id'] + '`)\n:arrow_down: ' + data[count][ 'downloads'] + ' | ' + like + ' ' + data[ count]['likes'] + '\n' count += 1 embedy = discord.Embed( title='Geometry Dash Level searches for "' + str(' '.join(list(args))) + '":', description=levels, colour=discord.Colour.from_rgb(201, 160, 112)) await ctx.send(embed=embedy) except: await ctx.send( str(self.client.get_emoji(BotEmotes.error)) + ' | Error: Not Found. :four::zero::four:')
async def ghiblifilms(self, ctx, *args): wait = await ctx.send(str(self.client.get_emoji(BotEmotes.loading)) + ' | Please wait... Getting data...') data = myself.api('https://ghibliapi.herokuapp.com/films') if len(list(args))==0: films = "" for i in range(0, int(len(data))): films = films+'('+str(int(i)+1)+') '+str(data[i]['title']+' ('+str(data[i]['release_date'])+')\n') embed = discord.Embed( title = 'List of Ghibli Films', description = str(films), color = discord.Colour.from_rgb(201, 160, 112) ) embed.set_footer(text='Type `'+str(Config.prefix)+'ghibli <number>` to get each movie info.') await wait.edit(content='', embed=embed) else: try: num = int([i for i in list(args) if i.isnumeric()][0])-1 embed = discord.Embed( title = data[num]['title'] + ' ('+str(data[num]['release_date'])+')', description = '**Rotten Tomatoes Rating: '+str(data[num]['rt_score'])+'%**\n'+data[num]['description'], color = discord.Colour.from_rgb(201, 160, 112) ) embed.add_field(name='Directed by', value=data[num]['director'], inline='True') embed.add_field(name='Produced by', value=data[num]['producer'], inline='True') await wait.edit(content='', embed=embed) except: await wait.edit(content=str(self.client.get_emoji(BotEmotes.error))+' | the movie you requested does not exist!?')
async def geoquiz(self, ctx): wait = await ctx.send( str(self.client.get_emoji(BotEmotes.loading)) + ' | Please wait... generating question...') data, topic = myself.api( "https://restcountries.eu/rest/v2/"), random.choice( src.getGeoQuiz()) chosen_nation_num = random.randint(0, len(data)) chosen_nation, wrongs = data[chosen_nation_num], [] data.remove(data[chosen_nation_num]) correct = str(chosen_nation[topic]) for i in range(0, 4): integer = random.randint(0, len(data)) wrongs.append(str(data[integer][str(topic)])) data.remove(data[integer]) emot, static_emot, corr_order_num = list('🇦🇧🇨🇩'), list( '🇦🇧🇨🇩'), random.randint(0, 3) corr_order = emot[corr_order_num] emot[corr_order_num], question, guy = '0', '', ctx.message.author for emote in emot: if emote != '0': added = random.choice(wrongs) question += emote + ' ' + added + '\n' wrongs.remove(added) else: question += corr_order + ' ' + correct + '\n' embed = discord.Embed( title='Geography: ' + str(topic) + ' quiz!', description= ':nerd: Click on the reaction! **You have 20 seconds.**\n\nWhich ' + str(topic) + ' belongs to ' + str(chosen_nation['name']) + '?\n' + str(question), colour=discord.Colour.from_rgb(201, 160, 112)) await wait.edit(content='', embed=embed) for i in range(0, len(static_emot)): await wait.add_reaction(static_emot[i]) def check(reaction, user): return user == guy try: reaction, user = await self.client.wait_for('reaction_add', timeout=20.0, check=check) except asyncio.TimeoutError: await main.add_reaction('😔') if str(reaction.emoji) == str(corr_order): await ctx.send( str(self.client.get_emoji(BotEmotes.success)) + ' | <@' + str(guy.id) + '>, Congrats! You are correct. :partying_face:') if Economy.get(ctx.message.author.id) != None: reward = random.randint(5, 150) Economy.addbal(ctx.message.author.id, reward) await ctx.send('thanks for playing! You obtained ' + str(reward) + ' diamonds in total!') else: await ctx.send( str(self.client.get_emoji(BotEmotes.error)) + ' | <@' + str(guy.id) + '>, You are incorrect. The answer is ' + str(corr_order) + '.')
async def joke(self, ctx): data = myself.api( "https://official-joke-api.appspot.com/jokes/general/random") embed = discord.Embed(title=str(data[0]["setup"]), description='||' + str(data[0]["punchline"]) + '||', colour=discord.Colour.from_rgb(201, 160, 112)) await ctx.send(embed=embed)
async def meme(self, ctx): data = myself.api("https://meme-api.herokuapp.com/gimme") embed = discord.Embed(colour = discord.Colour.from_rgb(201, 160, 112)) embed.set_author(name=data["title"], url=data["postLink"]) if data["nsfw"]: embed.set_footer(text='WARNING: IMAGE IS NSFW.') else: embed.set_image(url=data["url"]) await ctx.send(embed=embed)
async def ufo(self, ctx): num = str(random.randint(50, 100)) data = myself.api('http://ufo-api.herokuapp.com/api/sightings/search?limit='+num) if data['status']!='OK': await ctx.send(str(self.client.get_emoji(BotEmotes.error))+' | There was a problem on retrieving the info.\nThe server said: "'+str(data['status'])+'" :eyes:') else: ufo = random.choice(data['sightings']) embed = discord.Embed(title='UFO Sighting in '+str(ufo['city'])+', '+str(ufo['state']), description='**Summary:** '+str(ufo['summary'])+'\n\n**Shape:** '+str(ufo['shape'])+'\n**Sighting Date: **'+str(ufo['date'])[:-8].replace('T', ' ')+'\n**Duration: **'+str(ufo['duration'])+'\n\n[Article Source]('+str(ufo['url'])+')', colour=discord.Colour.from_rgb(201, 160, 112)) embed.set_footer(text='Username601 raided area 51 and found this!') await ctx.send(embed=embed)
async def _8ball(self, ctx): async with ctx.message.channel.typing(): data = myself.api("https://yesno.wtf/api") if data["image"].endswith('.gif'): img, filename = Painter.gif.giffromURL(data["image"], True), 'answer.gif' else: img, filename = Painter.urltoimage(data["image"]), 'answer.png' await ctx.send(content=data['answer'], file=discord.File(img, filename))
async def trivia(self, ctx): al = None try: wait = await ctx.send( str(self.client.get_emoji(BotEmotes.loading)) + ' | Please wait... generating quiz...') auth = ctx.message.author data = myself.api( 'https://wiki-quiz.herokuapp.com/v1/quiz?topics=Science') q = random.choice(data['quiz']) choices = '' for i in range(0, len(q['options'])): al = list('🇦🇧🇨🇩') if q['answer'] == q['options'][i]: corr = al[i] choices = choices + al[i] + ' ' + q['options'][i] + '\n' embed = discord.Embed( title='Trivia!', description='**' + q['question'] + '**\n' + choices, colour=discord.Colour.from_rgb(201, 160, 112)) embed.set_footer( text='Answer by clicking the reaction! You have 60 seconds.') await wait.edit(content='', embed=embed) for i in range(0, len(al)): await wait.add_reaction(al[i]) except Exception as e: await wait.edit( content=str(self.client.get_emoji(BotEmotes.error)) + f' | An error occurred!\nReport this using {prefix}feedback.\n```{e}```' ) guy = ctx.message.author def check(reaction, user): return user == guy try: reaction, user = await self.client.wait_for('reaction_add', timeout=60.0, check=check) except asyncio.TimeoutError: await wait.add_reaction('😔') if str(reaction.emoji) == str(corr): await ctx.send( str(self.client.get_emoji(BotEmotes.success)) + ' | <@' + str(guy.id) + '>, Congrats! You are correct. :partying_face:') if Economy.get(ctx.author.id) != None: reward = random.randint(250, 400) Economy.addbal(ctx.message.author.id, reward) await ctx.send('thanks for playing! You get also a ' + str(reward) + ' diamonds as a prize!') else: await ctx.send( str(self.client.get_emoji(BotEmotes.error)) + ' | <@' + str(guy.id) + '>, You are incorrect. The answer is ' + str(corr) + '.')
async def country(self, ctx, *args): country = myself.urlify(' '.join(list(args))) c = myself.api("https://restcountries.eu/rest/v2/name/"+str(country.lower())) if len(c[0]['borders'])==0: borderz = 'No borders.' else: borderz = myself.dearray(c[0]['borders']) embed = discord.Embed( title = c[0]['nativeName'], description = '**Capital:** '+str(c[0]['capital'])+'\n**Region: **'+str(c[0]['region'])+'\n**Sub Region: **'+str(c[0]['subregion'])+"\n**Population: **"+str(c[0]['population'])+"\n**Area: **"+str(c[0]['area'])+' km²\n**Time Zones:** '+str(myself.dearray(c[0]['timezones']))+'\n**Borders: **'+str(borderz), colour = discord.Colour.from_rgb(201, 160, 112) ) embed.set_author(name=c[0]['name']) await ctx.send(embed=embed)
async def time(self, ctx): data = myself.api("http://worldtimeapi.org/api/timezone/africa/accra") year, time, date = str(data["utc_datetime"])[:-28], str(data["utc_datetime"])[:-22], str(str(data["utc_datetime"])[:-13])[11:] if int(year)%4==0: yearType, yearLength = 'It is a leap year.', 366 else: yearType, yearLength = 'It is not a leap year yet.', 365 progressDayYear = round(int(data["day_of_year"])/int(yearLength)*100) progressDayWeek = round(int(data["day_of_week"])/7*100) embed = discord.Embed( title = str(date)+' | '+str(time)+' (API)', description = str(t.now())[:-7]+' (SYSTEM)\nBoth time above is on UTC.\n**Unix Time:** '+str(data["unixtime"])+'\n**Day of the year: **'+str(data["day_of_year"])+' ('+str(progressDayYear)+'%)\n**Day of the week: **'+str(data["day_of_week"])+' ('+str(progressDayWeek)+'%)\n'+str(yearType), colour = discord.Colour.from_rgb(201, 160, 112) ) await ctx.send(embed=embed)
async def typingtest(self, ctx): async with ctx.message.channel.typing(): data = myself.api( "https://random-word-api.herokuapp.com/word?number=5") text, guy, first = myself.arrspace( data), ctx.message.author, t.now() main = await ctx.send( content= '**Type the text on the image.**\nYou have 2 minutes.\n', file=discord.File(Painter.simpletext(text), 'test.png')) def check(m): return m.author == guy try: trying = await self.client.wait_for('message', check=check, timeout=120.0) except: await main.edit(content='Time is up.') if str(trying.content) != None: offset = t.now() - first asked, answered, wrong = text.lower(), str( trying.content).lower(), 0 if len(str(trying.content)) != len(text): while len(answered) != len(asked): if len(answered) > len(asked): asked += ' ' else: answered += ' ' for i in range(0, len(asked)): if answered[i] != asked[i]: wrong += 1 accuracy, err = round((len(text) - wrong) / len(text) * 100), False try: sec = offset.seconds except AttributeError: err = True if not err: wpm = round(len(str(trying.content)) / round(sec)) else: wpm = '`Error while calculating CPS. Maybe you are typing too fast.`' await ctx.send(embed=discord.Embed( title='TYPING TEST RESULTS', description='**Your time: **' + str(offset)[:-7] + '\n**Your accuracy: **' + str(accuracy) + '%\n**Your speed: **' + str(wpm) + ' cps (characters per second).', colour=discord.Colour.from_rgb(201, 160, 112)))
async def typingtest(self, ctx): async with ctx.message.channel.typing(): data = myself.api("https://random-word-api.herokuapp.com/word?number=5") text, guy, first = myself.arrspace(data), ctx.message.author, t.now().timestamp() main = await ctx.send(content='**Type the text on the image. (Only command invoker can play)**\nYou have 2 minutes.\n', file=discord.File(self.canvas.simpletext(text), 'test.png')) def check(m): return m.author == guy try: trying = await self.client.wait_for('message', check=check, timeout=120.0) except: await main.edit(content='Time is up.') if str(trying.content)!=None: offset = t.now().timestamp()-first asked, answered, wrong = text.lower(), str(trying.content).lower(), 0 for i in range(len(asked)): try: if asked[i]!=answered[i]: wrong += 1 except: break accuracy, cps = round((len(asked)-wrong)/offset*100) await ctx.send(embed=discord.Embed(title='TYPING TEST RESULTS', description='**Your time: **'+str(round(offset))+' seconds.\n**Your accuracy: **'+str(accuracy)+'%\n**Your speed: **'+str(cps)+' Characters per second.', colour=discord.Colour.from_rgb(201, 160, 112)))
async def gdlevel(self, ctx, *args): if len(list(args)) == 0: await ctx.send( str(self.client.get_emoji(BotEmotes.error)) + ' | Please enter a level ID!') else: if not args[0].isnumeric(): await ctx.send( str(self.client.get_emoji(BotEmotes.error)) + ' | That is not a level ID!') else: try: levelid = str(args[0]) toEdit = await ctx.send( str(self.client.get_emoji(BotEmotes.loading)) + " | Retrieving Data...") data = myself.api("https://gdbrowser.com/api/level/" + str(levelid)) image = 'https://gdbrowser.com/icon/' + data["author"] embed = discord.Embed( title=data["name"] + ' (' + str(data["id"]) + ')', description=data["description"], colour=discord.Colour.from_rgb(201, 160, 112)) embed.set_author(name=data["author"], icon_url=image) embed.add_field(name='Difficulty', value=data["difficulty"]) gesture = ':+1:' if data['disliked']: gesture = ':-1:' embed.add_field(name='Level Stats', value=str(data["likes"]) + ' ' + gesture + '\n' + str(data["downloads"]) + " :arrow_down:", inline='False') embed.add_field(name='Level Rewards', value=str(data["stars"]) + " :star:\n" + str(data["orbs"]) + " orbs\n" + str(data["diamonds"]) + " :gem:") await toEdit.edit(content='', embed=embed) except Exception as e: await toEdit.edit(content=f'```{e}```')
async def gdprofile(self, ctx, *args): if len(list(args)) == 0: await ctx.send( str(self.client.get_emoji(BotEmotes.error)) + ' | Gimme some ARGS!') else: try: url = myself.urlify(str(' '.join(list(args)))) data = myself.api("https://gdbrowser.com/api/profile/" + url) embed = discord.Embed(title=data["username"], description='Displays user data for ' + data["username"] + '.', colour=discord.Colour.orange()) if data["rank"] == "0": rank = "Not yet defined :(" else: rank = str(data["rank"]) if data["cp"] == "0": cp = "This user don't have Creator Points :(" else: cp = data["cp"] embed.add_field(name='ID Stuff', value='Player ID: ' + str(data["playerID"]) + '\nAccount ID: ' + str(data["accountID"]), inline='True') embed.add_field(name='Rank', value=rank, inline='True') embed.add_field(name='Stats', value=str(data["stars"]) + " Stars" + "\n" + str(data["diamonds"]) + " Diamonds\n" + str(data["coins"]) + " Secret Coins\n" + str(data["userCoins"]) + " User Coins\n" + str(data["demons"]) + " Demons beaten", inline='False') embed.add_field(name='Creator Points', value=cp) embed.set_author(name='Display User Information', icon_url="https://gdbrowser.com/icon/" + url) await ctx.send(embed=embed) except: await ctx.send( str(self.client.get_emoji(BotEmotes.error)) + ' | Error, user not found.')
async def bored(self, ctx): data = myself.api("https://www.boredapi.com/api/activity?participants=1") await ctx.send('**Feeling bored?**\nWhy don\'t you '+str(data['activity'])+'? :wink::ok_hand:')
async def hangman(self, ctx): wait = await ctx.send( str(self.client.get_emoji(BotEmotes.loading)) + ' | Please wait... generating...') the_word = myself.api( "https://random-word-api.herokuapp.com/word?number=1") main_guess_cor, main_guess_hid = list(the_word[0]), [] server_id, wrong_guesses = ctx.message.guild.id, '' for i in range(0, len(main_guess_cor)): main_guess_hid.append('\_ ') guessed, gameplay, playing_with, playing_with_id, level = [], True, ctx.message.author, int( ctx.message.author.id), 0 while gameplay: if ctx.message.content == Config.prefix + 'hangman' and ctx.message.author.id != int( playing_with_id) and ctx.message.guild.id == server_id: await ctx.send( '<@' + str(ctx.message.author.id) + '>, cannot play hangman when a game is currently playing!') newembed = discord.Embed( title=''.join(main_guess_hid), description='Wrong guesses: ' + str(wrong_guesses), colour=discord.Colour.from_rgb(201, 160, 112)) newembed.set_image( url= f'https://raw.githubusercontent.com/vierofernando/username601/master/assets/pics/hangman_{str(level)}.png' ) newembed.set_footer( text='Type "showanswer" to show the answer and end the game.') await ctx.send(embed=newembed) if '\_ ' not in ''.join(main_guess_hid): await ctx.send( f'Congratulations! <@{str(playing_with_id)}> win! :tada:\nThe answer is "' + str(''.join(main_guess_cor)) + '".') if Economy.get(ctx.message.author.id) != None: reward = random.randint(5, 500) Economy.addbal(ctx.message.author.id, reward) await ctx.send('thanks for playing! you get an extra ' + str(reward) + ' diamonds!') gameplay = False break if level > 7: await ctx.send( f'<@{str(playing_with_id)}> lost! :(\nThe answer is actually "' + str(''.join(main_guess_cor)) + '".') gameplay = False break def is_not_stranger(m): return m.author == playing_with try: trying = await self.client.wait_for('message', check=is_not_stranger, timeout=20.0) except asyncio.TimeoutError: await ctx.send( f'<@{str(playing_with_id)}> did not response in 20 seconds so i ended the game. Keep un-AFK!\nOh and btw, the answer is ' + str(''.join(main_guess_cor)) + '. :smirk:') gameplay = False break if str(trying.content).lower() == 'showanswer': await ctx.send('The answer is actually ' + str(''.join(main_guess_cor) + '.')) gameplay = False break elif len(str(trying.content)) > 1: await ctx.send('One word at a time. Game ended!') gameplay = False break elif str(trying.content).lower() in guessed: await ctx.send( f'<@{str(playing_with_id)}>, You have guessed that letter!' ) level = int(level) + 1 elif str( trying.content).lower() in ''.join(main_guess_cor).lower(): guessed.append(str(trying.content).lower()) for i in range(0, len(main_guess_cor)): if main_guess_cor[i].lower() == str( trying.content).lower(): main_guess_hid[i] = str(trying.content).lower() else: level = int(level) + 1 wrong_guesses = wrong_guesses + str( trying.content).lower() + ', '