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 Plugin Documentation is not up to date anymore

Hi :) I just read in #@sapphire/plugin-api Methods Error that the plugin was reworked, could I request that the new usage is documented/adjusted in the guide? I am very confused on old vs new usage...

Dupliacte commands

When registering commands with Sapphire, it created duplicate ones on top of the old ones from legacy codebase. How can I delete duplicate ones so only the currently active (Sapphire generated ones) remain? Deleting all commands and re-registering them is also an option I can do, just not sure how

Freeze on await client.login()

```ts import './lib/setup'; import { LogLevel, SapphireClient } from '@sapphire/framework'; import { GatewayIntentBits } from 'discord.js';...

string-store & strings

I've been trying out string-store and it's a great utility, but it's becoming annoying to stringify everything (and it also makes my formatting look bad because a lot of times it forces prettier to wrap the lines). When I serialize a custom id, I have to do .setCustomId(store.serialize(Id.EditSomethingButton, ...).toString()), and when I just use a normal custom id, I have to do .setCustomId(Id.EditSomethingButton.toString()). I know this isn't a very big problem; should I just suck it up? (...

message kits

So I'm looking at the active sapphire bot and its dashboard and they have "message kits" that can change how the embeds look and such. I'm wondering if its just exclusive to them or is there away to can build something like this for myself. I'm using the template typescript version. I know I can setup centralized embeds for different categories, but I didn't know if there was a plugin already made for this, or would I have to create it myself ?...
Solution:
and @Xndo this would be a bot developer implementation which you would have to implement from your end, i dont think implementing this in the framework would make any sense

StoreRegistryEntries Augmentation

I'm finding it a little difficult understanding how to augment the interface, specifically the commands store because I have my own extended class from sapphire's Command, and I keep having to do as <Class> whenever I retrieve a command from container.stores.get('commands').get(commandName). How am I supposed to do it? Scrap the above. From what I can see each store is stronly typed and a new type can't be assigned. This would be confirmed when looking at skyra's codebase too because types are manually casted....

Re-registering Command Within Scope of chatInputRun

Hey all, In short, I've been looking for a way to re-register a command definition in a subcommand that allows an admin of a server to create a currency type (XP, SapphirePoints, etc., it's arbitrary). These currency types needs to show up in other subcommands for admin, therefore re-registering seems necessary to alter the choices presented for such fields. The only thing that works without restarting the client seems to be a call to this.store.loadAll()....
Solution:
I would first try doing it through discordjs' client.application.commands but if that doesn't suffice or you want to be lazy then I believe from the top of my head you can also just call .load() on the specific command as opposed to loading all because I'm pretty sure load all does just that but in a for loop. Other than that though, you are on the right track. Yours is a bit of an edge case honestly. What you can also consider is not limiting selection to options at all but instead providing an autoconplete. Yes autocomplete can be bypassed but you would handle that by checking if the input is valid and if it's not then asking for valid input through a string select menu. This is what I do @Dragonite as well. You can try /pokemon then type .. idk "pika" and it'll autosuggest Pikachu. But then if you type "/pokemon" and mash your keyboard and hit enter before the autocomplete populates you will get an ephemeral reply with a select menu with suggestions....

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