sapphire-support
discordjs-support
old-sapphire-support
old-discordjs-support
old-application-commands-and-interactions
Question to Plugin i18next
I would like to start using @sapphire/plugin-i18next.
Can i fetch language files from a another repository (or from my own npm module)?...
Solution:
Both yes if you set the path accordingly.
Slash Command Decorator
is it possible to use
@sapphire/decorators
, to make slash commands?Solution:
the library exports no decorators for it so you'll have to write your own, it is possible to use decorators in general to register slash commands though.
eslint autofix problems
Hello, i started using
@sapphire/eslint-config
for my project.
Now i would like to solve these problems.
The most erros is because explicit member accessibility.
...Solution:
no, eslint rules are autofixable only if they provide auto fix functions. These rules simply do not. That's also nothing to do with the config, the config just enables/disables rules. Those rules are provided by the @typescript-eslint/eslint-plugin package (the official eslint plugin for linting typescript files).
Notably you can see which rules have auto fixers here for the eslint base and here for @typescript-eslint...

Error [UNLOADED_PIECE]: The piece 'ready' does not exist.
Hello !
On this code :
```js
import { Listener } from "@sapphire/framework";...
Solution:
you can set a name for the events, so you can name them differently but you can set the "event" property the event you need still
that way you can have multiple listeners for a single event...
Error please help
```ts
import { ApplyOptions } from '@sapphire/decorators';
import { Command, RegisterBehavior } from '@sapphire/framework';
import { send } from '@sapphire/plugin-editable-commands';
import { Subcommand } from '@sapphire/plugin-subcommands';...
Are command instance recreated every time someone use the associate slash command ?
Hello
I was wondering : imagine i have a simple ping slash command who return "pong". Will sapphire recreate an instance of my Ping class (who register the command) every time do /ping or not ?...
Solution:
From my understanding; No, they're created at load time and then just saved to the command store and ran through that
Promise error sometimes on load - sapphire.js framework
Hey,
Whenever I am starting my bot within a docker environment, I am getting this error sometimes;
```2024-04-22 12:04:51 - DEBUG - ApplicationCommandRegistries(BulkOverwrite) Overwriting global application commands, now at 0 commands...
Caching Problems
Hey, i have some problems with caching, on discord.js they sad
All Guilds are cached if you have the intent, and the client is ready
.
While using intents like GuildMembers
& Guilds
.
i dont know if it fits into this forum, i tough because sapphire initates the listeners....
...Some questions
Hello, I'm new Sapphire and I don't really know how to do the followings.
Right now I have 2 issues:
1) I'm trying to understand how could i send an error message when for example someone tries to reuse the /apply command in a timeframe of 30 seconds, right now it will say "the application failed to respond", but i'd like to say something like "you're in a cooldown right now!"
and
2) I'd like to understand how collectors really work, what I want to do is when someone answer a question it will send the next one immediately and at the end will send to the user every question+answer...
Solution:
1) See https://sapphirejs.dev/docs/Guide/preconditions/reporting-precondition-failure
2) That's DiscordJS realm, not Sapphire. That said, if you're running a collector inside a slash command you should defer the reply first because otherwise you'll always exceed the 5 second timeout during which you have to reply as per Discord API restrictions. Furthermore, instead of using a message collector you should use slash command options or modals with text input fields, that too is DiscordJS realm (with a bit of https://sapphirejs.dev/docs/Guide/interaction-handlers/what-are-they in case of the latter)...
Sapphire command not recognized
I'm trying to install and use sapphire CLI but doesn't matter if I use NPM or Yarn 4.1.1, when I install it and try and run
sapphire -v
I get this backSolution:
You can only call it that way if installed globally, which yarn berry (V2+) doesn't even do. Run it with
yarn sapphire
/ yarn dlx sapphire
instead. Or install it globally, how depends on your package manager (GIYF)
API Plugin Prefix
Hey all, for some reason my prefix isn't applying on the data paths
This is my env file:
```
API...
Solution:
disregard, it seems that it was due to something local, I reinstalled all the node_modules and the prefix worked correctly.
Task was not found | plugin-scheduled-tasks
👋🏿 I'm getting "
[ScheduledTaskPlugin] There was no task found for "task_name"
" error for all my scheduled tasks. Sometimes they run successfully but mostly they giving me this error.
There is the code of how i'm declaring task:
```ts
import { ApplyOptions } from "@sapphire/decorators"...Solution:
you should use a different logical redis database for every bot then
Can't load subcommand
Hello, i'm trying to update to the latest djs and sapphire versions (from djs v13 and sapphire v3) and I have this structure for a subcommand where I have a file for each subcommand and a index where I declare and import them, before updating sapphire it searched all the files in the folder until it found the index, now it seems it only checks the first file (add) and doesn't load the subcommand correctly. Is there any way to fix this without having to change the structure and declare all the subcommands in one file?
Error:
```Error when loading '/var/home/vicente/i/AnnounceIt/dist/src/commands/announcements/add.js': Error [EMPTY_MODULE]: A compatible class export was not found. [/var/home/vicente/i/AnnounceIt/dist/src/commands/announcements/add.js]
at _LoaderStrategy.load (file:///var/home/vicente/i/AnnounceIt/node_modules/.pnpm/@[email protected]/node_modules/@sapphire/pieces/dist/esm/lib/strategies/LoaderStrategy.mjs:63:13)...
Solution:
That does not follow the structure for the command nor subcommand loader of sapphire or plugin-subcommands. If you want your subcommnands to be their own files with plugin-subcommands then
1. define them in the root command
2. import functions from other files
3. make sure those files start with a
_
symbol (i.e. _add.ts
) so sapphire skips them when loading
3. call those functions in the appropiate methods...
multiplie registered handlers
Hi, is it better to split for example the button interactions for different buttons to different files?
Or does it have any complications with the general performance?
e.g. if i put everything in one file and fire functions to other files
is that better? or does that make no difference...
Solution:
Makes no difference
TypeScript Check
Hey. The code works but I am curious if there is any way to do a better coding job like cleaniness etc. Thanks in advance!
```ts
// © Sympact06
...
Variable parameter type based on the previous variable
I want to add a 'parametric'
set
subcommand to one of my commands
For that command the values can be user, role or a string. Can I somehow change the option type (for example use addRoleOption
instead of addStringOption
) based on the value of the type
option?
```...Solution:
I think this is possible if you use Auto complete
If I'm correct, Autocomplete interaction should be able to give you values of previously filled parameters, which you can use to dynamically present values...
create a command that has spaces as one arg
for example, i would want a command with multiple spaces for each arg, such as
!command <argwithspaces1> <argwithspaces2>
, or even using seperators like |
i just dont know where to start or if its even possible at all ( i tried using args.repeat and args.nextMaybe but that didnt work at all )...