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

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/framework@3.0.0 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.

Sapphire doesn't compile wirh discord.js v14

Apologies if this is silly but I've installed @sapphire/framework and when I try to compile using tsc I get thousands of errors from the sapphire framework. Am I missing an essential package?
Solution:
tsconfig.json:```json { "extends": "@sapphire/ts-config", "compilerOptions": { ...

compile into single file

Bundling the bot into a single file fails because sapphire loads commands/listeners files when run, not via import. Is there a simple setting in the bot to statically import all the commands?

Custom listener name not applying

Hey, I'm looking to put multiple listeners into the same file and I'm running into an issue where the name option isn't applying As a quick reference, I am on the v14 PR although I believe it's unrelated ...
Solution:
Looks like this was a caching issue with old files sticking around, not a bug

Precondition and InteractionHandler

Hey, is there a way to add precondition to InteractionHandler ?
Solution:
for interactions you have to use the parse method

Autocomplete handler not working

I made a interaction-handlers folder adjacent to my commands folder and have this code as a .ts file inside: ```` // @ts-nocheck import { InteractionHandler, InteractionHandlerTypes, PieceContext } from '@sapphire/framework';...
Solution:
Solved it. @Answer Overflow I didn't have .setAutocomplete(true)....
Sapphire - Imagine a Framework Community - Answer Overflow