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

Precondition i18n

Per this example here https://www.sapphirejs.dev/docs/Guide/preconditions/global-preconditions is it possible to like use one i18n function for it to work for all them with the message or do I have to take special precautions and check which type it is?
Solution:
If so, no, but you don't send messages through the preconditions anyway. You to that through listeners. And you identify the identifier there then send the translated message. See https://github.com/skyra-project/skyra/blob/main/src/listeners/commands/messageCommandDenied.ts for an example.

Got this error when executing command /kick

I never got this error before, i edited my /kick command and after doing so i executed the command the command works but after like 1-3 seconds of executing the command it crashes and throws this error:
Solution:
seems like it’s coming from there
No description

How to add string options

i need help with how to add string options if i add then them the normal way ie: .addStringOption((option) => option.setname etc) it wont work...
No description

Error when using @sapphire/type

Error: Cannot find module '/workspaces/shim/node_modules/@sapphire/type/prebuild/type-node-v115-linux-x64-glibc-2.31/type.node'
Error: Cannot find module '/workspaces/shim/node_modules/@sapphire/type/prebuild/type-node-v115-linux-x64-glibc-2.31/type.node'
...
Solution:
use yarn instead of bun

Commands + Listeners not registering

My commands and listeners are not registering/running. I suspect its because I'm using tsx but am not sure what the best way to resolve it would be
Solution:

Delete Message Instantly

https://github.com/skyra-project/skyra/blob/main/src/lib/util/functions/messages.ts does the deleteMessageImmediately function in the file above actually delete the message instantly? Faster than doing <Message>.delete()?...
Solution:
it still calls message.delete but doesnt throw an error on error codes.

Listener run() signature

Feel like I'm missing something obvious.. how do I find out the correct signature for a run method of any given listener - they're different for each event. I'm sure there's an obvious way to get this, without trial and error and debugging to see what's available to it - where am I not looking? ```ts import { Events, Listener, ListenerOptions } from "@sapphire/framework";...
Solution:
The only thing you can do is extends Listener<typeof Events.GuildCreate> but that won't implicitly type the run parameters, it'll just error if you provide the wrong types. Sadly TS offers nothing better.

PaginatedMessageEmbedFields empty array

So im kinda confused with the docs and im always getting empty array's when im trying to setItems over an array. i logged already my output from the array and its just an double Object (as it should be afaik) when im accessing the content inside that Object i get my Output as i wanted it but for some reason the PaginatedMessageEmbed can't access it... am i missing something? Thats some of my code: ``` ...
Solution:
You're assigning the result of .make() to a different variable and then you call the original object's run. Change the last line to pages.run(interaction) or dont assign it to a different variable.

Issue registering command on a specific guild using guildIds

Hello, I am having some issues trying to register a slash command to a specific guild. I have this "dev" command that should be registering on one guild (my dev guild), for that im specifying the guild ID in the guildIds array in the registry options. I had an issue before were the command was being registered into both (global and guild) so it was showing duplicated commands. To revert that, I deleted every global slash command aswell as guild commands and let sapphire handle the registration o...
No description

Subfolders Inside Commands Folder

Can i put the commands inside subfolders in commands folder ? example command path : commands/public/ping.js...

Encountering Error `TypeError: emitter.getMaxListeners is not a function`

Happens as soon as I run the code. I am using ts-node so I have no idea if this is the reason why.
Solution:
I mean, using ts-node is like a minefield, it doesn't always behave as desired and most of the time it's more efficient to use tsc --watch + node . 😅
No description

Problem loading virtual pieces

If I go by file system mode, all commands & listeners get loaded. But if I go by virtual piece route, only 1 command gets loaded. Here is my repo - https://github.com/MRDGH2821/Discord-Ban-Utils-Bot/tree/rewrite-sapphire (rewrite-sapphire branch)...
Solution:
Solution: 1. Explicitly put piece name, there's no way to set it dynamically (unless you set it in a variable & assign it wherever needed) 2. Don't use virtual pieces...
No description

Am I doing this wrong? Message doesn't send for preconditions, but the precondition works FINE

It just says the usual "The application did not respond."
Solution:
you need to implement chatInputCommandDenied listener still wherein you can send error.message. Also see https://sapphirejs.dev/docs/Guide/preconditions/reporting-precondition-failure...
No description

Problem with loader file generator

generate-loader is generating a loader at unintended location with .js extension applied 🤔 Also I have nested listeners, so the paths for those are not getting generated porperly...
Solution:
Fixed it in v1.9.3 @MRDGH2821. I swear I encountered and fixed that bug before but it somehow slipped through the cracks. I swear I had it working when I implemented this.
No description

ChatInputCommand

How to know if a interaction comes from a slash command?

[EMPTY_MODULE] Error:

I’ve looked at some of the other posts that was also related to this issue and used those solutions but i still don’t have a solution, file:
Solution:
interaction-handlers should be its own folder, not nested inside listeners.
No description

Error Handling

[ERROR] Encountered error on message command "test" at path "C:\Users\cmart\Desktop\Discord Bots\Sapphire\src\commands\Developer\test.js" Anyway of removing these error messages if the type of the error is a string? I don't want this error showing up on console when I do stuff like, for example: ```js...
Solution:
I opened a PR to add an example

PaginatedMessage: refresh pages after setPages()

How can I update or refresh PaginatedMessage after use setPages()? Currently, I have to click next/prev button to refresh all pages....
Solution:
Sounds like you're trying to modify the pages after calling run. That is not what PaginatedMessage was designed for. Run should always be the last thing called.

NPM script stops working when tsconfig extends @sapphire/ts-config

My npm package has a simple build script:
"prebuild": "rimraf dist types",
"build": "tsc",
"prebuild": "rimraf dist types",
"build": "tsc",
...
Solution:
to your prebuild add tsconfig.tsbuildinfo, that'll probably fix it. It's the cache file for incremental builds which are enabled by the config.