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

slashcommand wont appear

Tried to implement slash command but it wont show up. The bot is invited with the bot and application.commands scope and it still wont work. ping.js ```javascript const { Command } = require('@sapphire/framework');...

Command Modules

does sapphire have a command modules feature where commands can be grouped into modules that can be disabled or enabled on a per-guild basis?

help needed

ializing... [ERROR] Encountered error while handling the command application command registry for command "ban" at path "/home/runner/bot/commands/ban.js" TypeError: Cannot read properties of undefined (reading 'FLAGS') at /home/runner/bot/commands/ban.js:27:46 at Object.normalizeChatInputCommand (/home/runner/bot/node_modules/@sapphire/framework/dist/cjs/lib/utils/application-commands/normalizeInputs.cjs:30:5) at _ApplicationCommandRegistry.registerChatInputCommand (/home/runner/bot/node_modules/@sapphire/framework/dist/cjs/lib/utils/application-commands/ApplicationCommandRegistry.cjs:65:43)...
Solution:
alright

How to use preconditions properly?

Hi, im a new at sapphire and didn't know much about it, also i was reading the Docs that how to use Preconditions and how to handle failure on it. The question is, i was following the same thing at the docs but there is nothing show when i console.log it, im using ESM JavaScript not TypeScript. also, can someone explain how does Preconditions work? and what make it triggered on Listener event?...

Problem with extended SapphireClient

Hi there I'm trying to extend the SapphireClient to add some custom property. Here's all what I got already: ```ts import { SapphireClient } from "@sapphire/framework"; import { container } from "@sapphire/pieces"; import type { ClientOptions } from "discord.js";...
Solution:
Welp fixed, it seems that the options were overrided by the public keyword

Sapphire stops working when deployed to Heroku

The client still logs in but none of the commands are registered. I'm not familiar enough with sapphire to debug this myself, could someone suggest how I can debug the problem?

Custom slash commands registration

Infos: https://discord.com/channels/737141877803057244/737142209639350343/1240606406290178078µ Hey, so im doing this to create some custom slash commands. So the question is, does sapphire, have kind of collection or something i can add the command to it? so it don't get removed...
Solution:
Only if you use bulk overwrite
No description

Sapphire "no such file or directory" error

I know I like to only have weird bugs, but this is a new level even for me. Updating @sentry/node from ^7.114.0 to ^8.0.0 causes the following error in Sapphire on startup (not just for messageUpdate, for loads of other files as well): ```bash Error when loading '/app/dist/listeners/messageUpdate.js': [Error: ENOENT: no such file or directory, open '/app/node_modules/@sapphire/framework/dist/esm/@sapphire/result'] { errno: -2, code: 'ENOENT',...

trouble importing @sapphire/type

Hi, I'm trying to make an eval command and I'm importing @sapphire/type. There are no errors in the code, but when I run my bot I'm getting this error:
Error when loading '/Users/gww/bot/src/commands/Owner/eval.ts': error: Cannot find module "/Users/gww/bot/node_modules/@sapphire/type/prebuild/type-node-v115-darwin-arm64-unknown-unknown/type.node" from "/Users/gww/bot/node_modules/@sapphire/type/dist/esm/index.mjs"
Error when loading '/Users/gww/bot/src/commands/Owner/eval.ts': error: Cannot find module "/Users/gww/bot/node_modules/@sapphire/type/prebuild/type-node-v115-darwin-arm64-unknown-unknown/type.node" from "/Users/gww/bot/node_modules/@sapphire/type/dist/esm/index.mjs"
...

sapphire

What exactly can this bot do?

Autocomplete - option.match is not a function

Trying to use auto complete. Getting a weird error: ```2024-05-15 03:28:54 - ERROR - Encountered error on event listener "CorePossibleAutocompleteInteraction" for event "possibleAutocompleteInteraction" at path "::virtual::" TypeError: option.match is not a function 2024-05-15 03:28:54 - ERROR - at Object.ok (/home/phil/foc-bot/node_modules/@sapphire/framework/dist/cjs/lib/structures/InteractionHandlerStore.cjs:26:18) 2024-05-15 03:28:54 - ERROR - at _ResultOk.match (/home/phil/foc-bot/node_modules/@sapphire/result/dist/cjs/index.cjs:151:21)...
Solution:
Instead of returning filtered.map, wrap that in this.some just like how you return this.none

Sapphire Scheduled Tasks | When do they launch after bot restarts?

I have a task that disables all message components. But this fails to run after bot restarts and trying to run it Logs: ``` 2024-05-15 02:54:54 - INFO - @yume/sapphire-utilities registered successfully! // preInit...
Solution:
No. I mean don't call /register of the plugin and make a file similar to this and call it instead. You're already halfway there with your postLogin code. https://github.com/sapphiredev/plugins/blob/main/packages/scheduled-tasks/src/register.ts

messageRun commands

I'm getting an issue and honestly, don't know what's wrong, i'm using the template generated by the CLI and everything runs fine, however, when i try preconditions on messageRun subcommands they just not work for some reason? they work on messageRun commands but not subcommands. For example, i'm trying the precondition that comes with the template ```ts export class OwnerOnlyPrecondition extends AllFlowsPrecondition {...
Solution:
If I use sapphire new and then make only 2 edits: 1. Fill in .env 2. Add preconditions: ['OwnerOnly'] to src/commands/General/command-with-subcommands.ts then it does work...

i18n only translate command description

```ts public override async registerApplicationCommands(registry: ApplicationCommandRegistry) { registry.registerChatInputCommand((builder) => applyLocalizedBuilder(builder, 'commands/mycommand:name', 'commands/mycommand:description').setDMPermission(true) );...
Solution:
the latter, or set the same name in each of your language files

How does ApplyOptions work

I have been looking through the examples that are on the sapphire github and they have this bit and everytime i use the applyoptions thing, it just doesnt work. I referred to chatGPT and it said that applyoptions only really works for methods and im really confused
Solution:
Check your TypeScript configuration (tsconfig.json) to ensure decorators are enabled. Ensure that the experimentalDecorators option is set to true.
No description

Autofill message textbox

Is it possible to autofill the message text box upon the press of a button. The idea is to have a button which when pressed auto fills the text box with the intial part of the command (this command also has some options which the user needs to set)

Autocomplete TextInput

Is it possible to suggest something for the text input? https://discord.js.org/docs/packages/discord.js/14.15.2/TextInputBuilder:Class...
Solution:
There is autocomplete for command options but that's it. It doesn't exist for text input components.

BulkOverwrite has stopped functioning

In the last 5 months have there been any breaking changes to how commands register? I created 2 sapphirecli slash commands and one has appeared after several days (roll), the other one (createchannel) was pushed 2 hours ago and has not shown up in the BulkOverwritten guild yet.
Solution:
I think I might be deleting/creating my container incorrectly, is this not enough to update a running container?
No description