Sapphire - Imagine a Framework

SIA

Sapphire - Imagine a Framework

Welcome to the Ruby Discord server! Finally split off from the Sapphire bot.

Join

sapphire-support

discordjs-support

old-sapphire-support

old-discordjs-support

old-application-commands-and-interactions

`Precondition` doubts.

Hi, I'm rewriting my bot from Rust's poise framework to Sapphire. In the rust version, there was a config parameter that let me run a check every time, a command is ran. These are regular commands and not slash commands aka ?avatar. Is there anything similar for Sapphire where I can provide a function that will return either true or false to know if the command should be ran or not. Secondly, how do I handle preconditions that may take sometime to execute, something sort of a database lookup which may take from 50-300ms depending on the workload for the bot. I tried doing something like below ```ts // command file public constructor(context: Command.LoaderContext) { super(context, {...
Solution:
Yeah, I recommend deferring it only in precondition and then use editReply or followUp in the command

best practice for hybrid commands

im wondering what the best practices for making commands that have a message and slash version would be. is it possible to have one single file (ex: ping.ts) that stores a PingSlashCommand class and a PingMessageCommand class? so far ive divided it up via 2 files. one called ping.ts and one called message.ping.ts. this is kinda annoying though...

Scheduled task pattern broken?

Hello, I started using plugin for scheduled tasks and when I do * * * * * pattern which is for every minute, it's being multi-executed every second
Solution:
Our plugin doesn't control this, the underlying https://docs.bullmq.io/ does

Scheduled Task payload types

Does this plugin support adding type for the payload? Tried to just add interface in d.ts as type for that key but that doesn't work. tried to search docs for that but I didn't find anything about that re-read docs and found that they actually mention ability to specify type for payload. but somehow that doesn't work for me. Tried passing just raw type, interface, actual type and still no success the way I declare task & it's payload:...
Solution:

Could not pass a new instance of slash command builder to registry.registerApplicationCommands

I have found out that subcommand and subcommand group type is omitted when passing a newly instance of builder. When using the callback method it's not omitted 🤔 reproduction sample: https://github.com/yuanstuffs/registry-reproduction-sample...

Command comparison

is there a way to manually compare commands versus the api? Like deep comparison how the Framework does it automatically?

i18n not giving correct strings

In src/languages/en-US/coreCommands/ping.json I have this: ```json { "loading": "Calculating the latencies..." }...
Solution:
the issue was while building. Apparently esbuild converts .json to .js
No description

refreshing all the application commands

how can i refresh every application command with sapphire? as in overwrite every single one when i launch the bot?

Global error listener

How would I make a listener that checks for any slash command error and returns a reply?
Solution:
```ts @ApplyOptions<Listener.Options>({ name: "CoreChatInputCommandError", event: "chatInputCommandError" })...

run other commands inside other commands

im trying to run the "fix" command inside the "register" command but i cant figure out how to. i typed out what im attempting to basically do inside the register command but it obviously doesn't exist.
No description

filtering custom id via name

was wondering if i could just filter via the name property instead of using the parse method
Solution:
you need to check for customId of interaction, I don't think there are the other way to do that
No description

Issue when following along the Listener guide page

I directly copied the exact code from the below guide page on Listeners. I don't know how to fix this and not sure what to do. https://www.sapphirejs.dev/docs/Guide/listeners/creating-your-own-listeners...
Solution:
run method is missing
No description

Property 'utilities' does not exist in type 'Container'

it's just my day of getting back to coding after about a year in corporate work and I've been scratching my head for hours now why it cannot utilize @sapphire/plugin-utilities-store on the types. I don't know if using bun caused this issue, or I may have forgotten something. I tried injecting db to the container, it works. I just don't know for utilities (and probably other internal injections by other native sapphire packages). Thanks....
Solution:
Did you check out the readme? It's pretty thorough. https://sapphirejs.dev/docs/Documentation/api-plugins/@sapphire/plugin-utilities-store/ If yes then please describe excarly what problem you're facing....

LazyPaginatedMessage explanation

So, I have 500k users in database and I use prisma. I want to make economy leaderboard with LazyPaginatedMessage but can’t understand how it works and there are no examples for it I wanted to kinda have method with currentPage parameter, and that will be used to fetch data everytime on page change, right? So I can use “skip” in prisma query...
Solution:
As opposed to regular Paginated message it will only execute the page render of the previous, current, and next page. The result is also cached.

MAYBE a bug with subcommands

/
Solution:
oh, going through src I figured that event's name must be PluginMessageSubcommandNoMatch

oauth guide

might be a pretty dumb question, however, is there any version of oauth guide that is just so plain, a mind like mine can comprehend? I just for some reason need an example to see how it should work, if there is any. Anything helps. Tried plugin-api's documentation but for some reason I can't make anything work.
Solution:
yes you're describing the basic principle of OAUTH2. Like I just said, it works in 1 and 1 way only.

What am I supposed to trust, the basic slash command registering? Or the Wiki's Commands section?

Stuff under Creating a basic slash command seems to be heavily outdated, it says the type is Command.Registry in some parts, but vscode is never actually auto completing to that. Instead it auto completes to ApplicationCommandRegistery type, and Awaitable stuff as the return of registerApplicationCommands, it started to be totally different approach here, then I saw fetchReply is also outdated, and the new one, which is withResponse is no where similar to be usable in isMessageInstance, is it ba...

disable specific commands from registering on startup

hi, so i'm not completely sure how to implement this, but i have a config with all the command names, with an option to enable or disable them. how would i go about actually implementing this so that it doesn't register the command on the registry at all if the command was set to disabled? thanks...
Solution:
This should be built into Sapphire :Thonk: just set enabled: false on the command options

Required Client Permission mismatch with role

One of my commands requires various authorizations and, among other things, Connect. So I pass this array ```js const RequiredBotPermissions = [ PermissionFlagsBits.Connect, PermissionFlagsBits.CreatePublicThreads,...