sapphire-support
discordjs-support
old-sapphire-support
old-discordjs-support
old-application-commands-and-interactions
how to make fetchPrefix return a regex?
Is this possible? Like returning the regex prefix? I get a typescript error.
Solution:
https://www.sapphirejs.dev/docs/Documentation/api-framework/interfaces/SapphireClientOptions#regexprefix
Regexes go in a different property and take priority over fetchPrefix https://github.com/sapphiredev/framework/blob/d58810f76676184061e775e6249a4d01bdde67c3/src/optional-listeners/message-command-listeners/CorePreMessageParser.ts#L21...
messageSubcommandNoMatch listener not working
Hello again
Currently I am trying to handle the

messageSubcommandNoMatch
error. I've registered a listener for it:
listeners/messageSubcommandNoMatch.ts
```ts...
Invoking Command method from other command
Hey all, I’m not really sure if this is a “Sapphire support” type of question more than a TypeScript one (I’m new to TS in general)
But is there any way to invoke a commands messageRun or the designated method from say another command class (something like Java reflection/does sapphire have a command handler to grab the appropriate method?) or is the best way to extract the code to a new file then just call that from both commands?
Basically I have a command which is:...
Solution:
You can leverage
this.store
, just make sure you pas all the right arguments:
```ts
import { Args, Command, type MessageCommand } from '@sapphire/framework';
import type { Message } from 'discord.js';...error
Yesterday I had this error which was fixed by simply updating the framework
...
TypeError: Cannot read properties of undefined (reading 'parseConstructorPreConditionsRunIn')
TypeError: Cannot read properties of undefined (reading 'parseConstructorPreConditionsRunIn')
Solution:
This is the pitfall of not using either idHints https://www.sapphirejs.dev/docs/Guide/commands/application-commands/application-command-registry/registering-chat-input-commands#idhints or using bulk overwrite https://www.sapphirejs.dev/docs/Guide/commands/application-commands/application-command-registry/advanced/setting-global-behavior-when-not-identical
So you should do either of those and in case of the former prune all your currently registered commands using whichever way to unregister commands.
FWIW the logging when you first register a new command would’ve told you to add the ids to idHints....
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
Solution:
With the subcommands plugin
https://www.sapphirejs.dev/docs/Guide/plugins/Subcommands/getting-started#chat-input-command-slash-command-usage...
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()
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