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

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

I want to make a system about module command

I'm stuck right now, I only want 3 commands to be able to deploy globally, and in that there is 1 command to edit the modules, which will contain the commands. What I want to do is that the command to edit the module can automatically register a separate slash for that server. Can you help me?

Slash command autocompletion dynamic input options

I'm looking around the DiscordJS documentation and SapphireJS docs to see if there might be a way to add the ability to, essentially, have a user type a slash command like: /play input:<search terms> And when they are inputting the search terms, have options populate above like how some music bots do. ...
Solution:
Command#autocompleteRun can be async, which means you can execute a fetch HTTP request to retrieve the results and show them back to the user.

string-store not finding identifiers other than first in Schema on deserialize typescript

I am working on some new code for my bot and using the string-store utility. I've gone through https://discord.com/channels/737141877803057244/1303945790057746452 and https://discord.com/channels/737141877803057244/1303856829461168138 and have been able to get the system working with the steps in there. My schema is: ```ts import { Schema, SchemaStore, t } from '@sapphire/string-store';...
Solution:
Your store has 2 schemas, so when it deserializes a buffer, it can be one of the two. Compare the id or cast the value to the correct type to fix this.

Why my listener doesn't work?

Hello, i am trying to make a uptime checker thing. I'm currently just using a ready listener for test. main.ts ```ts import 'dotenv/config';...
Solution:
1. Which version of @sapphire/framework are you using? 2. What's your file/folder structure? 3. Did you use the CLI to generate your bot? 4. What's your main (CJS) or module (ESM) property in package.json 5. 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?...

my guild related listeners arent firing but my client ones are

pretty much just the title
Solution:
i just remembered that messageReactionAdd won't fire on uncached messages, unless u were to enable partials

Unexspected end of JSON input

Hey guys, I recently updated from API Plugin v6.1.1 to v7.0.3 and got into trouble with the new handling of request body. I try to extract the body of my request with const body = await request.readBodyJson();...
Solution:
You shouldn't read the body twice 😅

Updating paginated message pages while the handler is running

I'm trying to make a paginated message that can be updated after its creation. My command currently: 1. Responds with the paginated message with data from the database 2. Fetches new data from an API in the background...

JS Example has error with loading routes

I've downloaded the JS example from here: https://github.com/sapphiredev/examples/tree/main/examples/with-javascript The bot runs fine apart from a few issues with loading the routes ``` Error when loading 'C:\Users\Jacob\Downloads\sapph\src\routes\hello-world.js': TypeError: Cannot read properties of undefined (reading 'GET')...
Solution:
The second is because you need to install a build toolchain, see https://github.com/nodejs/node-gyp#on-windows The first... is because the code wasn't updated to Sapphire Plugin v7. If you don't need REST api plugin, just delete those files for now. If you do, then refer to the breaking changes, also we'd very much appreciate a PR ❤️ https://github.com/sapphiredev/plugins/blob/main/packages/api/CHANGELOG.md#sapphireplugin-api700---2024-11-02...

Precondition not triggering "chatInputCommandDenied"

I have setup the following precondition:
Solution:
Ah I also see where you're going wrong here. Yes you land on the breakpoint for this.error, however because you're using Array#forEach which accepts a callback function that returns void you're not actually returning this.error for the function chatInputRun but rather for the anonymous arrow function that is provided to Array#forEach. You can solve this by using for...of instead....

Sapphire keeps taking me in circles! Can't access my Dashboard.

Hello! I just added the Sapphire bot to my server yesterday, and I wanted to make a few edits. I headed over to the Sapphire Dashboard on my browser to log in, but I just keep getting taken in circles. I can no longer access my Dashboard. I've tried clearing my cache/cookies for the site. I've also tried logging in on another device with no luck. I'm stuck on the login page that says "You're currently logged in as _" It shows all of the servers that I operate underneath (photo attached). When I click on the server that I'd like to adjust, the page "refreshes" but then stays where it is. So frustrating! Any help would be greatly appreciated!...
Solution:
You seem to be asking a question related to the "Sapphire" bot, not the "Sapphire" framework. These are separate projects that share the same name but have no relation to one another. You may instead be looking for https://discord.gg/EXqShySz8h...
No description
Next