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

Broken modals

sometimes my modals are broken idk why sometimes some text inputs doesn't show up...

Remove old commands

is there a way to clear cached old commands? none of this commands are working rn, i was testing sapphire framework with these dummy commands but they are still there...

Errors when extending @sapphire/ts-config

I am extending the tsconfig in my config by using ```json { "extends": "@sapphire/ts-config" }...

@sapphire/shapeshift ExpectedConstraintError

Hi all, currently creating a command with choices. Here's the code I wrote, but for some reason, this weird error pops up when applying ...choices to #addChoices ```ts interface ShopItem {...
Solution:
Maximum amount of options is 25

Command registering although it does not exist

https://0x0.st/H8tx.png The command parent "misc" is registering although it is NOT on the code https://0x0.st/H8tY.png...
Solution:
I think the command file is still there in dist or whatever folder you have set for compiled output code

Custom Command Cooldown Message

So the default message is something like: There is a cooldown in effect for this chat input command. It'll be available at 2023-04-19T04:26:08.886Z. Is there any good way to turn this message into something more readable and convenient, such as: This command cannot be used for *X* hours / *Y* minutes. Is there a way to extract the cooldown for the command itself? So I can get a date or time object out of it?...

typescript aka tsc not working solved

i've globally installed it as well
Solution:
i've globally installed it as well

How to register commands without loadMessageCommandListeners=true?

I'm currently trying to split my bot into modules to keep the codebase cleaner and easier to maintain, but I'm having trouble figuring out how to register commands without loadMessageCommandListeners=true. I am willing to sacrifice auto-loading of commands, I just need to be able to load them from each of my code's "modules"

More information for CombinedPropertyErrors on shapeshift

Hello, I just rountinely cheked my errors on my production bot and noticed that a few days ago I had the following error ```ts ERROR - Encountered error on event listener "messageUpdate" for event "messageUpdate" at path "./dist/src/listeners/client/messageUpdate.js" CombinedPropertyError (1) ERROR - Received one or more errors ERROR -...

Using plugin-api to link accounts

I am creating a bot which requires the user to link their discord account to their roblox account, both have oauth2 endpoints. I have thought about two methods for authenticating but I am not sure how to implement using plugin-api. I will either generate a magic link that goes straight to roblox oauth, or have them log in with discord first and then roblox, but I am unsure how to redirect users once they go to a route. The only ways I can see the response being published is an error message, json, or plain text. Do I need to use a frontend framework such as express or can I do this entirely on the backend as I do not intent do have a frontend web page....

plugin-subcommands "No subcommand was matched"

I'm configuring my subcommand with: ```ts @ApplyOptions<Subcommand.Options>({ name: "config", subcommands: [...
Solution:
The solution: ```diff { name: "logs",...

how can i make subcommand in slash

i forgot how to do it, and how to handle subcommand?

Multiple context commands in a single file

Like the topic said I want to register 2 context commands in the same command class. Is that possible, if yes how can I achieve this in my code?

Type-safety for guild-only slash commands

I understand that ChatInputCommandInteraction#guildId is nullable, but is there some sort of way to assert it's going to be run in a guild? I'm setting .setDMPermission(false) on the builder, do I need to .guildId! everywhere or is there a better method?
Solution:
if (interaction.inGuild()) {
// now it's in guild and you dont need !
}
if (interaction.inGuild()) {
// now it's in guild and you dont need !
}
...

Passing data from one handler to the other

Say I have a Modal Submit Handler and then inside that handler, I create a button for a new reply, and when pressing that button, is there a way I can pass the data received from the modal to the next handler (in this case the Button Interaction Handler) Thanks in advance 🙂...
Solution:
Discord API offers no such option. The only thing you can do is compress it down to a very tiny string and pass it through the custom ID. For example: https://github.com/favware/dragonite/blob/5fb8956c075f4b9b63b8bc5ab47bb89531ce74ed/src/lib/util/utils.ts#L18-L54

Absolutely nothing happens with basic text command

I followed the Getting Started and setting up a basic command steps to no avail, I simply see 'took 0ms to initialize' and running '@<the bot> ping' does nothing. main is set to dist/index.js and I'm using TS if that affects anything.
Solution:
- Which version of @sapphire/framework are you using? - What's your file/folder structure? - Did you use the CLI to generate your bot? - What's your "main" property in package.json - Are you using TypeScript? And if so, how are you compiling and running your code? That is to say, what are your build and startup scripts?...

Slash command and Unknown interaction

Hi team 🙂 I have a slash command with an action row of buttons, the command is like a personality test, it sends an embed message with a question and each time you click a button to choose an answer (A, B or C) I update the embed with the next question (up to 6 questions). It works all fine itself, but if the User uses the slash command again without finishing the current test, the bot crashes with the following error rawError: { message: 'Unknown interaction', code: 10062 } whenever the user tries to click on a button of any of both messages. For me looks like somehow the ActionRow is not correctly attached to the Embed (doesn't make much sense since I create the actionRow inside chatInputRun method every time, so it should be correctly scoped). I can provide more information if needed, can someone help me? 🙂 ❤️...
Solution:
Solved, just in case someone faces a similar problem in the future, I was attaching the component collector to the channel instead of the message from the interaction.
- <Channel>.createMessageComponentCollector(…)
+ <Message>.createMessageComponentCollector(…)
- <Channel>.createMessageComponentCollector(…)
+ <Message>.createMessageComponentCollector(…)
...