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

On Listeners

A couple questions on listener pieces: - Where can I find a list of available sapphire event identifiers and their respective arguments? - Does sapphire have any listeners or similar setup by default and if so which ones?...
Solution:
Where can I find a list of available sapphire event identifiers and their respective arguments?
Events enum as well as the https://sapphirejs.dev documentation
Does sapphire have any listeners or similar setup by default and if so which ones?...

Setting up oauth API

my dashboard is hosted on https://cardinal.oreotm.xyz and my backend is hosted on a vps on [ipaddress] Backend Setup: ```ts...
Solution:
something like http://207.xxx.xxx.xxx:4000 could it be because im mixing http and https while using credentials: 'include'...

Sapphire Snowflake

how is this working if I don't even have @sapphire/snowflake installed? utils.js . ...
Solution:
Even though it's not in your package.json, one of your packages relies on it so it's still downloaded and usable. I forget if it's called a transitive or extraneous dependency

"Couldn't find a template file for that component type."

I'm having trouble setting up a custom component template using Sapphire CLI. Here's the template file (custom-listener.ts.sapphire): ``` { "category": "listeners" }...
Solution:
Solved by moving my custom templates folder to the root directory instead of inside src

Is it possible for a custom command to have a button for a link?

The image shows an example, it's a button on an embed. I know how to put a button onto it, but don't know if it's possible to send them to a link when they press it
Solution:
not really sapphire related but you use .setURL()
No description

Seemingly Random Command Registration Failures

Hello there, I created a basic command, however whenever the bot refreshes, the command registration almost always fails. And this most recent time, the command registered, and then after a refresh, it failed to register again. Error: ``` 2023-12-07 22:42:52 - ERROR - ApplicationCommandRegistries(BulkOverwrite) Failed to overwrite global application commands DiscordAPIError[50035]: Invalid Form Body...
Solution:
Ah issue was from an old issue in an old file that was still in the built files, so was still running

Is that possible to have multiple routes in the same route class?

Something like: ```ts @ApplyOptions<RouteOptions>({ route: 'users' }) export class UsersRoute extends Route { // GET in /users...
Solution:
it is not

Command not being registered

Hello, I'm currently following the guide for Sapphire and here's the first error, I can't seem to be able to register a command, that must be the dumbest mistake you've ever seen but after going throught the code a few times I can't get the error... Any idea ? https://pastebin.com/XSEepVsP ...
Solution:
OK so basically I added a console.log to the Register method and now it works, I'm guessing it was a random starting error and that refreshed the process or something 🤷‍♂️

Property does not exist on type 'Container'

i'm trying to use DI in typescript like on this page https://www.sapphirejs.dev/docs/Guide/additional-information/using-and-extending-container and i can't get it to work. my code is ```ts export class MyClient extends SapphireClient { public constructor() { super(...optionsandstuff); }...
Solution:
Start by updating your dependencies. If anything framework 4.8.2 is bugged (as opposed to 4.8.5) but you should be able to just update to v5. Also make sure you do not have @sapphire/pieces in your dependencies, let it be installed as a transitive dependency.

Sapphire eslint-config

So I updated eslint-config and all plugins to their latest versions, eslint-config is at 5.0.3 and now I get this so I am wondering did the syntax to extend change? ```...
Solution:
restart your IDE?
No description

Translate runIn error message

Since runIn pre condition do not return the identifier of precondition that failed, is there a way to translate the message of the error or should I just don't use the runIn: CommandOptionsRunTypeEnum.GuildAny and only use preconditions: ['GuildOnly']?

Type issues with .addChoices()

I am attempting to add choices to a string option, and this error is a little confusing. See what I mean: ```ts option.setName("type").setDescription("Choose whether to snipe an entire message or a message edit.") .addChoices([...
Solution:
addChoices has a spread syntax for the array type, so remove the square brackets and it will work.

Sapphire registering applications bug

So I updated sapphire to the latest version and when i start my bot the ApplicationCommand registering keeps thinking that there is differences found in every single command (Provided few screenshots)
Solution:
@sapphire/framework@pr-701
No description

Error when creating a modal

Can someone help me figure the cause of this error, heres my code below and the error. Code: ```js const { InteractionHandler, InteractionHandlerTypes } = require('@sapphire/framework');...
Solution:
i used createMessageComponentCollector() instead of doing it all in the button interaction handler

Linter errors in command options after upgrade

Hey there, After upgrading to the freshest Sapphire and Discord.js versions I've got error in every command where I parse the options. For example: ```...
Solution:
I had to reinstall the IDE and now it seems to work

augments

hello, when augmenting the @sapphire/pieces to edit the container, when i use pnpm i am required to install '@sapphire/pieces' package or augments for @sapphire/pieces do not work

Tooling question

If I want to like add eslint-plugin should I add both eslint and eslint-plugin and then override the rule in package.json, ```ts "rules": { "node/no-process-env": "error" },...
Solution:
Yes, unless by other way you meant using an .eslintrc file. You also don’t have to use sapphire’s config if you don’t want to. https://archive.eslint.org/docs/7.0.0/user-guide/configuring#:~:text=There%20are%20two%20primary%20ways%20to%20configure%20ESLint%3A,entire%20directory%20and%20all%20of%20its%20subdirectories.%20

[ERROR] Encountered error on event listener "moderationLog"

Full Error: https://pastebin.com/GnkxtJqe moderationLog Listener: https://pastebin.com/DLgksCHN...
Solution:
moreover, looking at the error stack at ModerationLogListener.run (C:\Users\cmart\Desktop\Discord Bots\Sapphire\src\listeners\moderationLog.js:19:8) the error appears here, maybe your getPunishmentTitle or getAutomodPunishmentTitle is returning null/undefined instead of a string, better fix that...

Fetch reply from a command to button interaction

How can i fetch a reply from x command so i can edit the reply in y button interaction
Solution:
the interaction passed through the interaction-handler is a ButtonInteraction so that should help https://discordjs.dev/docs/packages/discord.js/14.14.1/ButtonInteraction:Class#message...

Is there a way to use Sapphire to reset previously registered slash commands?

So, I've got a bot I'm working on that uses Sapphire and recently, just as an example, I generated a unban.ts slash command while I had npm run:watch running (so it registered the command with the bot). I then moved the unban.ts file to the Moderation folder I created for commands like this one, and now I need the previous unban command to become unregistered. Is there any way I could have Sapphire automatically unregister slash commands created like this one upon finding that the files for the...
Solution:
Then it would probably be because TypeScript does not delete old files from the dist folder when you move them in the src folder. Clean your dist folder and rebuild.