Untitled

mail@pastecode.io avatar
unknown
python
a year ago
1.1 kB
1
Indexable
Never
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='!')

todos = {}

@bot.command()
async def add(ctx, *, task):
    global todos
    todos[task] = False
    await ctx.send(f"Added task '{task}' to the to-do list.")

@bot.command()
async def remove(ctx, *, task):
    global todos
    if task in todos:
        del todos[task]
        await ctx.send(f"Removed task '{task}' from the to-do list.")
    else:
        await ctx.send(f"Task '{task}' not found in the to-do list.")

@bot.command()
async def list(ctx):
    global todos
    if len(todos) == 0:
        await ctx.send("The to-do list is empty.")
    else:
        message = "To-Do List:\n"
        for task, status in todos.items():
            message += f"{'[x]' if status else '[ ]'} {task}\n"
        await ctx.send(message)

@bot.command()
async def check(ctx, *, task):
    global todos
    if task in todos:
        todos[task] = True
        await ctx.send(f"Task '{task}' has been checked off.")
    else:
        await ctx.send(f"Task '{task}' not found in the to-do list.")

bot.run('TOKEN')