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

Commands don't trigger with newline starts

If a message is sent with a newline immediately after the command's name it won't be triggered. For example: ``` !say...
Solution:
No... I don't think this is gonna work. It goes pretty much against how we parse messages and commands. Might I recommend using Slash commands instead and showing the user a TextInput modal component which allows for multiline string input that way?...

How can i get registered Command JSON data?

like applicationBuilder.toJSON()?
Solution:
Alright, so getting the command JSON in Sapphire is pretty simple. There isn't one big toJSON() method for everything. The trick is to just make one yourself on each command. Basically, in your command file, you create a method that just returns its own JSON. You can call it toJSON or whatever you want....

Precondition position

I think that precondition positions are not working
Solution:
as you can see in the link I sent we dont actually check for duplicate positions, it's just going to be pushed or sliced into the array regardless

Reloading command pieces not working in Bun

Reloading a command piece, either with <piece>.reload(), with <CommandStore>.loadAll() or the @sapphire/plugin-hmr plugin, doesn't work and the command remains the same as before. After long trial and error I found that I could make it work by first unloading the piece (with <piece>.unload()), then removing the command file from the import cache (with delete require.cache[piece.location.full], this works in Bun with TS/ES6), and then loading the piece again (either with <piece>.reload() or with <CommandStore>.loadAll()), and the changes were successfully applied to the commands. This was tested in a minimal project, with only the following dependencies and file structure:...

How to manual disable precondition?

Hi, i made precondition that automatically enabled ```ts public constructor(context: AllFlowsPrecondition.LoaderContext) { super(context, { name: "RulesOnly",...
Solution:
i'd rather creating new instance ```ts declare module "@sapphire/framework" { interface CommandOptions {...

Voice channel status updated

How are you grabbing the audit log data for channel status?

how to use shoukaku and kazagumo

example?
Solution:
There are no music bot library examples because music bots are by and large against Discord ToS unless they stream exclusively royalty free music (which no one wants to listen to) On an aside, you really don't need to make yet another music bot. There's plenty out there already....

MessageCommandDenied event is not listening.

Hi, i want to change cooldown/permission message, i found reporting-precondition-failure and i do listener like this; ```ts import { Events, Listener, type MessageCommandDeniedPayload, type UserError } from '@sapphire/framework'; export class MessageCommandDenied extends Listener<typeof Events.MessageCommandDenied> {...
Solution:
then you need to implement both listeners
No description

Reduce loading time of ApplicationCommandRegistries

Hello all, I am experiencing a non-issue where the application command registries are taking over a minute to load. This is consistent, so I'm curious if there is any way to reduce this loading time. The bot has around 16 commands, most with minimal to no options.
[INFO] ApplicationCommandRegistries: Initializing...
[INFO] ApplicationCommandRegistries: Took 61,304ms to initialize.
[INFO] ApplicationCommandRegistries: Initializing...
[INFO] ApplicationCommandRegistries: Took 61,304ms to initialize.
...

how to change builder value before it registers?

Hi, i want to add my old builder style language handler ( ```ts const data = (this.builder as CommandBuilder).toJSON(); this.data = localizeData(data, this.client) as CommandJSONBody;...
Solution:
I just realized it, thanks! Is there also the possibility to make language-specific aliases (prefix command)

Paginated message maze error...?

I'm getting a strange message from the PaginatedMessage class: ```[PAGINATED_MESSAGE_RUNS_IN_NON_PARTIAL_DM_CHANNEL] PaginatedMessageRunsInNonpartialDMChannel: PaginatedMessage was initiated in a DM channel without the client having the required partial configured. If you want PaginatedMessage to work in DM channels then make sure you start your client with "CHANNEL" added to "client.options.partials". Furthermore if you are using message based commands (as opposed to application commands) then you will also need to add the "DIRECT_MESSAGE" intent to "client.options.intents"...
No description

PaginatedMessage unknown interaction

Hi, so the idea is I have certain commands that use a paginated message, and I want to log the user's result to my logs channel to check if it's working correctly. I log command usage in a method like the code below, and I realise my app crashes very frequently with a DiscordAPIError[10062]: Unknown interaction, especially when i try to navigate the pages myself with the select menu. The node.js process then exits with error code 1. I suspect that the duplicate pagination (one to the user, one to the logs channel) is causing the issue, so I disabled the logging and I encounter no more crashes....
Solution:
This will never work. You cannot have 2 things on 1 interaction like that. Why log every action of the user and not just the errors though? Also the process shouldn't exit outright on a simple error. This suggests your error handling is borked. That's a different problem though....

Question about phisherman plugin

Hi! I have a question about phisherman plugin: it is still possible to use it? (because I'v joined the official discord, but it seems to be fully shutdown since last month) Thanks to the peoples that take time to clarify my doubts 😄...
Solution:
no because to use the plugin you need an api key which as you mentioned you can no longer receive

PassportJS with Plugin API

Hello, i know Discord OAuth is directly available in Plugin API, but i want to add other auth methods like steam. For that i thought about using passportjs but i don't see a way to use it in combination with plugin api. Does someone have experience with this and can give me advice? 😄...

slash cmd

how to add slash cmd
Solution:
restart the bot or call commandStore#loadAll

what is route?

how to use that?
Solution:
it's part of the API plugin if you want to host a REST api along with your bot, see more details on https://sapphirejs.dev

multiple provided values message command

im attempting to make a message command that is like ?query Username1, Username2, Username3... etc id need to be able to first get all the usernames into one string and then split it myself by comma and space but how would i get them all to begin with? theres not a set amount of usernames that would need to be provided, ie some people could provide 2, 3 or even just 1....

Unable to catch Zod error

Hi, I'm creating a container builder system that intakes modal values from a user and attempts to create the selected component. I am trying to use discordjs's builders to set the data, then run the .toJSON() function, since this will try to validate the builder's data. I wanted to catch this error and notify the user what they need to adjust, however I can receiving this and not sure how to proceed: ...

Command reg

Can I register certain commands globally and some to my guild only?
Solution:
you can use RegisterOptions.guildIds for your guild specific commands and the commands that don't specify guildIds will be your global commands. in case your unfamiliar with the register options, it's the second parameter in the registry.registerChatInputCommand and registry.registerContextMenuCommand functions...

StringSelectMenu breaks command

Code: https://github.com/tortenworx/truss-bank-pre-release/blob/master/src/commands/accounts.ts So what happens is that whenever I do the command, with this string select menu, It breaks. Now I narrowed down the problem to the .addOptions bit. the productsList.map() function somehow breaks it....
Solution:
I found out the problem, the description for a string select menu option has a character limit that I was surpassing leading for it to error out without logging