import discord
from model_manager import ModelManager
import os
from dotenv import load_dotenv

# Load environment variables
load_dotenv()

# Discord bot setup
intents = discord.Intents.default()
intents.messages = True
intents.message_content = True
client = discord.Client(intents=intents)

# Initialize the ModelManager
USE_CUSTOM_MODEL = True
OLLAMA_URL = None  # Set to your Ollama endpoint if needed
model_manager = ModelManager(use_custom_model=USE_CUSTOM_MODEL, ollama_url=OLLAMA_URL)

@client.event
async def on_ready():
    print(f"Logged in as {client.user}")

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    # Generate response
    user_input = message.content
    bot_response = model_manager.generate_response(user_input)

    await message.channel.send(bot_response)

client.run(os.getenv("DISCORD_TOKEN"))
