import discord from discord.ext import commands from config import load_config, get_intents from database import setup_database, add_todo, list_todos, remove_todo config = load_config() intents = get_intents() bot = commands.Bot(command_prefix='!', intents=intents) # Replace 'YOUR_USER_ID' with the actual Discord ID of the user AUTHORIZED_USER_ID = '96701265748168704' conn = setup_database() @bot.event async def on_ready(): print(f'{bot.user.name} has connected to Discord!') @bot.command(name='todo', help='Adds a new to-do item') async def todo_command(ctx, *, todo_item: str): if add_todo(conn, todo_item): await ctx.send(f"Added to-do: {todo_item}") else: await ctx.send("Error adding to-do.") @bot.command(name='listtodos', help='Lists all to-do items') async def listtodos_command(ctx): todos = list_todos(conn) response = "To-Do List:\n" + "\n".join([f"{id}: {content}" for id, content in todos]) await ctx.send(response) @bot.command(name='removetodo', help='Removes a to-do item by its ID') async def removetodo_command(ctx, todo_id: int): if remove_todo(conn, todo_id): await ctx.send(f"Removed to-do with ID {todo_id}") else: await ctx.send("Error removing to-do.") @bot.command(name='shutdown', help='Shuts down the bot if authorized') async def shutdown(ctx): if str(ctx.author.id) == AUTHORIZED_USER_ID: await ctx.send('Shutting down. Bye!') await bot.close() else: await ctx.send('You do not have permission to shut down the bot.') bot.run(config["discord_token"])