yuki
yuki
Explore posts from servers
SIASapphire - Imagine a framework
Created by yuki on 5/20/2024 in #sapphire-support
baseUserDirectory with tsx
How do I use baseUserDirectory with tsx? Seems that it doesn't load the ts files relatives to main ts source code
7 replies
SIASapphire - Imagine a framework
Created by yuki on 5/19/2024 in #sapphire-support
Problem with extended SapphireClient
Hi there I'm trying to extend the SapphireClient to add some custom property. Here's all what I got already:
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"];
}
}
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"];
}
}
How I initialize the client:
const client = new BotClient({
baseUserDirectory: "./",
intents: ["Guilds"]

});

client.on("ready", () => {
console.log(`Logged in as ${client.user?.tag}!`);
});

await client.login();
const client = new BotClient({
baseUserDirectory: "./",
intents: ["Guilds"]

});

client.on("ready", () => {
console.log(`Logged in as ${client.user?.tag}!`);
});

await client.login();
But then somehow discord.js throws this error:
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)
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)
any idea what is really happening here?
8 replies
SIASapphire - Imagine a framework
Created by yuki on 9/13/2023 in #sapphire-support
Error [UNLOADED_PIECE]: The piece 'CoreReady' does not exist.
No description
18 replies
SIASapphire - Imagine a framework
Created by yuki on 8/23/2023 in #sapphire-support
Spaced options with @sapphire/lexure
How do I get options that contains space? I tried add the options with quotes, but it doesn't work. Detailed code: https://runkit.com/zenshibata/sapphire-lexure-test
16 replies
DIAdiscord.js - Imagine an app
Created by yuki on 8/21/2023 in #djs-questions
Attach files with @discordjs/rest
How do I attach files and send POST it to channel message endpoint properly?
10 replies
SIASapphire - Imagine a framework
Created by yuki on 7/11/2023 in #sapphire-support
Plugin subcommands: "No subcommand was matched with the provided command."
64 replies