DiscordBot/src/bot/bot.py

35 lines
771 B
Python

import discord
from discord.ext import commands
from dotenv import load_dotenv
from os import getenv
from commands.discord_commands import *
def setup_bot() -> commands.Bot:
print("Configuring bot...")
load_dotenv()
bot = commands.Bot(command_prefix="/", intents=discord.Intents.all())
@bot.event
async def on_ready():
try:
synced = await bot.tree.sync()
print(f"Successfully synced {len(synced)} commands")
except Exception as e:
print(e)
print("Bot ready !")
setup_commands(bot)
return bot
def start_bot(bot: commands.Bot) -> None:
print("Starting bot...")
token = getenv("DISCORD_TOKEN")
if token:
bot.run(token)
else:
print("token error")