AI-Discord-Bot/bot.py

38 lines
836 B
Python
Raw Normal View History

2025-05-06 11:56:01 -04:00
import os
import discord
2025-05-06 11:56:01 -04:00
from discord.ext import commands
from dotenv import load_dotenv
from ai import get_ai_response
from personality import apply_personality, set_persona
2025-05-06 11:56:01 -04:00
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
2025-05-06 11:56:01 -04:00
intents = discord.Intents.default()
intents.message_content = True
2025-05-06 11:56:01 -04:00
bot = commands.Bot(command_prefix="!", intents=intents)
2025-05-06 11:56:01 -04:00
@bot.event
async def on_ready():
print(f"✅ Logged in as {bot.user.name}")
2025-05-06 11:56:01 -04:00
@bot.command()
async def ping(ctx):
await ctx.send("🏓 Pong!")
2025-05-06 11:56:01 -04:00
@bot.command()
async def chat(ctx, *, message):
await ctx.send("🤖 Thinking...")
reply = get_ai_response(message)
await ctx.send(reply)
@bot.command()
async def setpersona(ctx, *, description):
set_persona(description)
await ctx.send("✅ Persona updated! New style will be used in replies.")
bot.run(TOKEN)