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

[SOLVED] quick question; does sapphire defer replies?

does sapphire defer interaction replies? no sapphire cli just @sapphire/framework
Solution:
ive figured out to just use interaction.deferReply() when needing it, ive only used it for eval so far tho

Invalid Form Body (or at least something like that) When the bot tries to register a new command

Hello, I just started to continue on my bot. I just did a upgrade to the most recent version of discord.js and sapphire. But now, the bot started giving me after "boot" cringe errors telling me that he can't register the commands. Exactly: take a look on the screenshot, this **** ist too long! sapphire-version is "next". I use CommonJS btw, that was a previous error 😅...
Solution:
its most likely to do with the fact that your providing the decorator and constructor. you have to provide one or the other, so you can either: - move your preconditions and cooldownDelay into the the decorator and remove the constructor - move your description into the constructor and remove the decorator...

@sapphire/result error in v4

After migrating to Sapphire v4 and D.js v14 and fixed all breaking changes, I've still got three errors from @sapphire/result One of the error is: ```...
Solution:
Anyway I think the reason for your issue might be that you haven't updated TypeScript, so try updating it to 4.9.4

Slash Command with Subcommand Plugin doesnt registering

After i update sapphire v4 and also djs v14 the commands using subcommand plugin doesnt registering their applicationcommands
Solution:
i reinstall subcommand plugin package and it works normally

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