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

Register a command on every guild

Hey, I am working on a bot, where I need to register some commands on every guild the bot is on. I cannot use global commands in that case. I was not able to find a straight forward in-build way to do that, so I wanted to ask, whether I missed something, or whether I have to implement that manually. I am still pretty new to sapphire, so if I need to do that manually, would be great if someone could give me food for thought....
Solution:
You'll pretty much have to end up handling registering yourself, which these methods make easier than doing it raw through the DiscordJS methods. As opposed to using the registerApplicationCommands in the command that is. Then as for how it will help, you can register the commands yourself to the guild in question when you receive a guildAdd event.

Intent question- paginatedmessage

Does paginated message require any intents or am I fine with just app command and bot scope?
Solution:
you need Guilds intent if you want the command to work in servers

Handle secondary bots from main

Hey! I am working on a meetings system that would require my bot to join meetings and record transcriptions. As we have several meetings and sometimes they overlap, I'd like to handle two to three secondary bots that would join the meeting when others are occupied. Is it possible to handle this logic in sapphire? How could that be done? Thank you!...
Solution:
Sapphire, nor DiscordJS for that matter, are set up for running multiple bots on the same process. So instead of overcomplicating you’ll just make 1 codebase then spawn it multiple times with multiple configs of Docker or whatever you use to spawn the process and pass different tokens through environment variables.

subcommand

what does this error mean: TypeError: Cannot read properties of undefined (reading 'parseConstructorPreConditionsRunIn')...
Solution:
That you need to update your dependencies, in particular @sapphire/framework

How would I go about forking a plugin? FInding some difficulty due to them being under a monorepo

all in the title
Solution:
If you want to make a small change, use patch-package

Subcommands

how do subcommands work with slash commands on sapphire

subcommand not working

using @sapphire/plugin-subcommands, my command doesnt respond but it registered the application command code: https://hasteb.in/qPcltHcGbxPjEVI...
Solution:
Seems to be a bug with how preconditions are enforced for subcommands? haven't tested it a ton. I added a console.log in the cooldown precondition and it seems to be consumed twice for each command run. @iaqi For now the best way to continue would be to disable your default global cooldown, or double the bucket limit....

Manual task not triggering

im trying to create an unmute task but it doesnt seems to get triggered that reliably I also tried copy pasting the documentation code for manual and it also gets triggered rarely here are some snippets of my code UnmuteUserTask.ts...

yarn recommended over pnpm?

Why is yarn recommended in the sapphire CLI over PNPM when PNPM is known to be the faster and more efficient package manager
Solution:
Yarn v4 is new version of Yarn that we recommend switching to as Yarn v1 has long since been deprecated.
"But I don't see any update on [source]?"
That is correct. Yarn v4 is installed through Yarn itself. You configure Yarn v4 on a per-project basis. How you installed Yarn globally is largely irrelevant to this (corepack, volta, something else). How to install Yarn v4 for your project? Simply write:...

lib folder

I notice when making a new sapphire project with the CLI a lib folder is made. What exactly does the lib folder do, and what files should be within? I'm trying to follow convention
Solution:
Anything really. The important part is that for example you should only have files with commands in the commands folder, so then where to put things like utilities. The convention we follow is to have a lib folder for that.

Setup 3 bots with Sapphire

Hello ! I'd like to set up 3 bots with Sapphire. But I'd like to have everything in the same code to share certain components. What I'm doing for the moment is creating 3 instances of SapphireClient, in which I define a path to retrieve commands, listeners, etc ......
Solution:
you're far far better off making a module with its own package.json for the shared code and then use workspaces to install it in your bots

I have a problem

avatar.js not working code : const { Command } = require("@sapphire/framework"); const { MessageAttachment } = require("discord.js"); ...
Solution:
First of all, next time wrap your code in codeblock please. Wrap it in triple backticks: ` code goes here ``​...

error when starting up my bot ?? :/

version: npm ls discord.js Amazigh Chatbot@ D:\Bureau2\Amazigh Chatbot └── [email protected] ...

@sapphire/snowflake question

const { DiscordSnowflake } = require("@sapphire/snowflake");
DiscordSnowflake.generate()
const { DiscordSnowflake } = require("@sapphire/snowflake");
DiscordSnowflake.generate()
Will the length of the generated numbers always be 19? I'm making a modal where users need to input a code generated by this...

Maze error - paginated message

I am getting this on a paginated message
Solution:
I replicated them 1:1, see last commit on the branch

Button Handler

is there some sort of built-in button handler in sapphire? if no, how can I handle them

Ephemeral PaginatedMessages are unusable

https://ss.clanware.org/CdquvjYO.png It always says that it's someone else's message. @sapphire/framework@npm:4.7.2...
Solution:
Unfollowing this because it's fixed in @sapphire/[email protected]

Bot wont respond to any command + wont register slashes though it says they are registered

My bot becomes online, responds to mentionPrefixOnly listener but it doesnt respond to any command Dependencies list: ```json { "@kaname-png/plugin-subcommands-advanced": "^2.4.0",...
Solution:
You can use . instead, I think 🤔
No description

how to change the client on the container's type to my custom client

no more details, that's all I want to know really

ApplyOptions

does ApplyOptions from @sapphire/decorators work with JavaScript, if yes, how would that work
Solution:
It doesn't