Ahmad A.
Ahmad A.
Explore posts from servers
SIASapphire - Imagine a framework
Created by Ahmad A. on 4/1/2024 in #sapphire-support
WIll this work?
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(command => command.setName("ping").setDescription("Pong!"), {
idHints: [`${this.container.client.id}`],
});
}
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(command => command.setName("ping").setDescription("Pong!"), {
idHints: [`${this.container.client.id}`],
});
}
3 replies
SIASapphire - Imagine a framework
Created by Ahmad A. on 3/29/2024 in #sapphire-support
Button doing nothing
const button = new ButtonBuilder()
.setCustomId("COB")
.setLabel("Custom Options")
.setEmoji("⚙️")
.setStyle(ButtonStyle.Secondary);
const button = new ButtonBuilder()
.setCustomId("COB")
.setLabel("Custom Options")
.setEmoji("⚙️")
.setStyle(ButtonStyle.Secondary);
import { InteractionHandler, InteractionHandlerTypes } from "@sapphire/framework";
import type { ButtonInteraction } from "discord.js";

export class ButtonHandler extends InteractionHandler {
public constructor(ctx: InteractionHandler.LoaderContext, options: InteractionHandler.Options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.Button,
});
}

public override parse(interaction: ButtonInteraction) {
if (interaction.customId !== "COB") return this.none();
return this.some();
}

public async run(interaction: ButtonInteraction) {
await interaction.reply({
content: "Hello from a button interaction handler!",
ephemeral: true,
});
await interaction.channel?.send("Hi");
}
}
import { InteractionHandler, InteractionHandlerTypes } from "@sapphire/framework";
import type { ButtonInteraction } from "discord.js";

export class ButtonHandler extends InteractionHandler {
public constructor(ctx: InteractionHandler.LoaderContext, options: InteractionHandler.Options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.Button,
});
}

public override parse(interaction: ButtonInteraction) {
if (interaction.customId !== "COB") return this.none();
return this.some();
}

public async run(interaction: ButtonInteraction) {
await interaction.reply({
content: "Hello from a button interaction handler!",
ephemeral: true,
});
await interaction.channel?.send("Hi");
}
}
No errors too
13 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
Code
import { Client as BaseClient, ClientUser, Collection, GatewayIntentBits } from "discord.js";
import IClient from "../Interfaces/Client.js";
import Command from "../Interfaces/Command.js";
import ClientConfig from "../Interfaces/ClientConfig.js";
import CommandHandler from "../handlers/commandHandler.js";
import EventHandler from "../handlers/eventHandler.js";
import Modal from "../Interfaces/Modal.js";
import ModalHandler from "../handlers/modalHandler.js";
import { PasteClient } from "pastebin-api";
import secrets from "../json/secrets.json" assert { type: "json" };
import sendLog from "../functions/sendLog.js";
class Client extends BaseClient implements IClient {
public readonly commands: Collection<string, Command>;
public readonly modals: Collection<string, Modal>;
public user: ClientUser;
public pastebin: PasteClient;
constructor() {
super({
intents: [GatewayIntentBits.Guilds],
allowedMentions: { parse: ["users"] },
});

this.commands = new Collection<string, Command>();
this.modals = new Collection<string, Modal>();
this.user = super.user as ClientUser;
this.pastebin = new PasteClient(this.config.pastebin);
}
config = secrets as unknown as ClientConfig;
async init() {
await sendLog(`[SYSTEM] Handlers have been initiated.`);
await CommandHandler(this);
await EventHandler(this);
await ModalHandler(this);
await this.login(this.config.token);
}
}
export default Client;
import { Client as BaseClient, ClientUser, Collection, GatewayIntentBits } from "discord.js";
import IClient from "../Interfaces/Client.js";
import Command from "../Interfaces/Command.js";
import ClientConfig from "../Interfaces/ClientConfig.js";
import CommandHandler from "../handlers/commandHandler.js";
import EventHandler from "../handlers/eventHandler.js";
import Modal from "../Interfaces/Modal.js";
import ModalHandler from "../handlers/modalHandler.js";
import { PasteClient } from "pastebin-api";
import secrets from "../json/secrets.json" assert { type: "json" };
import sendLog from "../functions/sendLog.js";
class Client extends BaseClient implements IClient {
public readonly commands: Collection<string, Command>;
public readonly modals: Collection<string, Modal>;
public user: ClientUser;
public pastebin: PasteClient;
constructor() {
super({
intents: [GatewayIntentBits.Guilds],
allowedMentions: { parse: ["users"] },
});

this.commands = new Collection<string, Command>();
this.modals = new Collection<string, Modal>();
this.user = super.user as ClientUser;
this.pastebin = new PasteClient(this.config.pastebin);
}
config = secrets as unknown as ClientConfig;
async init() {
await sendLog(`[SYSTEM] Handlers have been initiated.`);
await CommandHandler(this);
await EventHandler(this);
await ModalHandler(this);
await this.login(this.config.token);
}
}
export default Client;
Error:
src/structures/Client.ts:26:23 - error TS2855: Class field 'user' defined by the parent class is not accessible in the child class via super.

26 this.user = super.user as ClientUser;
~~~~


Found 1 error in src/structures/Client.ts:26
src/structures/Client.ts:26:23 - error TS2855: Class field 'user' defined by the parent class is not accessible in the child class via super.

26 this.user = super.user as ClientUser;
~~~~


Found 1 error in src/structures/Client.ts:26
40 replies