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 recommended way to split subcommands across multiple files?

Perhaps another way of phrasing this question is: Can I have arbitrary typescript files in the commands directory without breaking things?

Does sapphire support all the up to date Discord Auto moderation stuff?

Title
Solution:
most probably this is discord.js related and not sapphire related

How do subcommands work with idHints and guildIds?

How do subcommands work with idHints and guildIds?

Is there a way to prevent fetching information both in the precondition and the command itself?

I need to fetch the same data to resolve a precondition, as I'll need later in the command. Is there a way to prevent fetching this twice?

Listeners with same file name

Is it possible to have 2 listeners with the same file name being from 2 separate emitters?
Solution:
You'll have to specify the name option in both, they must be different

Any bot examples on Github using sapphire's fetch for 3rd party API endpoints?

Looking to rebuild basic Discord.js bot that only fetches API endpoints and posts embeds. Also adding slash commands.
Solution:
Discord bots that use @sapphire/[email protected] and leverage Application Commands and Interaction Handlers - Official Bot Examples ᴱ ᴰ ᴶˢ - Archangel ᴱ ᴰ...

Dependency conflict (discord-api-types)

I installed discord-api-types and now it conflicts with sapphire (or discord.js) version of discord-api-types, how can I fix this? ```ts src/commands/moderators/settings.ts:68:40 - error TS2345: Argument of type 'ChannelType.GuildText' is not assignable to parameter of type 'ChannelType.GuildText | ChannelType.GuildVoice | ChannelType.GuildCategory | ChannelType.GuildNews | ChannelType.GuildNewsThread | ChannelType.GuildPublicThread | ChannelType.GuildPrivateThread | ChannelType.GuildStageVoice'. ...
Solution:
The solution is to use version 0.33 of discord-api-types with Discord.js v13 / sapphire v3

sub commands

very new to sapphire stuff. discord.js in general. but heres my code..``js const { MessageEmbed, MessageActionRow, MessageButton, } = require(discord.js`); const { Command } = require("@sapphire/framework"); const { Subcommand } = require('@sapphire/plugin-subcommands'); ...
Solution:
oh its because i misspelled it haha

How do i delete a slash command?

I Accidentally Created A Slash Command. how do i remove it?
Solution:

Error when using plugin-i18next

node_modules/i18next/index.d.ts:309:18 - error TS2430: Interface 'InitOptions<T>' incorrectly extends interface 'PluginOptions<T>'. Type 'InitOptions<T>' is not assignable to type 'Omit<{ detection?: object | undefined; backend?: T | undefined; cache?: object | undefined; i18nFormat?: object | undefined; }, never>'. Types of property 'backend' are incompatible. Type 'Options | undefined' is not assignable to type 'T | undefined'. Type 'Options' is not assignable to type 'T'....
Solution:
work by adding "i18next": "~22.1.5"...

What’s the difference between a `Piece` and a `AliasPiece`

^
Solution:
AliasPieces can have aliases, Pieces cannot

Global Stores

Say that I wanted to create a globally-accessible Map for reading and writing data related to every guild the bot is in, is there a way to natively achieve this using Sapphire?

ApplicationCommandRegistry save new Command registered to DB

I want to save the idHints automatically in a Database, where can i intercept all new registered Commands with their respective idHint. I did try intercepting all events inside my Client with: ```js emit(event, ...args) { // save all events to a file...
Solution:
I asked a similar question a little while ago (archived in <#1040783283157471292>). The solution I ended up with was to pull all the IDs from the commands store and then upload them to my DB about two minutes after the client is constructed. I also pulled them in from the DB before creating the client so that I could be sure they would be cached in a container property I setup before the commands themselves would be created.

Templates for sapphire CLI

What is the list of templates that you can use for sapphire g?

send() function plugin-editable-commands

I'm confused, what is the point of this function and why not use the discord.js class methods?
Solution:
Because the method does the edit tracking and backend scenes for you

Can a parse be async?

And would it be 'override async' or 'async override'?

Error when loading listener on v14

Although I know that v14 support is still experimental, I decided to give it a go and see if I could get it to work with a basic client and listener. When trying to start the bot, it gives me the following error ```json Error when loading 'C:\Users\medup\Documents\Blight\dist\listeners\client\ready.js': TypeError: Cannot read properties of undefined (reading 'SELECT_MENU') at Object.<anonymous> (C:\Users\medup\Documents\Blight\node_modules@sapphire\discord.js-utilities\dist\index.js:894:54) at Module._compile (node:internal/modules/cjs/loader:1205:14)...
Solution:
We don't really actively support the PR like this. You're on your own and we appreciate any PRs of fixes. That said, you also need the PR version of @sapphire/discord.js-utilities...

TypeError piece.aliases not iterable

When my bot is logging in, it is being prevented by this error below. I tried deleting my node_modules and reinstalling but the same thing happens. Obviously the error can't be in the framework, any idea how I can get past this? error: ``` 2022-12-07 16:46:11 - ERROR - TypeError: piece.aliases is not iterable 2022-12-07 16:46:11 - ERROR - at CommandStore.insert (/Users/whacktop/Engrimoore/Beholder/node_modules/@sapphire/pieces/dist/lib/structures/AliasStore.js:58:33)...

Peristing cooldowns across restarts

Hello, is it possible to persist a cooldown after restarting the bot? I have commands with big cooldowns (like a day or a month) and I don't want them to be reset.
Solution:
There's no built in solution. You'd have to write one yourself backed by redis or some other solution

Conflicting data types with isMessageInstance()

src/commands/ping.ts:18:31 - error TS2345: Argument of type 'APIMessage | Message<boolean>' is not assignable to parameter of type 'Message<boolean> | APIMessage'.
Solution:
Framework does however but I can assure you the code or does are not the issue here otherwise far more people than just you would be having problems.