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 Server
HHyper1/6/2024

Any reason as to why this event wouldn't be firing?

```ts import { ApplyOptions } from "@sapphire/decorators"; import { Events, Listener, type MessageCommandErrorPayload, UserError } from "@sapphire/framework"; import { EmbedBuilder } from "discord.js"; //import { captureException } from '@sentry/node';...
Solution:
What are the names of all the files? Names have to be unique per piece type, even across folders. So no 2 files called error for example. Or if you do want that, set the name property in applyoptions
RRuin 🐲1/6/2024

Can't get working in Deno

I've been told Sapphire works in Deno, but when I tried to run my project as-is, I get this error.
Solution:
I'm going to use this message to mark as resovled with @Answer Overflow. The TL;DR is that Deno's node modules compatibility is kind of garbage and the solutions are - Stick to NodeJS. @vladdy and I are of the opinion that OP's issues with Node can be solved with Node, it just requires some environment setup. - Use Bun instead of Deno, we fully support it and it does have proper support for node modules....
No description
T./Ticker1/5/2024

How to use @sapphire/decorators?

I tried using it but am getting this error: Unable to resolve signature of class decorator when called as an expression. The runtime will invoke the decorator with 2 arguments, but the decorator expects 1. ...
Solution:
add experimentalDecorators to your tsconfig or extend @sapphire/ts-config/decorators
OOreo ™1/5/2024

Is it possible to send an image using `plugin-api`

I have a leveling bot and a dashboard for it, i was wondering if there was a way to get the users rank card from the api instead of generating the image on the dashboard.
Solution:
response.setContentType(MediaTypes.ImagePng).status(200).end(bufferOfTheImage) if i remember correctly. Let me know if it works. We could add utility methods for this.
RRuin 🐲1/4/2024

How to get ID of command?

How can I easily get the ID of a registered command for the purpose of mentioning it? I'll be mentoning the command from another command.
Solution:
The id field isn't stored in Sapphire because it is stored in DiscordJS already. Sapphire will have logged the IDs on initial register if you didn't use bulk overwrite (in which case you should have also added it to idHints) but to get it dynamically this is the code: For Global Commands```js import { container } from '@sapphire/framework';...
Ddoqe1/3/2024

[ARGS] this.error errors in the console

[ERROR] Encountered error on message command "ban" at path "D:\Gits\dqm-neo\src\commands\ban.ts" ArgumentError: Username must be less or equal than 20 characters long.
[ERROR] Encountered error on message command "ban" at path "D:\Gits\dqm-neo\src\commands\ban.ts" ArgumentError: Username must be less or equal than 20 characters long.
my arg takes a string and checks if the username length is less than or equal than 20 characters and more than 3 characters...
Solution:
just found out about messageCommandError.ts
No description
C-Carlos👑1/3/2024

Memory Leak

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 interactionCreate listeners added to [Client]. Use emitter.setMaxListeners() to increase limit I recently got this error, my bot only has 2 slash commands and 4 context menus, which are not used much, I already asked in the djs server and they said to go ask here instead...
RRavelt1/3/2024

Slash command not updated

Hi, I have a move channel command with options setup as in picture. On the channel command I did not previously have the channel type option set. I have since updated it (some months ago) and it looks like the slash command was not updated since I can still use category type channels. On my dev bot I unregistered and reregistered the command and that fixed it. Is this a bug or?
Solution:
Released in v5.0.7
No description
Ddoqe1/3/2024

Class constructor _Listener cannot be invoked without 'new'

i just got the listener from the docs and now it's sending this warning ``` Error when loading 'D:\Gits\dqm-neo\src\listeners\ready.ts': TypeError: Class constructor _Listener cannot be invoked without 'new' at new ReadyListener (D:\Gits\dqm-neo\src\listeners\ready.ts:23:42)...
Solution:
for those using next.js set your version on something different than es5 (i used es2016)
XXeno™1/2/2024

Sapphire's approach to components

Does sapphire introduce a new way to handle component interaction? Non persistent components, If so what are they
Solution:
If you mean a scenario where the bot would reply with a component and then listen to that, I'd recommend either: 1. If something simple like a Yes/No button, just use message.awaitMessageComponentInteraction 2. If inputs result in completely separate functionality like Singleplayer vs Multiplayer, stringify all necessary state and add it to the custom ID, then parse it out in separate interaction handlers...
C-Carlos👑1/2/2024

Certain amount of infractions per page

```js let warnings = await db.find({ user: user.id, guild: message.guild.id, automod: flagCheck ? true : false...
HHealthCareUSA1/1/2024

Docker volume issue

Hi, trying to run my bot inside of a docker container on my server (exposing the workdir to the host for changes). Yes, these files are stolen from the official repos. Current bind shows no files on the host and the attached error when trying to run the container. If I run the container without any mount points then it runs fine....
Solution:
No but you can make the GH action that also published the new image to run that command on the server
Ddan12/31/2023

Checking for flags in message commands

I'm trying to add a --silent flag which if present will make the punishment silent (the user won't get a dm). Is this possible through sapphire?
HHealthCareUSA12/30/2023

Get message text from ContextMenuCommandInteraction

Another noob question, sorry! Pretty much title. I have tried parsing the JSON object and using fetchReply() but I believe that is for the reply generated by the bot....
Solution:
See if there's anything for MessageContextMenuInteraction
HHealthCareUSA12/30/2023

How can I find out what events there are, and what the args are?

For example, MentionPrefixOnly has run(message: msg), but what does anything else have? I have tried creating a listener for adding reactions but I am unsure if this is the proper syntax. sapphire generate listener generates a listener different than the default MentionPrefixOnly listener. I have tried scouring the documentation but I cannnot find anything relating to the arguments of run(). Thank you!...
Solution:
messageReactionAdd is a DiscordJS event so the payload is on https://discord.js.org/docs/packages/discord.js/14.14.1/Client:Class#messageReactionAdd
YYuansheng12/30/2023

Unable to get piece's name with CommandStore#get when piece's enabled is false

When doing CommandStore#get with a piece that is not enabled, it returns undefined. But when getting the piece with its aliases, it returns the piece correctly. This issue doesn't effect pieces that is manually disabled
Solution:
that is correct. Pieces that are disabled get unloaded.
RRavelt12/29/2023

The precondition "SubcommandCooldown" is not available.

Hi, I have cooldowns configured on a subcommand like so, but running the command gives the title error.
Solution:
You need to register the plugin somewhere with import('@sapphire/plugin-subccommands/register') (mentioned in the readme)...
Ddjoh12/29/2023

TypeError: Cannot read properties of undefined (reading 'options')

im not even sure what i did wrong lmao https://i.proxied.host/u/N7N6gq.png @ me when replying pls...
Solution:
yall not gonna believe it but I deleted node_modules and reinstalled them and it's working now Kek
Ccosmicle12/29/2023

Change select menu options to custom options for paginated messages

Hi, how do I change the options to, for example, "test1" & "test2" instead? I'm using @sapphire/discord.js-utilities for Paginated Messages, if that's useful....
Solution:
https://www.sapphirejs.dev/docs/Documentation/api-utilities/classes/sapphire_discord_js_utilities.PaginatedMessage#setselectmenuoptions The callback function paramater has a pageIndex as shown so you can detect it for each page and add the proper text....
RREVENGE12/29/2023

Is it possible to set retries for a MessagePrompter (message strat)?

Title, and if it is possible, how? I did look through the docs and didn't find a clue.
Solution:
It is not, sorry.