diff --git a/Jan/dbtest command.py b/Jan/dbtest command.py new file mode 100644 index 0000000..5fa1ce3 --- /dev/null +++ b/Jan/dbtest command.py @@ -0,0 +1,65 @@ +from discord.ext import commands +import random + +class sf_user: + def __init__(self, id, username, dmchannel): + self.id = id + self.name = username + self.channel = dmchannel + self.question = 0 + self.category = 0 + self.semester = 0 + +bot = commands.Bot(command_prefix="!") +users = [] + +@bot.event +async def on_ready(): + print("we logged in as {0.user.name}".format(bot)) + return + +@bot.command() +async def start(ctx): + print("hello") + for i in users: + if i.name == ctx.author: + await ctx.send("User already in database") + return + users.append(sf_user(len(users), ctx.author, await ctx.author.create_dm())) + await users[-1].channel.send("Hello") + return + + +@bot.command() +async def question(ctx): + current_user = 0 + for i in users: + if i.channel == ctx.channel: + current_user = i + + if current_user == 0: + await ctx.send("User not in database") + return + + q_id = random.randint(0, 10) + users[current_user.id].question = q_id + await current_user.channel.send(q_id) + return + + +@bot.command() +async def answer(ctx): + current_user = 0 + for i in users: + if i.channel == ctx.channel: + current_user = i + + if current_user == 0: + await ctx.send("User not in database") + return + + await current_user.channel.send(current_user.question) + return + + +bot.run("Nzg1MTkxODM3OTg3MzczMDg2.X80Q4g.bK_vMhhESanMOA78KxHfmJft2vk") \ No newline at end of file diff --git a/Jan/userclass.txt b/Jan/userclass.txt deleted file mode 100644 index ae6055a..0000000 --- a/Jan/userclass.txt +++ /dev/null @@ -1,4 +0,0 @@ -name; name des nutzers -question; die aktuelle Frage -semester; einstellungen für semester (0 = random) -kategorie; einstellungen für kategorie (0 = random)