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

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.

Arguments

The channel built-in argument will detect any channel? (Including Text Channels, Voice Channels, Threads, etc)?

Decorators issue

Never used decorators, so I can't tell the reason why this is an issue
Solution:
I solved it by adding "target": "ES2016" in tsconfig.json
No description

Paginination limitation when not using select menus

I have the following error being presented to me
(node:1484241) [PAGINATED_MESSAGE_EXCEEDED_MAXIMUM_AMOUNT_OF_PAGES] PaginatedMessageExceededMessagePageAmount: Maximum amount of pages exceeded for PaginatedMessage. Please check your instance of PaginatedMessage and ensure that you do not exceed 25 pages total. If you do need more than 25 pages you can extend the class and overwrite the actions in the constructor.
and this is my current code giving the error: ```ts...
Solution:
Extend the class and override the addPage method. Never forget the basic principles of object oriented programming. You can achieve a lot with simple class extension....

Run bot without building to js and use ts-node or other alternatives instead.

Is there a way to achieve the title? Currently I need to build and then run the js file using the command:
npm run build && npm run start
npm run build && npm run start
...
Solution:
If you want to test the bot, then tsc-watch is good. Or you can remove typescript & code directly in js Or you can use bun runtime to start your typescript based bot directly (you will need to refactor your code so that it runs on bun)...

Unregister Old Application Sub Commands from the subcommands plugin

Some old commands i have made still appear in the autofill when typing a application command, how would i get rid of those?
Solution:
If they are still registered either use bulk overwrite by sapphire, use the discordjs methods to unregister, or use https://slash-commands-gui.androz2091.fr

Application Commands are not being registered when bot restarts.

I have an auto-update mechanism built into my bot so I don't have to reupload to the host every time I push a new build, and it appears that whenever the app restarts (using process.exit() and then Pterodactyl starts it back up), my application commands are not re-registered. There is no error in console indicating an issue and restarting forcefully (using Restart button in Pterodactyl) does not cause the issue to occur. Would anyone have some pointers for me to help figure out why this is hap...

Cannot set properties of undefined when extending `container`

Hello! I wanted to create a property entities that holds two properties which would be users and guild of class Entity. Now entities doesn't have any type at all since it'll just be an object to hold users and guild in one. But whenever I run my bot I receive Cannot set properties of undefined (setting 'users') Here's my augments: ```ts declare module '@sapphire/pieces' {...
Solution:
You need to assign .entities, like this:
container.entities = {
users: new Entity({}),
guilds: new Entity({})
};
container.entities = {
users: new Entity({}),
guilds: new Entity({})
};
...