Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def jsonisp(self, url):
- return requests.get(url).json()
- @commands.command()
- @commands.cooldown(1, 30, commands.BucketType.user)
- async def geoquiz(self, ctx):
- wait = await ctx.send(' | Porfavor espera... se te esta generando el test...')
- data, topic = self.jsonisp("https://restcountries.eu/rest/v2/"), random.choice(['capital', 'region', 'subregion', 'population', 'demonym', 'nativeName'])
- 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.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'
- trans = Translator()
- translated_topic = trans.translate(topic, src='en', dest='es')
- translated_nation = trans.translate(chosen_nation['name'], src='en', dest='es')
- translated_question = trans.translate(question, src='en', dest='es')
- translated_corr_order = trans.translate(corr_order, src='en', dest='es')
- embed = discord.Embed(title='Test de geografia: '+str(translated_topic.text), description=':nerd: Haz click en la reaccion! **Tienes 20 segundos.**\n\nQue '+str(translated_topic.text)+' pertenece a '+str(translated_nation.text)+'?\n\n'+str(translated_question.text), colour=color)
- 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.bot.wait_for('reaction_add', timeout=20.0, check=check)
- except asyncio.TimeoutError:
- await wait.add_reaction('😔')
- if str(reaction.emoji)==str(corr_order):
- await wait.edit(content='', embed=discord.Embed(title="¡Correcto!", description=' | <@'+str(guy.id)+'>, felizidades! Estas correcto. :partying_face:\n\nY se te han añadido diamantes a tu cuenta', colour=color))
- diamantes_dados = random.randint(10, 30)
- user = ctx.author
- with open("mainbank.json", "r") as f:
- users = json.load(f)
- users[str(user.id)]["wallet"] += diamantes_dados
- with open("mainbank.json", "w") as f:
- json.dump(users, f)
- else:
- await wait.edit(content='', embed=discord.Embed(title="¡Incorrecto!", description=' | <@'+str(guy.id)+f'>, Estas **incorrecto**. La respuesta era {translated_corr_order.text}', colour=color))
Add Comment
Please, Sign In to add comment