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

Precondition results

Can we use a different error class besides UserError in the precondition's error method? Might seem like a dumb question, but the last time I attempted it result couldn't unwrap the error...

Is it possible to add some sort of custom property to commands that can be checked in a precondition

I'm trying to make a precondition that will check for a role on the user, I was wondering if there is some way to add a property to a command, where I can check if it exists in a precondition, for example requiredRoles: ['ADMIN','MODERATOR']?

eslint config?

ive installed sapphire/ts-config and extended it but that wasnt working because it seems currently unsupported by eslint 9.x flat config requirement then i went to theeslint docs and copied their example config ```// @ts-check ...

Disable slash command in MP

Hello ! I don't understand how can I disable slash commands in DM. I test this in my command options: runIn: "GUILD_ANY",...

`ApplicationCommandType` TypeError

I'm attempting to create a context menu command: ```ts import { Command } from '@sapphire/framework'; import { ApplicationCommandType } from 'discord.js';...
Solution:
It's an issue with the types from discord.js, here's their FAQ that mentions this and the solution: https://discord.com/channels/222078108977594368/1320493963467296929...

extended property not autocompleting in vscode

i use esm and when i extend container.db = new Database(), the autocomplete not showing and always underlining in red color the db property.
No description

sapphiredev/examples

so I've got a quick question. Are all examples, such as typescript-complete and the other one ready to be used in production use or is it better to start one from scratch? Haven't used it once but wanna get some grasp of how it is. It looks so helpful given the fact it is pretty annoying to be setting up manually everything once again and yeah. Thanks!
Solution:
they are yes

Performance in interaction-handlers

Is there a performance penalty in sapphire for using many interaction handlers for different buttons (one for each button), or should I try to reuse some of them?
Solution:
Can confirm, unless your checks are slow or you have thousands of handlers, you’re not going to notice a performance impact

Testing Routes

Is there any example how to run the routes in Jest test? TL;DR I'd love to create some tests to make sure the response is correct in differents scenarios based on user authenticated...

Help with sappphire auth

i have problemms using the auth with sapphire
Solution:
if you do indeed have multiple outgoing requests they should also show up in the network tab

How to wait that the initialization of the ApplicationCommandRegistry is finished

Hi guys, is their away to wait for the completion of the ApplicationCommand registration? ```ts 2024-12-22 20:26:53 - INFO - Successfully logged in into Discord Connected to Redis for subscribing...

Does Custom Piece auto-loaded?

I am trying to develop a ReservationTask Piece using SapphireJS to perform a specified task after a certain time. First, I created a ReservationTask by extending the Piece class and then created a ReservationTaskStore to store it. In this case, I wonder if the ReservationTask Piece is automatically registered with SapphireJS. Also, if I add a custom Piece that inherits from this Piece, will it also be automatically added? I plan to refer to the following code frequently during development:...
Solution:
semi auto, you do have to configure the path of the store and add it to the store collection.

Stop sapphire from automatically loading pieces

I'd like to use sapphire's command class since I can adapt it more easily, however I want to prevent it from manually loading other pieces (like listeners). I remember there being an option for this but I pretty much can't remember so I'm asking here. P.S: I plan on loading commands manually, by calling this.container.loadPiece(), i just want to disable any type of automatic loading....
Solution:
Pass baseUserDirectory: null in your client options to disable loading, this is one of the steps at registering and loading virtual pieces.

What is the role of a Piece and a Store in SapphireJS?

From my research, it seems that a Piece cannot perform standalone actions. Instead, Pieces are stored in a Store, and developers retrieve them from the container's store to utilize them in other functionalities. Is this correct? I am looking for examples or related articles that explain the usage of Store and Piece, but the official documentation seems to lack such detailed explanations, so I am asking here....
Solution:
that is correct

Encountered error while handling an interaction handler run method.

Hello, I have encountered an error: ``` [ERROR] Encountered error while handling an interaction handler run method for interaction-handler "1_ActivateContractHandler" at path "C:\Users\diman\OneDriveДокументы\GNews_v2\dist\interaction-handlers\contract\1_ActivateContractHandler.js" DiscordAPIError[40060]: Interaction has already been acknowledged. at handleErrors (C:\Users\diman\OneDriveДокументы\GNews_v2\node_modules@discordjs\rest\dist\index.js:727:13) at process.processTicksAndRejections (c:\Users\diman\OneDriveДокументы\GNews_v2\lib\internal\process\task_queues.js:105:5)...

Use Prisma with SapphireJS

Hi, I saw in the Global preconditions guide you referenced this.container.prisma, which doesn't exist. I am new to Prisma, and I want to get started on using it with my bot, anyone have a guide on how to set it up?...

monorepo with sapphire

how would you go about installing a yarn or npm monorepo with sapphire bots?

Preconditions in Interaction Handler

Is it possible to use preconditions in the interaction handler? I was hoping to have preconditions work with my buttons as well 😁
Solution:
It is not, however, remember that preconditions are basically just glorified if else checks.

Difference with dev and prod > The application now has 0 global commands

Not sure what I'm missing here. When I run my dev command nodemon src/Bot.ts - everything works as expected, the bot is online and responsive, with 4 global commands. When I run my build command tsc - the build is successful...
Solution:
See the first big red block at the getting started guide https://sapphirejs.dev/docs/Guide/getting-started/getting-started-with-sapphire

text command triggered by mentioning bot (no command name)

I want to trigger a text command when the user mentions the bot, but with no command name. what is the best way to implement this?
Solution:
Add a listener called mentionPrefixOnly