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

message listeners stopped working in sapphire v4 on my bot

hi, this is my listener code: ```js const { Events, Listener, container } = require('@sapphire/framework');...
Solution:
Okay Vladdy found the problem @owoer You forgot to call super.onLoad() in your onLoad method ```js onLoad() {...

Duplicate identifier 'Command'

I'm trying to create a basic slash command, but when I import the Command class from @sapphire/framework, it gives the error:
Duplicate identifier 'Command'
Duplicate identifier 'Command'
What can I do?...
Solution:
f1 => restart ts server

Context menu commands not being registered

Hi, on updating to v4 I experienced the following error:
ApplicationCommandRegistry[report] Failed to update command Banish (<id>) DiscordAPIError[40041]: An application command with that name already exists
ApplicationCommandRegistry[report] Failed to update command Banish (<id>) DiscordAPIError[40041]: An application command with that name already exists
...
Solution:
we'll hopefully get this out this week

Is there a way to disable ApplicationCommandRegistries logs?

They happen on start-up and I don't want them between all of my formatted logging. Is there a way I can disable them?
Solution:
If you use a custom logger you should extend the built in Logger class. See for example how @sapphire/plugin-logger works.

Context Menu Interactions Not Received

I'm using the basic context menu command register (attached) and my run function is async contextMenuRun(interaction), but I do not think it's the problem with the function since the command does not even seem to be received (check screenshot). Anyone know how to fix this? Common troubleshooting for these types of issues would also be useful. Thanks!
Solution:
@tk can you check if npm install @sapphire/framework@pr-590 fixes it for you too

ChatInputCommandError Event not firing

I'm having trouble with this code https://hst.sh/odutopaniv.typescript in that the event is not firing when a command errors and this is being logged by sapphire natively https://hst.sh/ivezicirex.apache
Solution:
This appears to be an issue yes but I currently do not have the time to look into it. For now I recommend splitting across files and just calling the same external function: https://github.com/sapphiredev/gemboard/tree/main/src/listeners/commands

What does commandError emit?

I'm struggling to find what commandError emits when fired by sapphire.
Solution:
A chatInputCommandError event emits a ChatInputCommandErrorPayload

Am I doing this wrong? I feel like I'm doing this wrong.

Hey there, In my ping command I'm doing void interaction.reply(await resolveKey(interaction, "ping:success", { ping })) because I'm using eslint and it is screaming
Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator.
Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator.
when not using void. Is this a good way of handling the eslint error or is there a better one. resolveKey is from @sapphire/plugin-i18next and the eslint config is from @sapphire/eslint-config....
Solution:
interaction.reply returns a promise. It just be that way. Either await it, or if it's last in the command then return it.

Button handler not triggering

Heyah @Helpers I basically added a button handler from https://www.sapphirejs.dev/docs/Guide/application-commands/interaction-handlers/buttons in /listeners and changed the example's button ID with the one from ```ts const buttonRow = new ActionRowBuilder<ButtonBuilder>().addComponents( new ButtonBuilder() .setCustomId("foo")...

How to make auto idhints?

so i want to make automatic idhints adding like idHints: [this.id] but i think it doesn't work so how i can make it auto?...
Solution:
There is no automatic idHints. You are completely misunderstanding what idHints are for. Read https://www.sapphirejs.dev/docs/Guide/application-commands/application-command-registry/registering-chat-input-commands#idhints again In short idHints are used before commands are even registered (and this.id would be available) to diff files against API data....

Issue on upgrade to v4

On loading like any file (listeners and commands) it spits out a TypeError: import_discord2.Permissions is not a constructor error and doesn't load it.
Solution:
wait, i didn't update decorators

Namespace 'Command' has no exported member 'ChatInputInteraction'.

Hey there, I'm following the guide at https://www.sapphirejs.dev/docs/Guide/getting-started/creating-a-basic-app-command, and I'm getting the error Namespace 'Command' has no exported member 'ChatInputInteraction'. on this line. ```ts public async chatInputRun(interaction: Command.ChatInputInteraction)...
Solution:
Yeah that was changed today in v4. You should use Command.ChatInputCommandInteraction

Dockerfile - CLI Template

If I'm using yarn v3 do i enable line 23 + 27-28 or just 27-28?
Solution:
If you're using Yarn v3, then you copy the yarn.lock, the .yarnrc.yml, and the .yarn directory, as they are in your screenshot

Subcommands Typings clashing after updating.

```ts src/lib/structures/PrismSubcommand.ts:27:51 - error TS2694: Namespace '"C:/Users/jacob/Documents/GitHub/THE-PRISM-V4/node_modules/@sapphire/plugin-subcommands/dist/lib/Subcommand".Subcommand' has no exported member 'ChatInputInteraction'. 27 export type ChatInputInteraction = Subcommand.ChatInputInteraction & { ~~~~...

Send message to specific channel from slash command

I'm so sorry for having to ask this, but... how do you send a message to a specific channel from within a slash command? I believe I'm missing a huge gotcha here.

Cooldown Message

Is there a way to display a custom cooldown message after a cooldown limit is reached?
Solution:
TL;DR: see https://www.sapphirejs.dev/docs/Guide/preconditions/reporting-precondition-failure, get the remaining amount from error.context. Then send custom messages.

What's the best way to watch for activity changes on a channel

Hello 👋 I would like to know what's the best way to develop temporary text and voice channel based on activity. I was going to listen to the message* or voiceStateUpdate events (based on channel type) to update in a database their last activity, and at the same time send an event to warn that a new activity has been detected and thus restart the counter before deleting. However, an implementation like this one seems to me too heavy: retrieving each time the linked resource from the DB, updating it, always have a counter running, and that for each monitored channel....

Set ApplicationCommandOption max value to be a function

For a "page" option in a command, I want to set the max value in the options rather than checking after the user run's the command. Is there any way to do this?

Best way to make ButtonInteractions persistent after restarts?

I'm just wondering if there are any built in ways, or ways you might make button interactions persistent over restarts. I'm trying to make a page up/down button, but having a separate listener/collector means that 1. I have to figure out the current page of the message afterwards. ...
Solution:
but youll have to do something with permanent storage i.e. through a database

build error

I can build my project, and the error come from the framework (i use nodejs v18)
Solution:
Install @types/node