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

Quoted argument not consumed as single argument

I am trying the basic echo command from the guide, and finding that an argument in quotes, which is supposed to be a taken as a single argument is not occurring. ``` import { ApplyOptions } from '@sapphire/decorators'; import { Args, Command } from '@sapphire/framework'; import type { Message } from 'discord.js';...
Solution:
Remove the quotes: []. Thats telling the argument parser to ignore quotes

Formatting Dates

``ts let ratelimit = manager.acquire(interaction.guild.id); // reply -> String Please try again in ${new Date(ratelimit.expires - ratelimit.remainingTime)}`...
Solution:
you should use the date formatter

Shared handler

How to make shared InteractionHandler to handle buttons and select menus together?
Solution:
you can export multiple classes in one file and sapphire will register them.

Why is there no documentation for @sapphire/cron? Is it dead? Is there a good alternative?

I'm looking for a good solution for scheduled tasks , but it seems that the cron plugin is dead, at least I can't find any usage examples or any documentation of it. Does anyone here have more information about it or knows an alternative I don't know about?

Looking for a example of i18n plugin's applyLocalizedBuilder

Hi! I'm adding localization support to my bot using the i18n plugin, and I'm not too sure how to use applyLocalizedBuilder. I'd be extremely grateful if anyone has a example of using it with a command that has options.
Solution:
If you hover your mouse over the function, you'll see the documented examples

define global variable on start up

I'm trying to start a playwright chromium instance when the bot starts and I want it to be global, as in have it be usable in command classes, how would I do that?
Solution:
<:_:746069730170896405> Sapphire guide results: Additional Information / Using and extending container...

error handler

Is there a global error handler as like a listener, I looked through the docs but haven't seen something like that yet.
Solution:
Yes listeners, sapphire exposes a constant with all events. Also documented here https://www.sapphirejs.dev/docs/Documentation/api-framework/#events

How to create a store

Hey guys, I found nothing in the wiki or documentation on how to register a store neither how to populate it with a piece. I do play with the HMR plugin right now and I noticed with some research that only pieces are getting reloaded on change (as intended). So I searched for a way to add my helper classes to the client container as pieces so they get reloaded aswell....

Why should I use @sapphire/shapeshift instead of zod? What is the difference?

Why should I use @sapphire/shapeshift instead of zod? What is the difference?

Hi I am getting a permissions error when trying to run docker-compose up

THis is the error that I am getting ``` Attaching to bot_botler-dev_1 botler-dev_1 | ...
Solution:
sorry for reviving this but just realized I did not provide an update, so i did try this and it started but i was getting permission errors on the build dir instead. I removed the user NODE lines from docker file and I have had no permission issues since then

How can I add a slashcommand only for a specific Guild?

I want to create a slashcommand only in a specific guild. I tried doing so in the registery.registerChatInputCommand but it wont let me add a guild, guild_id parameter. any ideas?
Solution:
Because you're not reading the docs properly. It is in the second parameter, not the first.

TypeScript watch and starting bot taking over a minute

Hello, I'm relatively new to NodeJS etc. I started a new project trying to learn more TypeScript with SapphireJS and I installed it with pnpm and am trying to use TypeScript, I am coming from discord.py where I've become used to not having to compile code and having my bot start in less than 10 seconds, which is already considered way too much. I don't know if this an issue with my incompetence or with my computer, but running pnpm tsc --outDir dist/ -w src/*.ts and updating once of my source...

How to get SubCommand Ids

hello there. I want to create slash command mention from command name and command id. In this case, I can get global command id, but not the subcommand ids. ...

Error on Login with I18next Plugin

I started working with the i18next plugin but get this error on login. I include pictures of my index.ts, folder config and usage of the plugin....
Solution:
use the option include: ['src/**/*.json']

Create store for helper classes to access them through the container for hmr to reload it?

Hello there, I do play with the HMR plugin right now and I noticed with some research that only pieces are getting reloaded on change (as intended). So I searched for a way to add my helper classes to the client container as pieces so they get reloaded aswell. So far I do think that I need to put my helper classes in a store and put them into this store but I didn't found anything related to register a store so maybe you smart guys can help me out by explaining or providing any source of tutorial for me how to do so 🙂...

Subcommand unintentionally triggers Events.MessageCommandRun

I have a /dpm subcommand is defined as: ```typescript subcommands: [ { name: "all", chatInputRun: "dpmAll" },...
Solution:
Set a default on one of the subcommands or handle the error

AutocompleteInteraction options#getUser doesn't exist

Why is it saying that the getUser doesn't exist even tho it does?
Solution:
auto complete doesn't have getUser user options cannot have autocomplete set to true read the docs ...

Working with interaction SelectMenuBuilder

When i send a component SelectMenu , and i have a interaction handler for that , but when i selected , nothing happen , how i can handle event after i select menu
Solution:
omg , i realize i named wrong folder , when i fixed , it works , thanks for ur help

Using Typescript in Sapphire.

I was changing between Javascript to Typescript in the framework, and ping command don't work. My code: ping.ts ```ts import { Command } from '@sapphire/framework';...

GUILD_MEMBER_UPDATE - oldMember & newMember

Stackoverflow ( https://stackoverflow.com/questions/66175307/discord-js-guildmemberupdate-not-being-called-except-on-bot-user-changes ) is telling me guild member update event get oldMember and newMember as parameter. ```javascript client.on('guildMemberUpdate', (oldMember, newMember) => { // Fire if user has a role...
Solution:
Not sure. Check your intents I guess. Haven't dealt with this event in a long time. Regardless, it's more of a DJS question because sapphire literally does absolutely nothing for events. We don't for example proxy forward them or anything, we also just use client.on(...) essentially.