Sapphire - Imagine a Framework

SIA

Sapphire - Imagine a Framework

Sapphire is a next-gen object-oriented Discord.js bot framework.

Join

sapphire-support

discordjs-support

old-sapphire-support

old-discordjs-support

old-application-commands-and-interactions

Context Menu Command and Subcommand cannot be in same extended class?

I have a slash command which is an extended Subcommand called give-role with two subcommands - one & multi. The file name is give-role.ts Now I also want a Context Menu command named Give Role within same give-role.ts...

UserErrors not being caught by listener - bot is crashing

messageCommandError.mjs ```js import { Events, Listener } from "@sapphire/framework"; import { send } from "@sapphire/plugin-editable-commands"; import { EmbedBuilder } from "discord.js";...

Subcommand isn't running

When the subcommand is run in Discord, it times out. I've added a log to the beginning of the method but it isn't triggered. Normal commands work fine. ```ts @ApplyOptions<Subcommand.Options>({ name: 'blacklist',...
Solution:
found the issue, was using the wrong name for my precondition

How to properly handle UserErrors?

I'm using the official sapphire template and want to throw a UserError inside a context menu command. How do I correctly handle the error and send a message to the user? I saw contextMenuCommandDenied.ts and thought that would handle it but I don't get a response and the error is shown in the logs....

Can I set different requiredUserPermissions for each subcommand?

Just wondering if this is possible, and how. Thanks

Handling BulkOverwrite Registry Errors

When I encounter this error
[ERROR] ApplicationCommandRegistries(BulkOverwrite) Failed to overwrite guild application commands for guild 1********* DiscordAPIError[50001]: Missing Access
[ERROR] ApplicationCommandRegistries(BulkOverwrite) Failed to overwrite guild application commands for guild 1********* DiscordAPIError[50001]: Missing Access
...

Events for Voice

How can I do something like the following but for voice? ``` import { Listener } from '@sapphire/framework'; ...

How do I use autocompleteRun on subcommands?

^ As the title says. I can't seem to figure out how subcommands can have autocompleteRun implemented. I'm not too worried about duplicates, since there is only one subcommand that uses autocomplete.
Solution:
Doesn't matter. You still just do ```ts public override autocompleteRun(interaction: AutocompleteInteraction) { const subcommand = interaction.options.getSubcommand(); if (subcommand.name === 'the subcommand with autocomplete') {...

Message editing fails even though message can be fetched

Whenever I want to edit an ephemeral message I get the following error:
[ERROR] Encountered error while handling an interaction handler run method for interaction-handler "release_card" at path "/home/developer/Wishbot/src/interaction-handlers/release_card.js" DiscordAPIError[10008]: Unknown Message
[ERROR] Encountered error while handling an interaction handler run method for interaction-handler "release_card" at path "/home/developer/Wishbot/src/interaction-handlers/release_card.js" DiscordAPIError[10008]: Unknown Message
The message can be correctly fetched though using the channel and message id ...

Problem with ephemeral messages

I currently have a command which sends a button, problem is, once the button is pressed, I can't remove the ephemeral message. Is there a way to remove the button and also edit the entire message?

Is recommend have split autocomplete handlers

I want know is recommend have split handler such as characterAutocomplete & itemsAutocomplete.
Solution:
okay thanks

Quick question regarding application descriptions

How does one link an application command in the description of an app? Looks like a mention syntax, but I can't seem to figure it out.
Solution:
As for mentioning commands </price:1078828281555603489> is /price So it's name:id...

What typescript version to use?

Since the most recent announcement in #Announcements recommends that I should not use typescript version 5.x, what version should I rather use? Just any recent version below that?
Solution:
4.9.5, which is the latest for v4.

How to get subcommand name from interaction object?

I am will be having multiple commands which have their own sub commands (3 sub command per parent command). Out of those 3 sub commands, 2 of them will have AutoComplete. How do I distinguish between sub commands?...
Solution:
After some research I found out that this can be done using:
interaction.options.getSubcommand()
interaction.options.getSubcommand()
...

How do I listen for reactions on all messages in a channel?

doing discord bot dev after a long time. i wanted to listen for message reactions on every message in a channel and run a db query in the run function. but for some reason i can't even get a simple log to work rn. what am i doing wrong here? ```ts // src/listeners/reaction.ts ...
Solution:
Do you have the GuildMessageReactions Intent enabled? And that event only triggers on cached messages so you would also need to enable the partials for reaction and I believe message....

MessageCreate Event isn't working

This is the first listener Im creating I've read the documentation 50 times imo and checked out the examples and I am still confused ```ts import { Events, Listener } from '@sapphire/framework'; import type { Message } from 'discord.js';...
Solution:
you either have to name it messageCreate.<ext> or add a constructor with name: Events.MessageCreate (which resolves to name: 'messageCreate'

NOT WORK SAPPHIRE

why not work bot commands?
Solution:
why not work bot commands?

Reply During Cooldown

Can I make the bot reply with the remaining time of cooldown delay ?
Solution:
but if you wanna specifically get the remaining time:
Reflect.get(Object(context), 'remaining');
Reflect.get(Object(context), 'remaining');
...

messageUpdate event not Triggering

```ts import { Listener } from '@sapphire/framework'; import type { Message } from 'discord.js'; export class roleDeleteListner extends Listener { public constructor(context: Listener.Context, options: Listener.Options) {...

'"discord.js"' has no exported member named 'WebhookEditMessageOptions'. Did you mean 'WebhookFetchM

Error: '"discord.js"' has no exported member named 'WebhookEditMessageOptions'. Did you mean 'WebhookFetchMessageOptions' Project Created with sapphire new - typescript complete I just changed WebhookEditMessageOptions with WebhookEditMessageOptions...
Solution:
<:_:898645160219521134> WebhookFetchMessageOptions Options that can be passed into fetchMessage....