import './lib/setup';
import { PrismaClient } from '@prisma/client/edge';
import { withOptimize } from '@prisma/extension-optimize';
import { container, LogLevel, SapphireClient } from '@sapphire/framework';
import { GatewayIntentBits } from 'discord.js';
// Extend Prisma Client with the optimization extension
const prisma = new PrismaClient().$extends(withOptimize());
// Define a correct type for the extended Prisma Client
type ExtendedPrismaClient = PrismaClient & ReturnType<typeof withOptimize>;
// Sapphire client setup
const client = new SapphireClient({
defaultPrefix: '!',
caseInsensitiveCommands: true,
logger: {
level: LogLevel.Debug,
},
intents: [
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.MessageContent,
],
loadMessageCommandListeners: true,
});
// Main function to start the bot
const main = async () => {
try {
client.logger.info('Logging in');
await client.login();
client.logger.info('Logged in');
} catch (error) {
client.logger.fatal(error);
await client.destroy();
process.exit(1);
}
};
// Ensure the container has the correct type
declare module '@sapphire/pieces' {
interface Container {
database: ExtendedPrismaClient;
}
}
// Assign the database to the container
container.database = prisma as ExtendedPrismaClient;
// Execute the main function
void main();
import './lib/setup';
import { PrismaClient } from '@prisma/client/edge';
import { withOptimize } from '@prisma/extension-optimize';
import { container, LogLevel, SapphireClient } from '@sapphire/framework';
import { GatewayIntentBits } from 'discord.js';
// Extend Prisma Client with the optimization extension
const prisma = new PrismaClient().$extends(withOptimize());
// Define a correct type for the extended Prisma Client
type ExtendedPrismaClient = PrismaClient & ReturnType<typeof withOptimize>;
// Sapphire client setup
const client = new SapphireClient({
defaultPrefix: '!',
caseInsensitiveCommands: true,
logger: {
level: LogLevel.Debug,
},
intents: [
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.MessageContent,
],
loadMessageCommandListeners: true,
});
// Main function to start the bot
const main = async () => {
try {
client.logger.info('Logging in');
await client.login();
client.logger.info('Logged in');
} catch (error) {
client.logger.fatal(error);
await client.destroy();
process.exit(1);
}
};
// Ensure the container has the correct type
declare module '@sapphire/pieces' {
interface Container {
database: ExtendedPrismaClient;
}
}
// Assign the database to the container
container.database = prisma as ExtendedPrismaClient;
// Execute the main function
void main();