This commit is contained in:
adamercat 2020-12-14 13:12:57 +01:00 committed by Steinadler
parent 511dbaea0c
commit 9e3041b454
1 changed files with 14 additions and 2 deletions

View File

@ -42,9 +42,20 @@ async def question(ctx):
return
q_id = random.randint(0, 10)
question_str = get_question(q_id)[0]
users[current_user.id].question = q_id
await current_user.channel.send(q_id)
await current_user.channel.send(question_str)
return
def get_question(q_id):
all_lines = []
with open(../fragen_antworten.txt) as f: # The file is not in the same folder as the program file. Might not work, needs adjustment.
for line in f:
q_and_a = line.split(|) # Question_and_Answer
all_lines.append(q_and_a)
return all_lines([q_id][0],[q_id][1]) #[q_id][0] is the question, [q_id][1] is the answer
@bot.command()
@ -58,8 +69,9 @@ async def answer(ctx):
await ctx.send("User not in database")
return
answer = get_question(q_id)[1] # TO DO: return answer
await current_user.channel.send(current_user.question)
return
bot.run("Nzg1MTkxODM3OTg3MzczMDg2.X80Q4g.bK_vMhhESanMOA78KxHfmJft2vk")
bot.run("Nzg1MTkxODM3OTg3MzczMDg2.X80Q4g.bK_vMhhESanMOA78KxHfmJft2vk")