Initial Commit for Dolly:

Dolly is a simple Discord Bot that *right now* only does TODO lists. She does not handle anything else.
This commit is contained in:
Dani
2023-12-21 14:54:10 -05:00
commit 3b5652ebb9
7 changed files with 259 additions and 0 deletions

36
main.py Normal file
View File

@ -0,0 +1,36 @@
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)
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.run(config["discord_token"])