Sapphire - Imagine a framework

SIA

Sapphire - Imagine a framework

Welcome to the Sapphire Discord server! The next-gen object-oriented Discord.js bot framework can be found here.

Join

sapphire-support

discordjs-support

old-sapphire-support

old-discordjs-support

old-application-commands-and-interactions

API Placeholder in Route

I didn't found it in the docs. Is there any way to get a placeholder into a route like in express with /routename/:id so I can use it to get the resource with the respective id?
Solution:
exactly like that. That isn't Express syntax, that's the recommended REST syntax. you get the params through request.params.id, replace id with whatever you put in :id...

TypeError piace.aliases is not iterable

Good afternoon, I mixed such a strange code as best I could. My task was to add a button to the message with a built-in embed, but it's not clear why I get an error in the console, please give me an answer what I did wrong :). Code and error below. const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, } = require("@discordjs/builders") const { Command, Piece, InteractionHandlerTypes } = require('@sapphire/framework'); const { ButtonStyle, InteractionType } = require("discord.js");...
Solution:
Good afternoon, I mixed such a strange code as best I could. My task was to add a button to the message with a built-in embed, but it's not clear why I get an error in the console, please give me an answer what I did wrong :). Code and error below. const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, } = require("@discordjs/builders") const { Command, Piece, InteractionHandlerTypes } = require('@sapphire/framework'); const { ButtonStyle, InteractionType } = require("discord.js");...
No description

API Client with SSL?

Hey guys, currently I am trying to make the switch from an custom express API to the API plugin. Is there a way to let the plugin consume an ssl cert and open a https server? Greetings...

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....