© 2026 Hedgehog Software, LLC
SapphireClient
import { SapphireClient } from "@sapphire/framework"; import { container } from "@sapphire/pieces"; import type { ClientOptions } from "discord.js"; import { drizzle } from "drizzle-orm/node-postgres"; import pg from "pg"; import { dbConnectionString } from "../config.js"; const { Client } = pg; // @ts-expect-error Somehow errored with d.js ClientOptions conflict export class BotClient extends SapphireClient { public readonly db = drizzle(new Client({ connectionString: dbConnectionString })); public constructor(public readonly options: ClientOptions) { super(options); Object.assign(container, { db: this.db }); } } declare module "@sapphire/framework" { type SapphireClient = { readonly db: BotClient["db"]; }; } declare module "@sapphire/pieces" { // eslint-disable-next-line @typescript-eslint/consistent-type-definitions interface Container { readonly db: BotClient["db"]; } }
const client = new BotClient({ baseUserDirectory: "./", intents: ["Guilds"] }); client.on("ready", () => { console.log(`Logged in as ${client.user?.tag}!`); }); await client.login();
D:\[redacted\node_modules\.pnpm\[email protected]\node_modules\discord.js\src\client\websocket\WebSocketManager.js:147 largeThreshold: ws.large_threshold, ^ TypeError: Cannot read properties of undefined (reading 'large_threshold') at WebSocketManager.connect (D:\[redacted]\node_modules\.pnpm\[email protected]\node_modules\discord.js\src\client\websocket\WebSocketManager.js:147:28)
Join the Discord to ask follow-up questions and connect with the community
Sapphire is a next-gen object-oriented Discord.js bot framework.
2,286 Members