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

Peristing cooldowns across restarts

Hello, is it possible to persist a cooldown after restarting the bot? I have commands with big cooldowns (like a day or a month) and I don't want them to be reset.
Solution:
There's no built in solution. You'd have to write one yourself backed by redis or some other solution

Conflicting data types with isMessageInstance()

src/commands/ping.ts:18:31 - error TS2345: Argument of type 'APIMessage | Message<boolean>' is not assignable to parameter of type 'Message<boolean> | APIMessage'.
Solution:
Framework does however but I can assure you the code or does are not the issue here otherwise far more people than just you would be having problems.

Sapphire doesn't compile wirh discord.js v14

Apologies if this is silly but I've installed @sapphire/framework and when I try to compile using tsc I get thousands of errors from the sapphire framework. Am I missing an essential package?
Solution:
tsconfig.json:```json { "extends": "@sapphire/ts-config", "compilerOptions": { ...

compile into single file

Bundling the bot into a single file fails because sapphire loads commands/listeners files when run, not via import. Is there a simple setting in the bot to statically import all the commands?

Custom listener name not applying

Hey, I'm looking to put multiple listeners into the same file and I'm running into an issue where the name option isn't applying As a quick reference, I am on the v14 PR although I believe it's unrelated ...
Solution:
Looks like this was a caching issue with old files sticking around, not a bug

Precondition and InteractionHandler

Hey, is there a way to add precondition to InteractionHandler ?
Solution:
for interactions you have to use the parse method

Autocomplete handler not working

I made a interaction-handlers folder adjacent to my commands folder and have this code as a .ts file inside: ```` // @ts-nocheck import { InteractionHandler, InteractionHandlerTypes, PieceContext } from '@sapphire/framework';...
Solution:
Solved it. @Answer Overflow I didn't have .setAutocomplete(true)....

How can I use shard

Hello I want to use shard for my bot but the documentation say nothing about that, can you help me please ?
Solution:
It is the same as DJS.

Sapphire keeps binding to ports

I have created a sapphire bot using the CLI and it keeps binding to a port. How do I disable this?
Solution:
Remove the @sapphire/plugin-api plugin

How to remove image from interaction reply when using a paginator?

When my bot replies with an embed and then edit it's reply to a paginator the image what was in the embed still remains above the paginator. How to remove it?...
Solution:
Set the files option to an empty array on any pages where you don’t want an image

Automatically delete a old slash command that has been renamed?

How would I achieve this, I am using sapphire 3.1.3, and I want it to automatically delete the old one when it detects a change.
Solution:
A PR has been created that will add this as a feature

Commands won't be registered

I've currently only one slash command and one listener (for the ready event) but the listener won't be executed as well as the application command which also won't get registered. After I added some breakpoints to debug the bot I noticed that no breakpoint is hit in the listener and the application command file. src/index.ts...
Solution:
oh, thanks for the hint. I've set the wrong main property. After changing it to the correct one (dist/index.js) everything works!

sapphire type does not install on Node 19 [2]

This is very weird when i tried using the sapphire new command, The same happens with npm too?
Solution:
downgrade to Node 18. Sapphire type is not supported on Node 19 yet.

How to make custom sub command

I have error when try to make custom sub command
Solution:
I mean in the options

Detect HMR Reload

Hey! Is there any way to detect when HMR https://www.npmjs.com/package/@sapphire/plugin-hmr has run on my code? I need to refresh some stale data when it runs Thanks!...
Solution:
We currently do not emit any events back to sapphire on reloads but a PR for that would be accepted.

ChannelTypes not detected as a difference in slash commands

If you were to update a slash commands channel option's channel types, sapphire doesnt detect it and apply the update accordingly, youd have to delete the command and re-register it for the changes to apply

Refresh Commands

Is there a way to refresh all commands? I initially had some certain commands global, and then after expanding the bot, reduced them to guild-specific commands, although this has now caused duplicated commands, as seen in the screenshot. Is there a way to somehow force a refresh of all commands to resolve this? https://i.imgur.com/qGNrDgR.png...
Solution:
Use the discordjs methods to unregister commands

shapeshift's default with respect to surroundings

s.object({
name: s.enum("A", "B"),
other: s.object({ name: s.string }).default(/** if name is "A", default is { name: "abc" }, if name is "B", default is { name: "cba" }
s.object({
name: s.enum("A", "B"),
other: s.object({ name: s.string }).default(/** if name is "A", default is { name: "abc" }, if name is "B", default is { name: "cba" }
...
Solution:
Once we implement when, You'll be able to do it like this ```ts s.object({ name: s.enum("A", "B"), other: s.object({ name: s.string }).when('name', {...

Command File & Directory Parsing

1. Is there a link to the source code on how the framework handles files for commands? 2. Is there a way to extend the functionality of the current command handling built into the framework where it can interpret subcommands. An example would be commands/music/index.ts & commands/music/playlist.ts. What index.ts would be, is the "base command". Basically my question is how can my command handler be similar to Skyra's. If manipulating the framework won’t work, will using node:fs do the trick? Any links or documentation would be appreciated!...