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

@sapphire/type does not work with Bun

Hello! I was trying to get my Sapphire application up and running on my server, however I was greeted with this error: ``` silver-wolf | $ bun src/index.ts silver-wolf | Error when loading '/usr/src/app/src/commands/utils/eval.ts': 17 | var publicField = (obj, key, value) => defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); silver-wolf | 18 | var getFilename = /* @PURE */ __name(() => fileURLToPath(import.meta.url), "getFilename");...
Solution:
Adding to this, @sapphire/type doesn't use Node.js' internals, it uses v8.h (see source code). Because Bun is built on JavaScriptCore (JSC) and not V8, we can't make the internal inspecting part available for Bun even with a Rust rewrite.

"The application did not respond" on bulkDelete message use

Hello, just built my first slash command, what I coded seems fair though the command doesn't seem to be registered. When writing down / I don't even see my bot appearing (only the built-in stuff). Does the code seem fair? I can't see any major mistake that would make it not register... ```js...
Solution:
More readable code : ```js async chatInputRun(interaction) { try {...

Sapphire not updating the command

I updated the command but it's updating it in discord and when i use it, it reply with a random reply but when i rename it it uploads but the old one still exists...
No description

weird behavior with args.*Result after updating to sapphire v5.3.1

Hello, I have this code (pls see screenshot) available as [p]base64 cmd, this same setup worked perfectly fine when I was on sapphire 5.2.1 but after updating to v.5.3.1 today weird issues like these are popping up. Did something change in @sapphire/result to introduce this change? because it feels like breaking. also I tried to check whats changed between @sapphire/result v2.6.6 ... v2.7.1 but it says 465 files changed and trying to browse it to figure out what changed makes chrome on my potato laptop hard crash, so can someone help me figure out around this issue? thanks....
Solution:
- if (getMode.isErr()) getMode = { value: 'decode' };
+ if (getMode.isErr()) getMode = ok('decode');
- if (getMode.isErr()) getMode = { value: 'decode' };
+ if (getMode.isErr()) getMode = ok('decode');
...
No description

Pieces Framework Inquiry

@sapphire/pieces Would the pieces framework work outside of a discord.js (or discord related) project? I'm looking to add a module framework for my Electron IPC functions....

@sapphire/plugin-i18next FallbackLng Error

🆘 Hi, here's the problem I'm having. 📌 Can you help me solve this problem ? I have a languages folder with an en-US folder and a fr folder inside....

SchemaStore narrowed to never

Currently trying the example in the readme, not sure if this is a vscode bug but it's narrowing the store's type to never: ```ts import { SchemaStore, Schema } from "@sapphire/string-store"; const Id = {...
Solution:
aka ```ts const Id = { AgeUpdate: 0, StrengthUpdate: 1,...
No description

how to pass variables from one interaction into the next?

this is my current workflow concept: 1. user runs slash command 2. modal pops up, user enters email 3. bot validates email against regex, API service 4. if no account is found on service that matches the email, a message is provided with the option for the bot to create an account on the service on behalf of the user using the provided email...

@sapphire/plugin-api Methods Error

🆘 Hi, here's the problem I'm having. 📌 Can you help me solve this problem ? #️⃣ My code :...
Solution:
This was completely changed with @sapphire/plugin-api@v7

Google Cloud Run not logging into the bot

Hello devs, I am using Cloud Run to run a Discord bot docker image built like this: ``` 1. Build...
Solution:
Solved: the problem was not related to Sapphire. I had to allocate a persistent CPU...
No description

interaction.channel is null in slash commands

Hello. I'm sure this is an ID10T issue, but interaction.channel is null for me in my slash commands being used in DMs for my user bot. Am I missing something, like an intent? I'm literally only trying to check if the channel is DMs / DM group or if it's in an NSFW guild channel. Thanks.
Solution:
if you want to do a nsfw command, i recommend you to use nsfw property in builder https://discord.com/developers/docs/interactions/application-commands#create-global-application-command

[email protected] type level problem

just curious what happen here, is my Option usage is wrong? i wanna check is Some is null for retry, because i can't use async inside match or map...
No description

Context Menu not working

I was changing a command so both the message and context menu version of the command were in the same file, however the context menu part doesn't work, and instead returns the "The application did not respond" error. The message version of the command works fine. Relevant Code: https://pastebin.com/Ciqk03at...
Solution:
Add a contextMenuRun to the precontion that always returns this.ok()

Scheduled Task Does Not Remove on Fail

I have a listener that creates a new task when a member joins voice if a condition is met, and removes it when they leave. The task itself executes perfectly fine, however, if it errors it will not remove the task. I do handle users leaving the channel in the voice state code, however if the bot has downtime and the member leaves during it, it'll have to error out. I'm not entirely sure if this is intended behavior and I'm just understand the use-case wrong, I checked documentation for bull and it seems like it should remove on error, but it does not....
Solution:
Well the plugin is just a fairly tiny wrapper around the bullmq library and that is a bullmq option. So it only counts when it fails on the bullmq side. This could be when it fails to send from redis to the client for example.

Precondition not running

I've taken this from a working template project of mine, but I can't for the life of me figure out where this message is coming from.. it works in the template project, and checking the docs I can't see what I'm missing... I'm missing something stupid right? It's sitting in a preconditions folder, just the same The log message is not my own. 2024-11-02 22:59:01 - [WARN] preconditionUnavailable - The precondition "OwnerOnly" is not available. ...
Solution:
```ts declare module "@sapphire/framework" { interface Preconditions { OwnerOnly: never; }...

Dilemma 😫

I’m debating whether to handle audit events in a single file or break each event out into separate modules, aligning with the Sapphire Framework’s philosophy. I prefer to keep my code compact, even though I know it won’t significantly impact the end result, it’s just something I always spend extra time on for my own satisfaction. Now, my main question is whether opting for a single file will compromise performance compared to the modular approach that Sapphire advocates.

cant declare container items

cannot declare prisma as a child of container
No description

Paginated Message actions issue

I’m working with a PaginatedMessage in my command, where I display entities and use a dropdown (select menu) for users to choose an entity from the current page to view its details. However, if there are fewer than 10 entities, the dropdown doesn’t respond when selecting an entity, as if the command isn’t recognized as a PaginatedMessage. I suspect this may be because only one page is created, so the actions aren’t registered. I saw the setPageActions() method in the docs, could it help here? I've included screenshots: one with fewer than 10 entities (not considered as a Paginated message) and one with more (Paginated message). Thank you for your help !...
No description

Space separated arguments

Hello, I've created a custom messagePreParse that allows spaces as separators and it ended up parsing options and flags way faster than default while still providing me the info I needed.
After testing and finally feeling comfortable with it, I continued exploring Sapphire and added the subcommands package, quickly realizing they weren't compatible, as Subcommand's PreParseReturn only accepts types that extend from Args and mine would return a different (simpler) kind of object. So I've been dealing with this for a few days and I'm trying to figure out what would be the optimal approach as Lexure doesn't support spaces as a separator for options (I think?)....

New component under a PaginatedMessage

Hello ! I want to add a new component under my PagniatedMessage. This PaginatedMessage is a list embed that represents entities of a model. The user is invited to chose a row to edit via a select menu under the embed. The select menu is successfully added when the embed shows but disapear when I change page. I would like to know how to make my dropdown list refresh on every page change, is there a listener or something like that that can handle this? Here is the code of the listEntities method : ```javascript protected async listEntities(interaction: CommandInteraction<CacheType>, page: number) {...
Solution:
I think you want to use actions
No description