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

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/type@2.4.0 & 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.

Autocomplete within command class

iya, I was wondering if there's a way to add an autocomplete handler within the command class, so i dont have to create my own autocomplete handler. I'm using @sapphire/plugin-subcommands so wondering if theres something like that so I could just specify autocomplete: besides chatInputRun: or something...

Paginated message support

Can i allow paginated message actions to be controlled by anyone in server, currently it accepts an argument of whom to give.
await paginatedMessage.run(msg, msg.author);
await paginatedMessage.run(msg, msg.author);
...
Solution:
There is no such option and it likely wont be added because target isn't just used for filtering interactions but also internationalisation and ensuring interactions stay in sync.

Subcommand wont get registered

Hey, I know it must be some little stupid thing I did wrong: Im trying to create subcommands but while starting my bot I get the following error: TypeError: Cannot read properties of undefined (reading 'parseConstructorPreConditionsRunIn') ...
Solution:
Update your dependencies, framework specifically. The method is a static method on Command class.
No description

Permission bits to Human Readable text

Is it possible to get Human readable text from permission bits? I'm trying to make a help command which extracts command names via container stores & when user selects the command name, the help command then extracts detailedDescription of selected command to show. A nice addition would be to show the permissions required....
Solution:
const { PermissionsBitField } = await import('discord.js');

new PermissionsBitField(the bits here).toArray()
const { PermissionsBitField } = await import('discord.js');

new PermissionsBitField(the bits here).toArray()
...

Check if command is a slash command

```js categories.forEach((category) => { const dir = commands.filter((c) => c.category === category); const capitalise = category.slice(0, 1).toUpperCase() + category.slice(1); ...

Is it possible to send voice messages from a bot?

I have a discord bot and want to integrate OpenAI's TTS API. Problem: it just attaches MP3 files which mobile users need to download. Is there a way to send these as Voice Messages?
Solution:
Bots cannot send voice messages

Error [EMPTY_MODULE]: A compatible class export was not found.

Solution:
Simply move the file to the interaction-handlers directory (create it if you don't have one) and the issue should be solved

PaginatedMessages

how does this work? I want to use it in a warnings command which gets all the warnings from a user
Solution:
There are more expambles in the documentation than humans in the world just abouts so just look there https://www.sapphirejs.dev/docs/Documentation/api-utilities/classes/sapphire_discord_js_utilities.PaginatedMessage Or use /tag query: bots from @Spinel to get a long list of open source bots. Some use PaginatedMessage. Plenty of examples to go off of....