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

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?

How can I bypass required user permissions?

I want developers to be able to bypass them I can probably override the parseConstructorPreConditionsRequiredUserPermissions method so it adds an extended/custom precondition but that's my last resort since it feels hacky...
Solution:
we dont have an option for that

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

I'm not receiving any Context Menu Command interactions

the command gets registered correctly and I've tried changing the bot permissions, adding/removing intents and also different code examples from the docs but none of them seem to work I've enabled trace logging to see if anything would show up but apparently not, loadMessageCommandListeners also doesn't change anything I'm using @sapphire/[email protected], [email protected] and also ESM but I doubt that's relevant lmk if I need to provide more details...

__importStar is not defined

Hey! I am using a star import in my bot but whenever I try to run the dev script, it gives me the following error: ``` const dotenv = importStar(require("dotenv")); ReferenceError: importStar is not defined...

Fake Message Execution

Is there a way to create a fake message and execute a command off of it? I want to use it for an execute command similar to Jishaku execute (for dpy) and was curious if it was possible. Thx

extend command

i'm unsure how to go about doing this but how do I extend Command so that its options also include a description usage and categories array

Converted to es6 module, commands not loading

INFO - Logging in
INFO - logged in
INFO - ApplicationCommandRegistries: Initializing...
INFO - ApplicationCommandRegistries: Took 0ms to initialize.
INFO - Logging in
INFO - logged in
INFO - ApplicationCommandRegistries: Initializing...
INFO - ApplicationCommandRegistries: Took 0ms to initialize.
then it's frozen....

Is there anyway to register slash command for guild and global separately.

I want to make a guild slash command i18n . each guild will have it own slash command language by register slash command per guild. Is there anyway to do it separate from global slash command register.