reset Dolly by removing all of her code
This commit is contained in:
14
config.py
14
config.py
@ -1,14 +0,0 @@
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
import discord
|
||||
|
||||
def load_config():
|
||||
load_dotenv()
|
||||
return {
|
||||
"discord_token": os.getenv("DISCORD_BOT_TOKEN")
|
||||
}
|
||||
|
||||
def get_intents():
|
||||
intents = discord.Intents.default()
|
||||
intents.message_content = True
|
||||
return intents
|
33
database.py
33
database.py
@ -1,33 +0,0 @@
|
||||
import sqlite3
|
||||
|
||||
def setup_database():
|
||||
conn = sqlite3.connect('todos.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('''CREATE TABLE IF NOT EXISTS todos (content TEXT)''')
|
||||
conn.commit()
|
||||
return conn
|
||||
|
||||
def add_todo(conn, todo_item):
|
||||
try:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("INSERT INTO todos (content) VALUES (?)", (todo_item,))
|
||||
conn.commit()
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"Error adding to-do: {e}")
|
||||
return False
|
||||
|
||||
def list_todos(conn):
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT rowid, content FROM todos")
|
||||
return cursor.fetchall()
|
||||
|
||||
def remove_todo(conn, todo_id):
|
||||
try:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("DELETE FROM todos WHERE rowid = ?", (todo_id,))
|
||||
conn.commit()
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"Error removing to-do: {e}")
|
||||
return False
|
47
main.py
47
main.py
@ -1,47 +0,0 @@
|
||||
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"])
|
Reference in New Issue
Block a user