Sapphire - Imagine a Framework

SIA

Sapphire - Imagine a Framework

Sapphire is a next-gen object-oriented Discord.js bot framework.

Join

sapphire-support

discordjs-support

old-sapphire-support

old-discordjs-support

old-application-commands-and-interactions

'Can't find the template.' on a template listed in the docs

When running sapphire generate buttoninteractionhandler customRole I get the error Can't find the template., however, https://www.sapphirejs.dev/docs/Guide/CLI/generating-components lists buttoninteractionhandler as a component.
Solution:
Update your globally installed @sapphire/cli making sure sapphire --version returns 1.6.1.

Issue when running mutiple bot instances on the same redis db with the scheduler plugin

I have currently 3 bots that all are executing the same code. They have a schedule that triggers every day at 0am and are using the same redis db. I recently discovered, that sometimes, the execution of the scheduled task is not executing and I was wondering if this cuold be connected to the multiple bot instances that a are connected to the same redis db....
Solution:
If so then yes. You should configure them to use different databases. Bullmq doesn't use any particular unique identifiers for its keys.

Plugin subcommands: "No subcommand was matched with the provided command."

I configured my subcommands like this: ```ts [ { name: "requester",...
Solution:
actually this also works pretty sure:
chatInputRun: (chatInputRun: Subcommand.ChatInputCommandInteraction) => this.chatInputSet(chatInputRun)
chatInputRun: (chatInputRun: Subcommand.ChatInputCommandInteraction) => this.chatInputSet(chatInputRun)
...

Application Data is null

So, I'm trying to get the owners of my application (for a team-members-based precondition for stuff like eval) but this.container.client.application has most of the data as null. It gives me the ID, flags, and that's about it. Is there anything I need to do to get that to show? Sorry if this is a stupid question it's been a while since I've worked with discord bots...
Solution:
@hyperfirers firstly, this is a discord.js question, not related to the sapphire framework. Secondly, you need to fetch the application before accessing the ClientApplication properties and methods. ```js const app = await <Client>.application.fetch();...

I need help to unistall sapphire because i just downloaded in vscode with knowledge abt it

i probably shouldn't have installed it without know what it is rlly is and now i keep getting errors in my code

Error listeners

Which listener catches this (image)? I have MessageCommandError and ChatInputCommandError listeners and neither one gets a log, I don't even get anything in the console. In addition, there are also MessageCommandDenied and ChatInputCommandDenied listeners...

Question about container in shards

Is there a way to fetch container values from another shard? I have a bot that stores data in a collection that is defined in the container, and I have a command that counts how much data is stored in this collection and the result is different between the shards

Combine Precondition and object available on the Command

Not sure if I've put that the right way, but I'm sure that the example will make some sense. I have this precondition that works. ```ts export class OnlyAlive extends Precondition {...

BulkOverwrite usecase

I'm trying to use BulkOverwrite to let sapphire handle all my commands but whenever I start the bot sapphire recreates some old commands which I already deleted. As far as I understand it BulkOverwrite should only register commands which are inside the project and not already deleted commands which are cached by discord Am I missing something or does BulkOverwrite work differently then I think?...
Solution:
delete your dist folder and recompile. TS will never delete files when the source TS files are deleted.

Need help persisting interaction data between consecutive interactions in Sapphire

Description I'm currently working on a project using the Sapphire framework and I'm facing an issue with persisting interaction data between consecutive interactions. I would appreciate any guidance or advice on how to solve this problem. Current Setup - I have a slash command registered in Sapphire that makes a userSelectMenu....
Solution:
There are no real best practises but your options pretty much boil down to using a cache of sorts. Either in memory by exporting some object, or a Collection (import { Collection } from 'discord.js', which is just an extension of native Map btw) or externally through a fast caching service like Redis. Either. way they are all key/value storages so keys will be customids/snowflakes/etc whatever you can use to identify later, and values whatever data you want....

When do I need the runIn Option?

Do I also need it when creating only slash commands?
Solution:
that's your call as to whether you want to lock the slash commands to specific channel types or not

Cooldown

Is there a way to make the command run once a day at a fixed time? How can it be used again after 12am?

Setting autocomplete options based on other option's value

I'm trying to make it so one autocomplete option (type)'s choices are based on the value of another option (category) within the same command. When I first set the value of category - which is a non-autocomplete string choice option - and I move to the autocomplete option type it successfully populates its choices according to the value of category. However, when I go back and change the value of category to something else, then move to the type option, the proper corresponding choices only populate correctly if I type at least one letter. If I do not, it populates it with the previously set of choices, corresponding to the first value set for category. I've attached a GIF that will hopefully help understand my issue. Thank you!...

autocompleteRun for sub commands

Is it possible to setup a autocompleteRun for specific subcommands similar to how it is done for chatInputRun?

Modal Validation Error

```js const { InteractionHandler, InteractionHandlerTypes } = require('@sapphire/framework') const { ModalBuilder, TextInputStyle, TextInputBuilder, ActionRowBuilder } = require('discord.js') module.exports = class extends InteractionHandler {...
Solution:
FYI, you can chain builder functions. For example, you can turn: ```ts const textInput = new TextInputBuilder() textInput.setCustomId('inputOne')...

Get the value that was attempted to be parsed in an Arg

Hiya folks, I have the following code, where I determine if the arg is either of my custom type (working), or if it's a server member. If it is neither, I want to throw out an error that I can handle, but as part of handling that error, I'd like to know the value that was attempted to be parsed. ```ts...
Solution:
Hiya folks, I have the following code, where I determine if the arg is either of my custom type (working), or if it's a server member. If it is neither, I want to throw out an error that I can handle, but as part of handling that error, I'd like to know the value that was attempted to be parsed. ```ts...

Make commands register when i run a command like `!sync`

Hi, I used the CLI to generate a project and noticed it syncs everytime a file changes. I have autosave enabled so this will get ratelimited pretty fast. Is there a way to make it sync slash commands when I run a command (and automatically use all the registerApplicationCommands )? Also wondering if there's a way to make all commands "guild" commands instead of having to give guildIds every time I register...
Solution:
Sapphire offers no built-in commands but you can leverage https://www.sapphirejs.dev/docs/Guide/commands/application-commands/application-command-registry/advanced/registering-application-commands-outside-a-command to implement a system like that yourself. As for guildIds, you can just do ```ts // somewhere...

confused

when i make the file extension to js it gives me 5 error and says the file should be in TS extension which i did but when i follow the guide now it gives me a new error

Is it possible to edit the default message returned by "preset preconditions"?

For example, the precondition set by <CommandOptions.requiredClientPermissions> returns I am missing the following permissions to run this command: Manage Channels as the <UserError>.message parsed in the ChatInputCommandDenied listener, but I'd like it to return something else.

Question

Hey! What is the difference about sapphire and discord.js? Or what is sapphire? I read the docs but i dont understand