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

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)...

Handling deletion of all guild specific slash commands with BulkOverwrite

I've been using BulkOverwrite to manage slash commands for guilds and use the ApplicationCommandRegistryRegisterOptions to specify an array of guildIds to create guild specific commands with registerChatInputCommand. This works great as long as I have at least one guild specific command for a guild. The issue is when II remove a guild id from all the command ApplicationCommandRegistryRegisterOptions then it won't overwrite anything in that guild and so it doesn't delete the removed commands. Below I've included an example of two commands. Assume that previously both commands were registered for guilds ['111','222','333'] specifically. If I make an update to remove guild '222' from the Help Command and guild '333' from both the Ping and Help Command, then guild '222' will properly delete the Help Command, however guild '333' will not be updated and keep both the Help and Ping Command....
Solution:
Sapphire doesnt handle deletion of commands, not with bulk nor anything else. You'll have to use the DiscordJS methodologies for that. Alternatively you can use https://slash-commands-gui.androz2091.fr/settings...

User counts

Is it possible to get a semi-accurate / approximate user count without fetching all users / servers when trying to update it? I've tried: - client.users.cache.size (but this does not have all users included and i don't want to client.users.fetch() a lot) - Fetching every guild and using guild.approximateMemberCount while removing duplicates...