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

Passing data from one handler to the other

Say I have a Modal Submit Handler and then inside that handler, I create a button for a new reply, and when pressing that button, is there a way I can pass the data received from the modal to the next handler (in this case the Button Interaction Handler) Thanks in advance 🙂...
Solution:
Discord API offers no such option. The only thing you can do is compress it down to a very tiny string and pass it through the custom ID. For example: https://github.com/favware/dragonite/blob/5fb8956c075f4b9b63b8bc5ab47bb89531ce74ed/src/lib/util/utils.ts#L18-L54

Absolutely nothing happens with basic text command

I followed the Getting Started and setting up a basic command steps to no avail, I simply see 'took 0ms to initialize' and running '@<the bot> ping' does nothing. main is set to dist/index.js and I'm using TS if that affects anything.
Solution:
- Which version of @sapphire/framework are you using? - What's your file/folder structure? - Did you use the CLI to generate your bot? - What's your "main" property in package.json - 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?...

Slash command and Unknown interaction

Hi team 🙂 I have a slash command with an action row of buttons, the command is like a personality test, it sends an embed message with a question and each time you click a button to choose an answer (A, B or C) I update the embed with the next question (up to 6 questions). It works all fine itself, but if the User uses the slash command again without finishing the current test, the bot crashes with the following error rawError: { message: 'Unknown interaction', code: 10062 } whenever the user tries to click on a button of any of both messages. For me looks like somehow the ActionRow is not correctly attached to the Embed (doesn't make much sense since I create the actionRow inside chatInputRun method every time, so it should be correctly scoped). I can provide more information if needed, can someone help me? 🙂 ❤️...
Solution:
Solved, just in case someone faces a similar problem in the future, I was attaching the component collector to the channel instead of the message from the interaction.
- <Channel>.createMessageComponentCollector(…)
+ <Message>.createMessageComponentCollector(…)
- <Channel>.createMessageComponentCollector(…)
+ <Message>.createMessageComponentCollector(…)
...

Create locale slash commands

how can I create a team not globally but locally for one server? I can't find such an option.

create modal

im super new about djs and sapphire. for newbie sapphire is more easier than vanilla djs thats why i picked sapphire. i just checked docs and i find out how to create modals but idk how to use them can someone give example of code or example usage of modals...

Sapphire CLI error

I'm trying to create a bot using the command, but an error pops up.

Cant find the template

.sapphirerc.json ```json { "projectLanguage": "ts", "locations": {...

on ready messages

is there any chance to disable "commands initialized" message on startup ?

Argument of type '"Staff"' is not assignable to parameter of type 'SimplePreconditionKeys | Simpl...

Error ```Error when loading 'C:\Users\User\Desktop\Bots and stuff\Gir-Unit V2\src\preconditions\ServerOwner.ts': src/lib/structures/commands/GirCommand.ts:95:26 - error TS2769: No overload matches this call. Overload 1 of 2, '(keyOrEntries: SimplePreconditionKeys | SimplePreconditionSingleResolvableDetails | PreconditionContainerArray): PreconditionContainerArray', gave the following error. Argument of type '"Trainee"' is not assignable to parameter of type 'SimplePreconditionKeys | SimplePreconditionSingleResolvableDetails | PreconditionContainerArray'. Overload 2 of 2, '(entry: PreconditionSingleResolvableDetails<keyof Preconditions>): PreconditionContainerArray', gave the following error....

Autocomplete `interaction.commandName` when used in a subcommand

What will be the contents of interaction.commandName in an autocomplete interaction handler when the invoking interaction came from a subcommand or a subcommand in a group? Is it just baseCommand subCommand and baseCommand group subCommand? On a similar note, does interaction.commandId change for each subcommand?
Solution:
So is the commandName property on the interaction that gets passed into the interaction handler just the subcommand name then or is it the parents? At this point, you've said both.

Disable And/Or Change Listeners Directory

Is there a way to change the default name of the listeners directory? If not, is there a way to completely disable automatic registration of the listeners? If there is, how do you register them manually?...
Solution:
In regards to changing the default name of the listeners directory, you will need a file called .sapphirerc.json and in there put this: this is just an example ```json...

TypeError: Cannot read properties of undefined (reading 'write')

```js \testing-forbidden\node_modules@sapphire\framework\dist\lib\utils\logger\Logger.js:27 this.write(ILogger_js.LogLevel.Error, ...values); ^ ...
Solution:
Actually I figured it out, ```ts const result = await model.create(document).catch((error) => { container.logger.error(error); });...

Dynamic route not working

I am currently utilizing the plugin-api with the following versions: - @sapphire/framework": "^4.2.2 - @sapphire/plugin-api": "^5.0.2" ...
Solution:
Okay! It started working after deleting the node_modules folder and reinstalling.

Error When trying to getString.

I'm in the process of updating djs 13 to 14. - "discord.js": "^14.9.0", - "@sapphire/framework": "^4.2.2", ...
Solution:
I'm in the process of updating djs 13 to 14. - "discord.js": "^14.9.0", - "@sapphire/framework": "^4.2.2", ...
No description

Slash Command User Arg Always Failing

I've been following the guide on how to create slash commands and I realized that whenever I attempt to run my command and enter in the user argument, it tells me the user is not valid. I've even tried this with the example command on the guide, so it doesn't seem to be something wrong with my code. Here is the code used: https://hastebin.skyra.pw/iyepoxidaw.ts (this is from the guide) Here is what it looks like when I attempt to run:...
Solution:
Seems you have to add the #0001 (or whatever tag) to the end of it. Kind of weird it doesn't automatically do that. Anyway. Solved.

check if commands initialized

is there a way to check if commands initialized or not
Solution:
is there a way to check if commands initialized or not

Slash and message commands.

Can I make a slash command and a message command in the same archive?

Whats the difference between the different imports?

Some packages reexport things from djs for example. What is the best practise to use? And whats the difference?...
Solution:
discord.js only exports a type which is an alias for string. @sapphire/snowflake is a TS implementation of the snowflake system. They are 2 completely different things. (also you could've found this out by checking the djs and sapphire docs)...