Teixeira
Teixeira
Explore posts from servers
SIASapphire - Imagine a framework
Created by Teixeira on 6/2/2024 in #sapphire-support
Validation error in `SlashCommandBuilder.addSubcommand`
No description
21 replies
SIASapphire - Imagine a framework
Created by Teixeira on 5/10/2024 in #discordjs-support
Keep getting "Shard 0 is reconnecting..." errors
No description
2 replies
SIASapphire - Imagine a framework
Created by Teixeira on 4/29/2024 in #discordjs-support
Is there a way to make the bot press a button component within a message
Wondering if there's a way to simulate a button press on a message (particularly a message that wasn't sent by the bot).
3 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/17/2024 in #sapphire-support
"ChatInputCommandError" listener not firing for subcommands
ChatInputCommandError.ts:
import { ChatInputCommandErrorPayload, Events, Listener } from '@sapphire/framework';
import generalErrorEmbed from '../lib/embed-presets/GeneralError.js';

/**
* Emitted after a chat input command runs unsuccesfully.
*/
export class ChatInputCommandErrorListener extends Listener<typeof Events.ChatInputCommandError> {
public constructor(context: Listener.LoaderContext, options: Listener.Options) {
super(context, {
...options,
event: 'chatInputCommandError'
});
}

/**
* Is called whenever an error is thrown in a `chatInputRun` method.
*
* @param error - The error thrown
* @param payload - The contextual payload
*/
public async run(error: unknown, payload: ChatInputCommandErrorPayload) {
(async () => {
if (!payload.interaction.deferred) await payload.interaction.deferReply({ ephemeral: true });

await payload.interaction.editReply({
embeds: [generalErrorEmbed]
});
})().catch(this.container.logger.error);

this.container.logger.error(`Encountered an error with the "chatInputRun" method of command "${payload.command.name}"`, error);
}
}
import { ChatInputCommandErrorPayload, Events, Listener } from '@sapphire/framework';
import generalErrorEmbed from '../lib/embed-presets/GeneralError.js';

/**
* Emitted after a chat input command runs unsuccesfully.
*/
export class ChatInputCommandErrorListener extends Listener<typeof Events.ChatInputCommandError> {
public constructor(context: Listener.LoaderContext, options: Listener.Options) {
super(context, {
...options,
event: 'chatInputCommandError'
});
}

/**
* Is called whenever an error is thrown in a `chatInputRun` method.
*
* @param error - The error thrown
* @param payload - The contextual payload
*/
public async run(error: unknown, payload: ChatInputCommandErrorPayload) {
(async () => {
if (!payload.interaction.deferred) await payload.interaction.deferReply({ ephemeral: true });

await payload.interaction.editReply({
embeds: [generalErrorEmbed]
});
})().catch(this.container.logger.error);

this.container.logger.error(`Encountered an error with the "chatInputRun" method of command "${payload.command.name}"`, error);
}
}
8 replies
SIASapphire - Imagine a framework
Created by Teixeira on 3/14/2024 in #sapphire-support
Globally setting the guild in which to register commands by default
Even though I'm setting ApplicationCommandRegistries.setDefaultGuildIds(<GUILD_ID>); before <SapphireClient>.login the commands are still being registered globally. The commands do not have the guildIds option set.
114 replies
SIASapphire - Imagine a framework
Created by Teixeira on 1/24/2024 in #sapphire-support
NPM script stops working when tsconfig extends @sapphire/ts-config
My npm package has a simple build script:
"prebuild": "rimraf dist types",
"build": "tsc",
"prebuild": "rimraf dist types",
"build": "tsc",
When extending @sapphire/ts-config on my tsconfig.json , it stops working. Using typescript^5.3.2 and rimraf^5.0.5. Strangely enough, running tsc in the same working directory works as expected... Full tsconfig.json:
{
"extends": ["@sapphire/ts-config", "@sapphire/ts-config/extra-strict", "@sapphire/ts-config/decorators"],
"include": ["src"],
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"module": "NodeNext",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": true,
"declarationDir": "types",
"sourceMap": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"noFallthroughCasesInSwitch": true,
"strict": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"resolveJsonModule": true,
"declarationMap": true,
"importHelpers": true
}
}
{
"extends": ["@sapphire/ts-config", "@sapphire/ts-config/extra-strict", "@sapphire/ts-config/decorators"],
"include": ["src"],
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"module": "NodeNext",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": true,
"declarationDir": "types",
"sourceMap": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"noFallthroughCasesInSwitch": true,
"strict": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"resolveJsonModule": true,
"declarationMap": true,
"importHelpers": true
}
}
12 replies
SIASapphire - Imagine a framework
Created by Teixeira on 12/9/2023 in #sapphire-support
On Listeners
A couple questions on listener pieces: - Where can I find a list of available sapphire event identifiers and their respective arguments? - Does sapphire have any listeners or similar setup by default and if so which ones?
7 replies
SIASapphire - Imagine a framework
Created by Teixeira on 12/8/2023 in #sapphire-support
"Couldn't find a template file for that component type."
I'm having trouble setting up a custom component template using Sapphire CLI. Here's the template file (custom-listener.ts.sapphire):
{
"category": "listeners"
}
---
export class {{name}}Listener extends Listener {
public constructor(context: Listener.LoaderContext, options: Listener.Options) {
super(context, {
...options,
/**
* These two default to the file's name.
*/
name: 'ready',
event: 'ready'
/** */
});
}

/**
* Executes on event trigger
* @param client - The client that triggered this event
*/
public run(client: Client) {
// TODO
}
}
{
"category": "listeners"
}
---
export class {{name}}Listener extends Listener {
public constructor(context: Listener.LoaderContext, options: Listener.Options) {
super(context, {
...options,
/**
* These two default to the file's name.
*/
name: 'ready',
event: 'ready'
/** */
});
}

/**
* Executes on event trigger
* @param client - The client that triggered this event
*/
public run(client: Client) {
// TODO
}
}
When running npx sapphire generate custom-listener test it returns Couldn't find a template file for that component type. Default component templates work normally
4 replies
SIASapphire - Imagine a framework
Created by Teixeira on 8/17/2023 in #sapphire-support
Can I have multiple autocomplete interaction handlers?
When an autocomplete interaction comes through, if one of the autocomplete handlers returns this.none() in the parse method, will it still run the other handlers until it finds one that returns this.some()?
4 replies
SIASapphire - Imagine a framework
Created by Teixeira on 6/28/2023 in #sapphire-support
Setting autocomplete options based on other option's value
5 replies
DIAdiscord.js - Imagine an app
Created by Teixeira on 6/28/2023 in #djs-questions
Setting autocomplete options based on other option's value
11 replies
SIASapphire - Imagine a framework
Created by Teixeira on 6/28/2023 in #sapphire-support
autocompleteRun for sub commands
Is it possible to setup a autocompleteRun for specific subcommands similar to how it is done for chatInputRun?
6 replies
SIASapphire - Imagine a framework
Created by Teixeira on 6/25/2023 in #sapphire-support
Is it possible to edit the default message returned by "preset preconditions"?
For example, the precondition set by <CommandOptions.requiredClientPermissions> returns I am missing the following permissions to run this command: Manage Channels as the <UserError>.message parsed in the ChatInputCommandDenied listener, but I'd like it to return something else.
7 replies
DIAdiscord.js - Imagine an app
Created by Teixeira on 6/23/2023 in #djs-questions
Is there any way to know when a user has purchased or cancelled/not renewed a server subscription?
Couldn't find anything about it in the guide. I'm on 14.11.0. Thank you!
24 replies
SIASapphire - Imagine a framework
Created by Teixeira on 6/11/2023 in #sapphire-support
Set precondition's name instead of having it resolve from file name
Is it possible to set a precondition's name manually instead of having it resolve from file name, similar to how it can be done with listeners, commands and interaction handlers?
4 replies
SIASapphire - Imagine a framework
Created by Teixeira on 6/11/2023 in #sapphire-support
Should I create multiple interaction handlers for each interaction type?
If I'm understanding correctly the point of the parse method is to determine whether a specific interaction handler should run, so that means we can create multiple handlers of the same type (Button for example) right? The guide does mention this is possible for listeners but doesn't say anything about it for interaction handlers so I just wanted to confirm, thanks!
5 replies
DIAdiscord.js - Imagine an app
Created by Teixeira on 8/12/2022 in #djs-questions
Cannot use GIF url as an embed's image.
9 replies
DIAdiscord.js - Imagine an app
Created by Teixeira on 7/14/2022 in #djs-questions
Setting the default permission for commands built using discord.js builders.
I'm trying to use <SlashCommandBuilder>.setDefaultMemberPermissions('0') to disallow members to use that command by default, but it's not working. Could it be because this command is registered on a guild instead of globally? I'm using @discordjs/builders@0.16.0-dev.1657757509-fe34f48
12 replies