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

Would there be a way to make a command list?

How would I make a command list, for example you would use !help (or !help <commandName>) (example message)
Commands...
Solution:
Look at some of the bots that use sapphire (for example @Skyra ) but in shot you get the data from the container which gets access to the stores. How you want to parse and format that data is up to you. We won't be hand holding all the way to making the command because at that point we may as well write your bot for you (which would be a paid comission)

Clear Command Cache?

Since the other one removed his message... How to clear the cache using Sapphire?
Solution:
You should set add this line to your index file before you log in, which will overwrite all commands each time. ```ts import { SapphireClient, container, ApplicationCommandRegistries, RegisterBehavior } from '@sapphire/framework'; ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(RegisterBehavior.BulkOverwrite);...

InteractionHandler Buttons

I have a problem with my buttons. Somehow they don't work... I guess it's something easy, but I can't figure out what it could be. The buttons are in a folder named interaction-handler/Buttons The error I am getting is: ``` [ERROR] Encountered error while handling an interaction handler run method for interaction-handler "CancelSetup" at path "C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\src\interaction-handlers\Buttons\Setup\CancelSetup p.ts" Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred....
Solution:

ValidationError: Expected a string primitive

```ts C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules@sapphire\shapeshift\src\validators\StringValidator.ts:73 return this.ip(6); ^ ValidationError: Expected a string primitive...
Solution:
I fixed it, my dev had accidentally removed the .setLabel().

Need help for ContextMenuCommand

I have the below code: ```ts import { PaginatedMessage } from "@sapphire/discord.js-utilities"; import { Command } from "@sapphire/framework"; import { config } from "../../utils/config";...
Solution:
@Jarvo
- public override async contextMenuRun(interaction: Command.ContextMenuCommandInteraction) {
+ public override async contextMenuRun(interaction: UserContextMenuCommandInteraction) {
- public override async contextMenuRun(interaction: Command.ContextMenuCommandInteraction) {
+ public override async contextMenuRun(interaction: UserContextMenuCommandInteraction) {
...

How to use sapphire framework decoraters plugin

I saw a youtube tutorial for making a discord bot using sapphire framework in which the person used decoraters to make command but when i tried i am getting this weird error.
Solution:
Are you using "@sapphire/ts-config/decorators" in your tsconfig.json? Else, please show the aforementioned file. This error comes from using ES decorators rather than the legacy ones.

check if message starts with the prefix

how can I check if a message starts with the bot's prefix? Including the bot's mention
Solution:
Seeing as this is a follow up from your previous post and you do not have access to the command context you'll have to parse it out manually ```js const possiblePrefixes = ['!', '<@PUT_YOUR_CLIENT_ID_HERE_FOR_THE_MENTION>', 'etc']; const msg = {...

Get command used with a message object

Is there any way to know which command was used only by having a message object?

Duplicate identifier "Preconditions" when module augmenting "@sapphire/framework"

Please see screenshot
Solution:
unfortunately, the type keyword cannot be used. instead, it should be an interface because it will merge the content with the pre-existing interface
No description

Object literal may only specify known properties, and 'tasks' does not exist in type 'ClientOptions'

Hello there, I created a new project with sapphire new, using the minimal template. I'm trying to add the @sapphire/plugin-scheduled-tasks plugin. Following the doc, I use the npm install command and I added the register in the setup.ts....
Solution:
Interesting I think this happens because tsup outputs the file as .d.ts for CJS instead of .d.cts because it works just fine when using ESM For now if you add a line import '@sapphire/plugin-scheduled-tasks'; then it's fixed @Pandraghon pinging @vladdy here as well for reference...

Subcommands Refusing to work for anyone but me?

I have a command called lm and card which is in a leveling module, and these are the only subcommands in the module and they dont seem to work for anyone else but me. They were working a few days ago, was there a change that checks for bot owner permissions?
No description

Unknown Interaction

For some reason whenever my bot reboots, commands that clearly exist will error with “Discord API Error: Unknown Interaction”. The strange part about this is that it will often execute the command and then error. Is there some way to avoid this? It has also randomly happened on times that wasn’t after a reboot as well.
Solution:
seems to be working so far? nobody has reported encountering that issue recently so I’m going to assume deferring the reply fixed it.

Interaction handlers problem

hello, I have a problem when creating modals interaction, always get weird error logs (attachment 2) I don't know, what should I do? i need to create some registration sections (which is i copy from djs-docs for testing), when user execute command example: /register will show the embedded button, the button is fine, inside button(interaction handler) is the modals code (attachment 1)...
Solution:
Includes will be fine just make sure to return this.some as well. In fact better to do if(condition) return this.some() so you don't have a negated if condition.

Weird type error

```ts TS2345: Argument of type 'PieceContext<keyof StoreRegistryEntries>' is not assignable to parameter of type 'LoaderContext'. Types of property 'store' are incompatible. Type 'ArgumentStore | CommandStore | InteractionHandlerStore | ListenerStore | PreconditionStore' is not assignable to type 'InteractionHandlerStore'. Property 'run' is missing in type 'ArgumentStore' but required in type 'InteractionHandlerStore'....
Solution:
Change PieceContext to LoaderContext

How to use "and" & "or" with preconditions?

The Guide does not have any examples of this, so Im wondering how I can achive this. Having one of multiple preconditions needing to match Having multiple preconditions needing to match...
Solution:
should be [['AdminOnly', ['ModOnly', 'OwnerOnly']], 'InVoiceChannel']; for - AdminOnly - AND ModOnly OR OwnerOnly - AND InVoiceChannel ...

Proper way to setup ESLint

what's the proper way to setup ESLint? I'm attempting to look at the github repo for gemboard and I am unable to figure it out by looking at the configs.
Solution:
gemboard has it in the package.json but you can also just create an eslintrc file. See https://eslint.org/docs/latest/use/configure/ for more info.

how to make message when command is in cooldown?

hey, so my default defaultCooldownDuration inside my Client is 4000ms(4 seconds), but when i run the command multiple times it won't respond because it's in cooldown, i just want to send a single message saying the bot is in cooldown, how an i do that?
Solution:
Implement messageCommandDenied / chatInputCommandDenied / contextMenuCommandDenied https://www.sapphirejs.dev/docs/Guide/preconditions/creating-your-own-preconditions

How to push incomplete .env file to repo?

https://github.com/sapphiredev/gemboard/blob/main/src/.env -> Wondering how this environment file is easily pushed with the token removed (i assume) automatically. Is there a hook/gitignore to setup to automatically remove specific tokens from the environment file or is there a separate .env.local file that is excluded from the repo?
Solution:
There are separate env files, but basically you can use .env.development.local for development tokens/secrets, and .env.production.local for production ones. They're not pushed because .gitignore: https://github.com/sapphiredev/gemboard/blob/main/.gitignore#L24-L27 The reason why the extra files work (when dotenv wouldn't load further than just .env) is because the project uses @skyra/env-utilities (dependencies in package.json), which loads them, more information on the package's README....

Command not registering

for some reason, this command is not registering and is registered on parent file, I am doing something wrong?
No description