end of voting emlpemented

This commit is contained in:
ggodot 2025-02-12 16:16:04 +01:00
parent a2f2b6a055
commit c3df30c7bb

22
bot.py
View File

@ -131,38 +131,38 @@ async def funfact(ctx):
ran = randrange(len(jokes["funfacts"])) ran = randrange(len(jokes["funfacts"]))
msg = await ctx.send(f"Jednou jsem slyšela že: {jokes["funfacts"][ran]["txt"]}") try:
await ctx.respond(f"Jednou jsem slyšela že: {jokes["funfacts"][ran]["txt"]}")
except:
await ctx.send(f"Jednou jsem slyšela že: {jokes["funfacts"][ran]["txt"]}")
msg = await ctx.send(f"Co myslíš?")
jokes["funfacts"][ran]["visited"] =+ 1 jokes["funfacts"][ran]["visited"] =+ 1
love = "" love = ""
change = 0
await msg.add_reaction("\U0001F44D") await msg.add_reaction("\U0001F44D")
await msg.add_reaction("\U0001F44E") await msg.add_reaction("\U0001F44E")
await asyncio.sleep(60) await asyncio.sleep(300)
msg_cached = discord.utils.get(bot.cached_messages, id=msg.id) msg_cached = discord.utils.get(bot.cached_messages, id=msg.id)
for emo in msg_cached.reactions: for emo in msg_cached.reactions:
if emo.emoji == "👍": if emo.emoji == "👍":
jokes["funfacts"][ran]["upvotes"]+= emo.count - 1 jokes["funfacts"][ran]["upvotes"]+= emo.count - 1
change+= 1
elif emo.emoji == "👎": elif emo.emoji == "👎":
jokes["funfacts"][ran]["downvotes"]+= emo.count - 1 jokes["funfacts"][ran]["downvotes"]+= emo.count - 1
change+= 1
elif emo.emoji == "🫀": elif emo.emoji == "🫀":
love = ', já Vás mám taky ráda 🫀' love = ', já Vás mám taky ráda 🫀.'
if change != 0: await msg.edit(content=f"Děkuju za ohodnoceni. {love}")
await ctx.send(f"Děkuju za ohodnoceni. {jokes["funfacts"][ran]["upvotes"]} říká že dobrý a {jokes["funfacts"][ran]["downvotes"]} že ne{love}. ") await msg.remove_reaction("\U0001F44D", msg.author)
else: await msg.remove_reaction("\U0001F44E", msg.author)
await ctx.send(f"Hlasovaní skončilo. Můžete zkusit další {love}.")
with open("funfacts.json", "w") as f: with open("funfacts.json", "w") as f:
json.dump(jokes, f) json.dump(jokes, f)
return True return True
bot.run("MTMyNTk1Mzg4OTcyNzQxNDM0Mw.G2Tgo0.2OhbgaVYhys0BhxJMVgGDnG0W5qvxH-soJML3M") bot.run("MTMyNTk1Mzg4OTcyNzQxNDM0Mw.G2Tgo0.2OhbgaVYhys0BhxJMVgGDnG0W5qvxH-soJML3M")