SQLite Setup
This commit is contained in:
1 parent
7882ba4915
commit
d564756511
5 files changed
+64
-10
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
import asyncio
|
||||
import discord
|
||||
from cogs.database import Database
|
||||
from discord.ext import commands
|
||||
from dotenv import load_dotenv
|
||||
|
||||
@@ -13,8 +14,11 @@ bot = commands.Bot(command_prefix="Warum Kann das nicht weg??? :C", intents=inte
|
||||
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
print(f'Logged in as {bot.user} (ID: {bot.user.id})')
|
||||
print('------')
|
||||
print(f"Logged in as {bot.user} (ID: {bot.user.id})")
|
||||
print("------")
|
||||
|
||||
await bot.database.connect()
|
||||
print("Database connected!")
|
||||
|
||||
try:
|
||||
synced = await bot.tree.sync()
|
||||
@@ -22,16 +26,22 @@ async def on_ready():
|
||||
except Exception as e:
|
||||
print(f"Failed to sync commands: {e}")
|
||||
|
||||
@bot.event
|
||||
async def on_disconnect():
|
||||
await bot.database.close()
|
||||
|
||||
|
||||
async def load_extensions():
|
||||
for filename in os.listdir('./commands'):
|
||||
if filename.endswith('.py'):
|
||||
await bot.load_extension(f'commands.{filename[:-3]}')
|
||||
print(f'Loaded extension: commands.{filename[:-3]}')
|
||||
for filename in os.listdir("./commands"):
|
||||
if filename.endswith(".py"):
|
||||
await bot.load_extension(f"commands.{filename[:-3]}")
|
||||
print(f"Loaded extension: commands.{filename[:-3]}")
|
||||
|
||||
async def main():
|
||||
async with bot:
|
||||
bot.database = Database()
|
||||
|
||||
await load_extensions()
|
||||
await bot.start(os.getenv('DISCORD_TOKEN'))
|
||||
await bot.start(os.getenv("DISCORD_TOKEN"))
|
||||
|
||||
asyncio.run(main())
|
||||
Reference in new issue
Block a user