🧹 Cleaning up cogs

This commit is contained in:
NikolajDanger
2021-03-31 16:53:37 +02:00
parent 92fe7913f7
commit aff29a8d91
10 changed files with 166 additions and 126 deletions

View File

@ -1,6 +1,7 @@
import json
import urllib
import random
import asyncio
class Trivia():
def __init__(self, bot):
@ -83,3 +84,38 @@ class Trivia():
self.bot.log("Couldn't find the question (error code 1102)")
return None
async def triviaParse(self, ctx, answer):
try:
await ctx.defer()
except:
self.bot.log("defer failed")
if answer == "":
question, options, correctAnswer = self.triviaStart(str(ctx.channel_id))
if options != "":
results = "**"+question+"**\n"
for x, option in enumerate(options):
results += chr(x+97) + ") "+option+"\n"
await ctx.send(results)
await asyncio.sleep(60)
self.triviaCountPoints(str(ctx.channel_id))
self.bot.databaseFuncs.deleteGame("trivia questions",str(ctx.channel_id))
self.bot.log("Time's up for the trivia question",str(ctx.channel_id))
await ctx.send("Time's up The answer was \""+chr(correctAnswer)+") "+options[correctAnswer-97]+"\". Anyone who answered that has gotten 1 GwendoBuck")
else:
await ctx.send(question, hidden=True)
elif answer in ["a","b","c","d"]:
response = self.triviaAnswer("#"+str(ctx.author.id), str(ctx.channel_id), answer)
if response.startswith("Locked in "):
await ctx.send(f"{ctx.author.display_name} answered {answer})")
else:
await ctx.send(response)
else:
self.bot.log("I didn't understand that (error code 1101)",str(ctx.channel_id))
await ctx.send("I didn't understand that (error code 1101)")