import DiscordApi from "discord.js"; import { Configuration as OpenAIApiConfiguration, OpenAIApi } from "openai"; import { PrismaClient } from "@prisma/client"; import config from "./config"; import { queueRequest } from "./execution"; import InteractionManager from "./interactionManager"; const discord = new DiscordApi.Client({ intents: [ DiscordApi.GatewayIntentBits.Guilds, DiscordApi.GatewayIntentBits.GuildMessages, DiscordApi.GatewayIntentBits.MessageContent, ] }); export const openai = new OpenAIApi(new OpenAIApiConfiguration({ apiKey: config.tokens.OpenAI })); export const database = new PrismaClient(); const interactionManager = new InteractionManager(); interactionManager.bindClient(discord); discord.on("ready", async event => { console.log(`Connected to Discord as ${event.user.tag} (${event.user.id})`); }); discord.on("messageCreate", async message => { if (message.author.bot) return; if (!message.mentions.has(message.client.user)) return; queueRequest(message); }); discord.login(config.tokens.Discord);