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

Multiple command exports from a single file.

Is it possible to export multiple Command classes and they'll be recognised as seperate commands?, i.e:- i have a file where i have 2 classes each extending to the Command class or the Subcommand class from the sapphire plugin. And they'll also get stored in the command store

translate replys of sapphire like cooldown

guys how can i translate or change the sapphire reply like cooldown or requiredClientPermissions etc...

Subcommands help

Hello, I have around 50-60 commands which I want to categorize in subcommands, is there an easy way to do it? or I'll have to recode it. I remember this framework having some cog system but unsure if I can setup subcommands with it. Thank you for the help

OwnerOnly precondition not working

Hello there. I just yoinked the OwnerOnly precondition from the guide and the Github repo but I just can't make it work. I don't get an error, I also yoinked the precondition failure messages, I don't get any info about why its not working. I only get "The application did not respond". Without the precondition my command works. OwnerOnly.ts ```ts import { Precondition } from '@sapphire/framework';...
Solution:
fixed it

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....