import os from discord.ext import commands from checkin_db import CheckinDB checkin_db = CheckinDB("checkin.db") bot = commands.Bot(command_prefix="!") @bot.command() async def checkin(context: commands.Context) -> None: print(f"{context.message.author.display_name} checked in") checkin_db.auto_checkout() checkin_db.update(context.message.author.display_name, True) count = checkin_db.get_checkin_count() if count == 1: await context.send(f"Aktuell {count} Mensch im Erfindergeist") else: await context.send(f"Aktuell {count} Menschen im Erfindergeist") @bot.command() async def checkout(context: commands.Context) -> None: print(f"{context.message.author.display_name} checked out") checkin_db.update(context.message.author.display_name, False) count = checkin_db.get_checkin_count() if count == 1: await context.send(f"Aktuell {count} Mensch im Erfindergeist") else: await context.send(f"Aktuell {count} Menschen im Erfindergeist") @bot.command() async def checkin_list(context: commands.Context) -> None: checkin_db.auto_checkout() count = checkin_db.get_checkin_count() if count == 1: await context.send( f"Aktuell {checkin_db.get_checkin_count()} Mensch im Erfindergeist: {', '.join(checkin_db.get_checkin_names())}" ) else: await context.send( f"Aktuell {checkin_db.get_checkin_count()} Menschen im Erfindergeist: {', '.join(checkin_db.get_checkin_names())}" ) bot.run(os.getenv("DISCORD_KEY"))