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

Whats the command to send messages about the user info

new to js
Solution:
Sapphire and discordjs offer no built in commands.

Force restarted after getting discord.js error

Hi, i want to ask about my bot, if i get some error from sapphire like error from "args", that not make my bot restarted, but if i get some error from discord.js like "Unknown Message" or nothing else the bot force restarted, can you help me pliss? <a:NGS_PleadCry:958030314943434752>

Getting localized application command option

I can't really find how to parse options using their name when I used i18n to localize them. Thanks in advance!...
Solution:
Found it! You can use resolveKey to get a translation.

Allow or prevent command execution

I found this file in the framework: https://github.com/sapphiredev/framework/blob/main/src/listeners/application-commands/chat-input/CorePreChatInputCommandRun.ts And it very much looks like that's the one responsible for letting commands be executed or not. I want to accomplish something similar, but if I create my own listener for the same event, it will not prevent the commands that are being authorized by the core listener, will it? How would that work? And how can I accomplish what I want?...
Solution:
see the enabled precondition

Paginated message not editing reply (always seems to reply)

```ts const display = new PaginatedMessage({ template: templateEmbed, pageIndexPrefix: 'Case', actions: [...
Solution:
I found that it works when I set the customid of the button to @sapphire/paginated-messages.stop, but really it should be able to support any customid

Specifying Types

I'm quite new to Typescript, but I'm slowly getting the hang of it. Although, I was wondering if there's a way to set the type to an TextChannel? Check the image below for what I mean....
Solution:
Yes just import the class then write as TextChannel, or first write it as such and let vscode fix the import when it says it’s not there yet.
No description

Decorator Style for Register Subcommands

Is there a Short Style possible for that? Like That for normal Slash-Commands ```js @ApplyOptions<Command.Options>({ description: 'ping pong' })...
Solution:
The official plugin doesn’t have decorators for subcommands so yes

Issue with subcommand groups

In this code, i have multiple entries inside the panel subcommand but they don't work. ticket is the command name, and panel is a subcommand and it has multiple entries one of them is setup whose messageRun function setupPanel but the code doesn't execute for some reason. not sure why exactly...
Solution:
You should add type: 'group' after name: 'panel'. It defaults to type: 'method'
No description

Paginated Embed error

```ts private async sendPing(message: Message) { const a = await this.getMods() return await new PaginatedFieldMessageEmbed() .setTemplate({ title: 'Test pager embed', color: 0x6080 })...
Solution:
Items need to be valid embed fields because you're using PaginatedFIELDMessageEmbed and fields need a description, title and whether it's inline or not, no other fields. You cannot just insert a random object and expect it to me magically mapped. The error tells you the title is missing and yes it clearly is missing. You should either make a 2 dimensional array of titles and descriptions to ensure every page has an array of proper structure OR use PaginatedMessageEmbed root class and build your own pages with addPageEmbed...
No description

Are union types supported in args.pick?

I really wanted to know whether i could do union types in arguments picking, coming from discord-akairo it had that thing where you can have multiple types which then gets resolved at argument prompting

InteractionHandler pieces not loading

So my handler pieces are stored in src/client/components and my SapphireClient extension is in src/lib/extensions but however i construct my client in src/index.ts...
Solution:
solved
No description

Wanting to remove the footer page index, PaginatedMessage

I want to get rid of this, as of what i have seen it's applied through the applyFooter method which is a protected method, there are options to get rid of the other properties but not this i'd like to know how i can get rid of this. Since this is not documented
Solution:
Extend the class and override it
No description

Client Permissions

When using the client permission tag from applyOption it always passes as true even if the bot doesnt have the permission
Solution:
Previously, obtaining permissions for new applications did not work due to this check:
if (isNullish(permissions))
if (isNullish(permissions))
Because permissions have always had the value of this.dmChannelPermissions (for new applications), in fix, I removed this check...

AutoComplete subcommand name/id

Hello! I'm trying to use autocomplete interactions for my subcommands. Both subcommands (start & end) have the same autocomplete option called 'event'. I'd like to be able to identify which subcommand is being used to use a different logic for each one. Is this possible? Currently I am only able to access the command's information but not the subcommands....
Solution:
You can use interaction.options.getSubcommand() 🙂

DiscordAPIError[10062]: Unknown interaction on interaction.showModal()

Upon restarting the bot, whenever I run a certain command for the first time it returns "DiscordAPIError[10062]: Unknown interaction" on interaction.showModal(). I've seen similar issues (application does not respond) when running other commands for the first time after a bot restart. I believe the main issue is with the interaction object not with the actual modal. After that, if you run the command once again it has no issues....

Is it possible to dev Offline ?

I will be on a plane for a while, and I would love to know if it's possible to use discord.js API localy
Solution:
Can you send discord messages while offline. There is your answer (no)...

Converters

Hey wondering if, it is possible to have type convertions in sapphire or with any of it's utility packages, I have seen the Resolver class but i think there are some methods missing in example the library dpy has a series of converters one is the ColorConverter, so i was wondering whether it's possible to have such converters in sapphire https://github.com/Rapptz/discord.py/blob/master/discord/ext/commands/converter.py#L619
Solution:
I think you're just looking for arguments https://www.sapphirejs.dev/docs/Guide/arguments/using-arguments But also do not forget that nothing stops you from simply defining a function in some utility file and export it then import it elsewhere. You're not restricted to what the framework provides, you can still use regular JavaScript concepts too. If you must have the function as part of the container though then we have this plugin: https://github.com/sapphiredev/plugins/tree/main/packages/utilities-store#readme Other than that, the actual conversion is something you're gonna have to write yourself. I don't think discordjs exports their color conversion functions, but we're not going to mirror their code (overhead, maintenance, etc) so if you want to use what discordjs used internally then create an issue on their repo asking for the functions to be moved to a subpackage (assuming it's not exported). ...

InteractionHandler

Im kinda new to discord.js so im abit confused on how to make it so that only the command author can use the select menu in interaction handlers
Solution:
Pass the command author id through with the customId field (alongside some kind of identifying information) then validate it and return some/none accordingly. View the sapphire guide on interaction handlers for more info on the latter. https://www.sapphirejs.dev/docs/Guide/interaction-handlers/what-are-they Mind you that customId is limited to 100 characters. If the data you need to pass doesn't fit into that when stringified you'll need to do some compression, for example for @Dragonite I have this https://github.com/favware/dragonite/blob/main/src/lib/util/utils.ts...

Command Handler

Hello, just wanted to check for some clarification, ACR, for slash, there's 0 need for a command handler correct? or am I misunderstanding? I am new to slash commands and their usage..... or am I just completely dumb here lol
Solution:
You need to match the incoming data to the proper run functions so yes there is a need