Files
barry/bot.py
2025-12-27 17:21:40 +11:00

29 lines
733 B
Python

import barry
import discord
from discord import app_commands
import os
intents = discord.Intents.default()
client = discord.Client(intents=intents)
tree = app_commands.CommandTree(client)
with open("training.txt") as t:
training = t.read()
model = barry.train(training)
@tree.command(name="ask", description="Ask Barry a question")
async def ask(interaction: discord.Interaction, question: str):
_ = await interaction.response.send_message(barry.prompt(question, model))
@client.event
async def on_ready():
await tree.sync()
print(f"logged in as {client.user}")
key = os.getenv("BARRY_TOKEN", None)
if key == None:
print("Set BARRY_TOKEN to the Discord token before continuing")
exit(1)
client.run(key)