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

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!...

Is there a way to update all sapphire packages instead of going one by one?

is there a way to just update it all together instead of one by one? trying to migrate to v3
Solution:
yarn v1: yarn upgrade --interactive yarn v3: yarn upgrade-interactive npm: npx npm-upgrade pnpm: pnpm dlx npm-upgrade ...

sapphireplugin-subcommands can't catch error?

Hello! I am using this subcommands plugin and i cannot log error in the console. no idea what is going on
Solution:
Not sure what you mean. Need more info. But it should be noted that subcommands have their own error listeners as documented here: https://www.sapphirejs.dev/docs/Documentation/api-plugins/modules/subcommands_src#subcommandpluginevents

Type 'DeveloperOnly' is not assignable to type 'PreconditionEntryResolvable'.

Type '"DeveloperOnly"' is not assignable to type 'PreconditionEntryResolvable'.
Type '"DeveloperOnly"' is not assignable to type 'PreconditionEntryResolvable'.
in src/commands/eval.ts. With a precondition file at src/preconditions/DeveloperOnly.ts with the content https://hst.sh/ufunolenip.typescript . index.d.ts exists with the following content https://hst.sh/gikuhixani.typescript . Eval starts with the content https://hst.sh/sagivaqahe.typescript . ...
Solution:
may it be at fault of the PR you're using? think

TypeError Cannot read properties of undefined (reading 'CHANNEL_CREATE')

So following the docs, I've set up everything and it should work, but I get the error in the title. I'm using TypeScript, and I've installed the required packages (@sapphire/framework and discord.js) However when I do npm start I get the error....
Solution:
Sapphire isn't compatible with Discord.js v14 just yet, which is why you're getting the error.

sapphire type does not install on Node 19 [1]

Well, it seems to dislike me. Fails to build dependencies as it seems like....
Solution:
Nuke @sapphire/type from deps, or downgrade to v18
Sapphire - Imagine a Framework Community - Answer Overflow