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

Problem since upgrading to latest sapphirejs and TS 5.0

After upgrading to the latest version of sapphire, it is raining errors like "ESM syntax is not allowed in a CommonJS module when 'verbatimModuleSyntax' is enabled." or "A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled.". I amended my tsconfig to this post.
Solution:
oh it seems like it worked to remove the module commonjs line. I will test this, and then close this.

What does sapphire's logger use on the backend?

Winston, pino, something else?
Solution:
console.log/debug/error/warn etc

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