diff --git a/Jan/dbtest command.py b/Jan/dbtest command.py index 5fa1ce3..64d6012 100644 --- a/Jan/dbtest command.py +++ b/Jan/dbtest command.py @@ -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") \ No newline at end of file +bot.run("Nzg1MTkxODM3OTg3MzczMDg2.X80Q4g.bK_vMhhESanMOA78KxHfmJft2vk")