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

Custom Events not Creating Listeners

I'm having issues using Sapphire with custom events. For example, I have an event for when a member subscribes to a role: ```ts import { ApplyOptions } from '@sapphire/decorators'; import { container, Listener } from '@sapphire/framework'; import { type GuildMember } from 'discord.js';...
Solution:
https://github.com/skyra-project/skyra/blob/main/src/listeners/guilds/members/notMutedMemberAddInitialRole.ts https://github.com/skyra-project/skyra/blob/main/src/listeners/guilds/members/guildMemberAdd.ts#L15 Custom events should work just fine. Make sure your emits are actually called and you do not have duplicate file names. By default the name of the file is used as the piece name, and the piece name has to be unique because we use a Map which has unique keys https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map...

Ignoring Precondition Failures

I'm working on a precondition that I wanna ignore on the ChatInputCommandDenied listener. The documentation suggests to a add information on the context in the Precondition ```ts export class MyDummyPreconditions extends Precondition {...
Solution:
Only button ones can update a message with the same content and be fine

Select menu interaction handler not working

I have a select menu interaction handler which never actually get the interaction, I added a console log in the parse function and it wasn't triggered either, ideas? File: https://github.com/oriel-beck/application-bot/blob/v4/src/interaction-handlers/apply/select.ts...

Dms not being read by Event.messageCreate in listener.

So after an hour of research and checking the guide every 10 minutes, I am fairly confused on why my bot is not reading DMs. This is to implement a ModMail system to my existing bot. The full repo is here on the major development branch: https://github.com/MiekoHikari/VTA-Discord-Bot/tree/major-development Im sure I put in the right bitfield intents and I used the sapphire CLI to generate a ts template for me! I'm sure its a silly mistake somewhere but can't find it V - V...
Solution:
For DMs you need to enable message partials. https://discordjs.guide/popular-topics/faq.html#enabling-partials FYI this is not a sapphire thing, the same would count if you just used Discordjs raw. Sapphire doesn't do anything special like forwarding or filtering events, we only bind them to the client, that's it....

Paginated message exceeding 25 pages

(node:1) [PAGINATED_MESSAGE_EXCEEDED_MAXIMUM_AMOUNT_OF_PAGES] PaginatedMessageExceededMessagePageAmount: Maximum amount of pages exceeded for PaginatedMessage. Please check your instance of PaginatedMessage and ensure that you do not exceed 25 pages total.
If you do need more than 25 pages you can extend the class and overwrite the actions in the constructor.
(node:1) [PAGINATED_MESSAGE_EXCEEDED_MAXIMUM_AMOUNT_OF_PAGES] PaginatedMessageExceededMessagePageAmount: Maximum amount of pages exceeded for PaginatedMessage. Please check your instance of PaginatedMessage and ensure that you do not exceed 25 pages total.
If you do need more than 25 pages you can extend the class and overwrite the actions in the constructor.
Why can't paginated messages go more than 25 pages, and how do I do what the last line is telling me to do?...
Solution:
Nevermind, figured it out. Paginated messages can't go more than 25 pages due to the select menu for the pages (which is limited to 25 choices)

Is it possible to run the same bot multiple times and have them each independently handle commands?

I was wondering if I can just run multiple instances of the same bot and have them handle commands on a per channel basis. Each instance of the bot would have it's own config that tells it what channel it can respond to commands in. I was able to achieve this in discord-akairo (old discord framework) with message commands, but I don't know if this would work with interaction commands....
Solution:
Nevermind. Everything worked perfectly from the start. My own filter feature was making me think no messages were being sent to the second instance's channel. I guess there was an influx of messages all at once in the first instance's channel which made me think it was both instance's messages.

Can't find the template. for buttoninteractionhandler

I used the official CLI guide to generate a buttoninteractionhandler but it says that it cant find a template???
Solution:
I used the official CLI guide to generate a buttoninteractionhandler but it says that it cant find a template???
No description

StringSelect shows error in PaginatedMessage

I've updated the versions to latest and now I see a type error where it expects anything but not ComponentType.StringSelect here's the code for reference https://srcb.in/HpWMA3PaUq...

Augmenting detailed description

```ts export interface DetailedDescriptionCommandObject { usage: string; examples: string[]; extendedHelp: string;...

Set global commands guildIds

Hello, is it possible to set globally the guilds id of all commands, For example when developing, I want commands to be only in one server. thank you in advance...

Snowflake support

Yo (english isnt my native lang) So I am planning to use snowflake id's in my own app, and I decided to use your package (@sapphire/snowflake) because it looks the best one (found it from djs). While researching the snowflake id's, as far as I understand, the worker id is included in the snowflake so there wont be any dublicates. And while I was browsing your code, I saw the options workerId and processId, how to use them? I mean, the backend is just expressjs, without workers or anything, i am planning to run a single instance on vps using pm2, or maybe use pm2 to create workers? so, i know that these options are optional, but still, how to use them? when should i use them?...
Solution:
You should use them if you have multiple processes, for example in a sharded bot

TypeError: isJSONEncodable is not a function

Returns this while registering applications commands and this after a while ``` /home/mooy/projects/13-bot/node_modules/.pnpm/[email protected]/node_modules/discord.js/src/structures/MessagePayload.js:202 isJSONEncodable(embed) ? embed.toJSON() : this.target.client.options.jsonTransformer(embed), ^ ...

Cannot access MimeTypes & HttpCodes when verbatimModuleSyntax is enabled in TypeScript 5

I thought api plugin is updated to support TypeScript 5... Should I just use constant for this

Issues importing from shapeshift

I'm trying to use StringValidator from @sapphire/shapeshift but it keeps throwing this error when i start up the bot: ``` import { StringValidator } from '@sapphire/shapeshift'; ^^^^^^^^^^^^^^^...
Solution:
You're supposed to do s.string.url(...), importing s from the package.

Accessing container inside of a decorator

Is that possible to have access to the container inside of a decorator. I'm trying to use it in a createFunctionPrecondition but I'm getting: TypeError: Cannot read properties of undefined (reading 'container')...

Sapphire Paginated Embed

I have a paginated embed which works fine by the way. I just need a way to be able to select one field from all the embed fields and then run a function based on which field was selected via a string select menu. Can anyone please guide me in the right direction?
Solution:
No that's not currently possible. Right now the components are resolved at build, not per page. However there is a WIP PR that will address this so it may come in the future.

This is not working

Nothing is getting logged from this Listener

Bot does not respond

I've made a bot following the tutorial (kinda), and it does not respond at all anymore (image). The code is public and can be found at https://github.com/oriel-beck/application-bot/tree/v4. To start it follow the readme. According to the debug log it's connected and receives the interaction payload....

Dynamic disable Slash Command based on role

Is that possible dynamic enable a slash command for a specify role in a specifically guild?

How to get the resolve a key without a target?

👋 Is there a way to access the locale strings using the i18next plugin passing the language instead of delegate it to the fetchLanguage? I'd love to have the nameLocalizations and descriptionLocalizations on my slash commands coming from the i18n json files. That will make it easy to collaborative translation. Something like:...
Solution:
Use applyLocalizedBuilder 🙂 Exemple: ```ts import { Subcommand } from '@kaname-png/plugin-subcommands-advanced';...