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

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

ButtonBuilder setEmoji?

I tried searching for this issue but haven't found anything that could help.

Having trouble with reporting precondition failure

I am trying to send an error message when a person who isnt the bot owner runs the eval command but i cant get it to work I followed the docs and even copied the example bot but nothing seems to make the thing work. I tried to console.log error.message but that doesnt console.log either Precondition ```ts...

Mentioning application subcommands

Follow up from this: https://discord.com/channels/737141877803057244/1086724151429042246 Is there a way to mention subcommands too? I noticed that base subcommands cannot be mentioned, i.e. in a subcommand /a b you cannot mention using </a:id>....
Solution:
</[base name] [subcommand name]:[base id]>

Task is set to execute hourly but executes 3 times

I registered a task, that should run at :00 every hour. For some reason, it executes it 3 times tho, 1. at :00 2, at :02 and the 3. at :05 past...

messagecommand generated from CLI error

I just started out with Sapphire and i was trying to use the CLI to generate a messagecommand but ran into this error
Unable to resolve signature of class decorator when called as an expression.
The runtime will invoke the decorator with 2 arguments, but the decorator expects 1.
Unable to resolve signature of class decorator when called as an expression.
The runtime will invoke the decorator with 2 arguments, but the decorator expects 1.
...
Solution:
I just started out with Sapphire and i was trying to use the CLI to generate a messagecommand but ran into this error
Unable to resolve signature of class decorator when called as an expression.
The runtime will invoke the decorator with 2 arguments, but the decorator expects 1.
Unable to resolve signature of class decorator when called as an expression.
The runtime will invoke the decorator with 2 arguments, but the decorator expects 1.
...
No description

@sapphire/type installation script error

```cmd $ pnpm i Lockfile is up to date, resolution step is skipped Packages: +327 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...
Solution:
Okay, something odd happened, I ran pnpm add nodemon and it magically installed itself without error? I guess the solution is to install another package instead of running pnpm i

unknown interaction error

Is there a reason why I keep getting random unknown interaction errors? [2023-04-04 00:16:12] [ERROR] Encountered error on chat input command "translate" at path "/workspace/src/commands/basic/translate.js" DiscordAPIError: Unknown interaction [biit] [2023-04-04 00:16:12] at RequestHandler.execute (/workspace/node_modules/discord.js/src/rest/RequestHandler.js:350:13) [biit] [2023-04-04 00:16:12] at processTicksAndRejections (node:internal/process/task_queues:96:5)...
Solution:
Then add interaction.deferReply() before the async function and then reply with interaction.editReply(); Normal commands only can respond in 3 seconds and with deferred 15 minutes...

who to connect html to discord.js?

hi iam trying to connect html form and send data to the bot soo i can do an action with it, how to make it possible?

Messages are not being monitored

I've enabled loadMessageCommandListeners in the ClientOptions, as well as added the MESSAGE partial. The Message Content Intent is also enabled in the Discord apps dashboard, as well as added GUILD_MESSAGES intent in the ClientOptions. However, the bot only responds to commands prefixed with the mention. I've set the default prefix to !.
Solution:
lol, im dumb it should be MESSAGE_CONTENT intent in the options facepalm

Proper pnpm support

I keep getting
The inferred type of 'parse' cannot be named without a reference to '../../node_modules/.pnpm/@[email protected]/node_modules/@sapphire/result/dist/lib/Option/Some.js'. This is likely not portable. A type annotation is necessary.
The inferred type of 'parse' cannot be named without a reference to '../../node_modules/.pnpm/@[email protected]/node_modules/@sapphire/result/dist/lib/Option/Some.js'. This is likely not portable. A type annotation is necessary.
in any situation where I use ...

Set the precondition for all commands in a faster way instead of manually set for each command

Is there a faster way to automatically set a specific precondition every time creating new command than use the preconditions option in every command constructor?
Solution:
1. if it's a custom precondition (i.e. one you wrote yourself) set the position option to make it global 2. if it's not a custom precondition (i.e. a built in one) then extend the Command class and use object merging to set it on the custom base class to extend...

Sapphire not getting my commands

Every time i make a command it seems that sapphire doesnt care about them, i put my commands in the commands directory, I am using tsx for my runner (tsx uses esbuild)
Solution:
Every time i make a command it seems that sapphire doesnt care about them, i put my commands in the commands directory, I am using tsx for my runner (tsx uses esbuild)
No description

How to get infos about the current task?

I want to log things like taskid etc. what infos are there to work with and how do I get them inside of my task?

How can i start using bulkOverwrite

I was just curious on how I could start using BulkOverwrite to override slash commands?

Adding preconditions to a slash command?

Is there a way to add a precondition to an application command? I'm not sure if it works the same as the old chat commands or if I would have to hardcode them into each command.

mongoose listener not working

im trying to setup a mongoose listener for the 'open' event however saphire doesnt seem to catch it my best guess is i didnt specify the right emitter as my other listeners work here is a screenshot

TypeError: channel.isTextBased is not a function

I have a problem with Interactions: Since yesterday evening every button interaction results in an error as follows ```js /home/developer/Wishbot/node_modules/discord.js/src/client/actions/InteractionCreate.js:50 if (channel && !channel.isTextBased()) return;...
Solution:
I have a problem with Interactions: Since yesterday evening every button interaction results in an error as follows ```js /home/developer/Wishbot/node_modules/discord.js/src/client/actions/InteractionCreate.js:50 if (channel && !channel.isTextBased()) return;...

Can not resolve dependency sapphire

Hello, after todays NODE JS update, im having an issue with sapphire dependency, would you be able to advise me? thank you.

UserError listener not catching all errors

I am running an imported function in my command, and calling UserError in this file and when I do, it is not caught by the listener, and my bot crashes. Error Source: https://github.com/cosigyn/Clanware-V3/blob/master/src/mods.mjs#L229 Command: https://github.com/cosigyn/Clanware-V3/blob/master/src/commands/general/affiliate.mjs...