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

how would you go about logging shard creation in sapphire?

I understand that shards are auto created by default, how would I go about logging it? Does anyone have a bot on github that could show an example? i'm more of a visual learner :)
Solution:
Shards are entirely managed by DiscordJS. Sapphire doesn't do anything shard related. DiscordJS has several event emitters that you can listen to using Sapphire to get information about shards: https://github.com/sapphiredev/gemboard/tree/main/src/listeners/shard/...

What is a Piece?

I often read this term but dont really understand it
Solution:
A "piece" is literally a "piece" of your code. Every Sapphire class (commands, preconditions, arguments, listeners, etc) extend the Piece class. Pieces have some properties that are therefore available on all of those classes.

GuildIds Array Empty = global command?

If i leave the guilds array empty, does this mean the command will not be registered or will it be registered globally? Basically, I want to know the behavior when providing these values [] [''] undefined...
Solution:
[] = global undefined = global null = global [''] = invalid 🙄...

How necessary (in practice) is it to set idhints?

Working on a public bot, and I am not sure how to handle this effectively when I work with a dev and a prod version of the bot. Is it really necessary for me to make an effort in this topic or does it work just fine without idhints?
Solution:
Related to the original question, I found this https://www.sapphirejs.dev/docs/Guide/application-commands/application-command-registry/advanced/setting-global-behavior-when-not-identical if using this will I not have to worry about ids?...

How do you initialise a UserSelectMenu?

As per title, how do you do it? As of right now, I only see MessageSelectMenu available for use and cannot import anything "user select menu" related. Here's my dependencies....
Solution:
UserSelectMenu is not in DiscordJS v13 so update to DiscordJS v14 and Sapphire v4 and it will just™️ work™️ Other than that refer to https://www.sapphirejs.dev/docs/Guide/application-commands/interaction-handlers/select-menus but where-ever it says StringSelectMenu just do UserSelectMenu....

selects

Does sapphire support the (kinda) new Role & Channel selection menus?
Solution:
It should anyway

turn off dev mode?

Not finding anything in docs/online, is there a production mode? (yes, this is building and running dist bundle)
Solution:
Set NODE_ENV as production

Very intense application command fetching

I'm using the new sapphire, v4.0.1 , with discord js v14.7.1 Suddenly, the the bot does an incredible amount of fetching of application commands, resulting in rate limit. {"timeToReset":1100,"limit":50,"method":"GET","hash":"Global(GET:/applications/:id/commands)","url":"https://discord.com/api/v10/applications/ID/commands?with_localizations=true","route":"/applications/:id/commands","majorParameter":"global","global":true}...
Solution:
@bomi can you test the changes made in the PR release if they achieve the same end result?
npm install @sapphire/framework@pr-598
npm install @sapphire/framework@pr-598
...

Use preconditions outside of the command class

Is there a way to run a precondition check outside of the command class for instance if I wanted to check if someone would pass a precondition in a function
Solution:
import { someCondition } from '../lib/utils/someCondition';

if (someCondition) return;
import { someCondition } from '../lib/utils/someCondition';

if (someCondition) return;
...

Setup bot hosting with SparkedHost

okay , i searched on gg and found a host is sparkedhost , i setup everything , i use filezilla to transfer all files in dist folder to run bot , but seem like it cannot run some sapphire functions it should read all interactions,commands ,... like pepeFeelsBadMan but i dont know why , mayb my setup have something wrong...

How can I effectively use the `PaginatedMessage` function?

``js const queue = this.container.client.player.getQueue(interaction.guild!); if (!queue) return interaction.reply({ content: ${this.container.client.dev.error} | I am not in a voice channel`, ephemeral: true }); if (!queue.tracks || !queue.current)...
Solution:
```ts import { PaginatedMessage } from '@sapphire/discord.js-utilities'; import type { Command } from '@sapphire/framework'; async function aa(this: Command, interaction: Command.ChatInputCommandInteraction) {...

sapphire steals the CPU

We just deployed a bot on a droplet... No I just got the message of my co-developer, that the process of the bot requires the Whole ram and CPU of the droplet, so Ubuntu shut the process down. The bot is in comparison very light, so I can't imagine how this happened. It is running via pm2. Any ideas? On my local test machine, normal running cost only 27 MB, not 1 GB 🤷🏻 Thx...
Solution:
Sounds like an issue on the OS end, especially if it doesn't happen locally. Sapphire also has a very very tiny memory footprint compared to discordjs itself.

Application Commands

``` [ERROR] ApplicationCommandRegistry[toggle author] Failed to register guild application command with name "Toggle Author" for guild "993567738360496288" DiscordAPIError: Missing Access at RequestHandler.execute (C:\Users\weila\Documents\Discord Bots\Massive-Automation\node_modules\discord.js\src\rest\RequestHandler.js:350:13) at processTicksAndRejections (node:internal/process/task_queues:96:5) at RequestHandler.push (C:\Users\weila\Documents\Discord Bots\Massive-Automation\node_modules\discord.js\src\rest\RequestHandler.js:51:14)...
Solution:
3. Copied the wrong Id

Command alias for slash commands?

Is there a way to add an alias for chat input commands, like for example a /command having an alias "run" so that /run does the same thing as /command
Solution:
no because discord doesn't allow aliases for slash commands

Adding a command to a guild after client is ready.

I want to make my bot modular by allowing people to enable and disable modules, and for the bot to then set the registries to add the guild etc, which functions will i need to make use of? Can't figure it out on the docs
Solution:
why not just use slash commands and let people manage that through the Discord permissions UI so you don't have to bother

Emoji In Context Menu Command

Hey, I'm trying to put an emoji in a context menu command and it's throwing an error - is that expected? I'd expect emojis to work when registering the command, I'm guessing this might be a bug with the name validation that Sapphire does? Sample Code...
Solution:
I'd expect emojis to work when registering the command, I'm guessing this might be a bug with the name validation that Sapphire does?
Sapphire doesnt validate names. DiscordJS does. so you'll have to go there it's part of @discordjs/builders...

commandDenied Event not Fired

All is in the title (and the file is loaded because I tried to put a console.log in the constructor and it was printed) I have a command with a cooldown and when the cooldown is reached, I get "App not responding" but nothing in console (My run() only console.log the params)...
Solution:
I’m pretty sure you need the listener to be listening to the “chatInputCommandDenied” event, not just “commandDenied”

HMR plugin error

Everytime I start up my bot with the HMR plugin enabled I recieve this error with all my commands:
Solution:
Haven’t tested but pretty sure this is solved with the new version will open a new post if I encounter anymore errors

Recognising "hidden" in CommandOptions

Hello, I realise this is more a TypeScript question than a Sapphire question. What type should I add to the options parameter to make it recognise hidden: boolean? I was thinking something like options: Command.Options & {hidden: boolean} but it didn't work. Thanks!...