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

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({})
};
...

Bot freezing after evaluate `.client`

- evaluated how eval this.container.client - with which options option? - define "hang"...

will using super while having @ApplyOptions work

will this code still work? will @applyoptions be applied or no
Solution:
no, it's either constructor or applyoptions. Just default guildId to empty string on line 24?
No description

Command.LoaderContext does not exist

I have been updating my code to the new versions recently released, and Command.Context has been deprecated, but Command.LoaderContext does not exist. Listener.LoaderContext does exist however. "@sapphire/framework": "^4.8.2",...
Solution:
Mb, Command is from @kaname-png/plugin-subcommands-advanced (which probably hasn't been updated yet), not sapphire

found differences for command when i havent made any changes

not sure whats happening but i havent made any changes and it still says its finding differences
Solution:
@iaqi replace your gear emote
No description

Can't create new listener

I've tried to create a ready listener as the getting started shows, but it crashes
Solution:
exact same error as #TypeError Class constructor _SapphireClient cannot be invoked without 'new' This means your target wasn't set so it defaults to ES3 which is ancient JS that isn't supported and doesn't supported classes...

@sapphire/shapeshift validate env library

How would I go about making a library which validates the process.env similar to that of znv but using @sapphire/shapeshift. Was thinking of doing that so I keep my libraries within sapphire if possible

Extending the container wont work?

Maybe my enviroment is wrong? I restarted the ts client*...
Solution:
WAIT solved i didnt have sapphire/pieces installed, (i usually have it so i didnt check)
No description

Listeners and Handlers not registering interactions/events

Hey! After the latest release my bot is not responding to any interactions or events. Slash commands, buttons, modals, everything stopped working. I already made the necessary changes to my files...
Solution:
This really is just a duplicate of #Deployment failing, we haven't fully finished rolling out all updates yet. Afterwards please start anew.

Deployment failing

Hey! My sapphire deployment is failing but I don't really know why. It is giving me some errors on the framework's code apparently: ``` ...
Solution:
Not a Sapphire bug, but rather a semi-breaking type change in latest version that we're announcing in a few minutes. tl;dr: You need to use InteractionHandler.LoaderContext instead of PieceContext. Likewise for commands it's Command.LoaderContext, listeners Listener.LoaderContext, and so on....

Log File

Is there an setting that i can change so my bot saves logs to a file?
Solution:
You'll have to create your own logger plugin for that. However it should be noted that if you host your bot with something like pm2 or docker that those services already create a log file of themselves so creating one of your own means you're duplicating all the logging.

Pre-built binaries not installable for @sapphire/[email protected] & build failing

Hi, I'm opening this thread for a contributor who is encountering issues attempting to install Sapphire The full logs are found at: https://gist.github.com/Southpaw1496/21a4679c77a48baa063aad67680443d4 A highlight is that │ node-pre-gyp http GET https://github.com/sapphiredev/type/releases/download/v2.4.0/type-v2.4.0-node-v108-darwin-arm64-unknown-unknown.tar.gz the build step seems to not be able to resolve the last two parts of their machine information...
Solution:
Make sure you are up-to-date using the latest @sapphire/type. Python 3.12 broke some stuff in node-gyp but that’s been fixed in @sapphire/type 3.4.1. Also make that your lock file is regerenated and only pulls in node-gyp v10 or higher (the transitive dependency should be node-gyp@latest).

Any idea why is this happening?

I updated the packages and the types got messed up
Solution:
Remove @sapphire/pieces from your dependencies and just let it be pulled in as a transitive dependency.