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

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 └── discord.js@14.13.0 ...

@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/discord.js-utilities@7.1.2

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

Lib classes types

Where there is no suggestions for the types in the class to override like Command?

Enable slash command for bot owners only

Is that possible for register a slash command to be visible only for a specific user like the bot owner?
Solution:
it is not, Discord API doesn't allow that. At best you can set preconditions and set required role to Administrator

Global precondition

I'm not able to answer a custom message with global precondition (global.ts) in preconditions folder ```ts //@ts-ignore import { AllFlowsPrecondition, Piece, Result } from "@sapphire/framework";...
Solution:
it is chatInputCommandDenied and contextMenuCommandDenied not commandDenied since v3 of the framework: https://www.sapphirejs.dev/docs/Guide/getting-started/updating-from-v2-to-v3#sapphire-events-added

The inferred type of 'parse' cannot be named without a reference to...

Hey! I am getting this error while trying to create an interaction handler: The inferred type of 'parse' cannot be named without a reference to '.pnpm/@sapphire+result@2.6.4/node_modules/@sapphire/result'. This is likely not portable. A type annotation is necessary. This is my code:...
Solution:
yeah so basically pnpm doesn't patch typescript to ensure that it considers the folder where it dumps the non hoisted files for the typescript server/compiler. It's a major flaw in pnpm. If you look for example at Yarn which also has a PnP mode (opt in), they do patch TypeScript for this very reason. It's extremely dumb to think that you're non compliant solution will just work OOTB with the whole ecosystem and I honestly blame pnpm devs for this very much. Wouldn't be surprised if they have various open issues on the topic, have never checked. Basically any installed package that then module augments another installed package (transitive or not), will not work with pnpm. In our case, @sapphire/framework has a transitive dependency on @sapphire/pieces and also module augments @sapphire/pieces, and discord.js for that matter....