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

welcome bot

How do you make the bot send a welcome message
Solution:
1. Add a config command so people can configure the channel it should be sent in 2. Add a listener for guildMemberAdd, the DiscordJS event for when a new member joins the server 3. When that listener pops send a message to the configured channel, or the system channel if none was set. Also refer to our user guide for getting started: https://sapphirejs.dev...

How do you register paths for pieces? Also have an additional question when this one is solved.

I have a file structure as outlined below, I am wondering how I can make sapphire recognize this path and register the respective stores for that path. I am running into the issue of even when calling <Store>.registerPath and pointing to my pieces folder it isn't loading the commands I have.
No description

Question

How do i get rid of this “warning”(?)
Solution:
No description

frustrating unknown interaction

I'm getting alot of unknown interaction errors and I have no idea what it means
Solution:
I realized the problem: I was hosting my bot on my trashy local network and not my vps, that seems to be the cause of the problems. Thank you!

Distube and sapphire

I am trying to use the npm of distube since the lavalink was not working for me and before distube does work, the problem is that the file where the distube client is defined I pass it to load it to the index and I make a console.log(client.distube) and if it detects it but when using it in a command it comes out as undefined and I already tried to do everything and nothing, If anyone can help me with this, I appreciate it, whether it's Lavalink or Distube, to help me
Solution:
@Skyra used to have lavalink with sapphire long long ago but you can go back in the commit history to find it eventually. That said assuming you're gonna be playing from YouTube keep in mind that doing so is against the YouTube and by extension Discord's terms of service and can lead to your bot being terminated. Having music functionality will certainly give you a very low chance to get your bot verified. Also in regards to YouTube, people can already use voice channel activities to listen together....

interaction.options.getMember() not definable?

Somehow interaction.options.getMember() is not valid... While on the Discord.js docs it is. I already made Member to be outputted to a message, and it says @Jarvo, so it should be correct... ```js import { Command } from "@sapphire/framework";...
Solution:
Oh. Nevermind. I fixed it already.

Would there be a way to make a command list?

How would I make a command list, for example you would use !help (or !help <commandName>) (example message)
Commands...
Solution:
Look at some of the bots that use sapphire (for example @Skyra ) but in shot you get the data from the container which gets access to the stores. How you want to parse and format that data is up to you. We won't be hand holding all the way to making the command because at that point we may as well write your bot for you (which would be a paid comission)

Clear Command Cache?

Since the other one removed his message... How to clear the cache using Sapphire?
Solution:
You should set add this line to your index file before you log in, which will overwrite all commands each time. ```ts import { SapphireClient, container, ApplicationCommandRegistries, RegisterBehavior } from '@sapphire/framework'; ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(RegisterBehavior.BulkOverwrite);...

InteractionHandler Buttons

I have a problem with my buttons. Somehow they don't work... I guess it's something easy, but I can't figure out what it could be. The buttons are in a folder named interaction-handler/Buttons The error I am getting is: ``` [ERROR] Encountered error while handling an interaction handler run method for interaction-handler "CancelSetup" at path "C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\src\interaction-handlers\Buttons\Setup\CancelSetup p.ts" Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred....
Solution:

ValidationError: Expected a string primitive

```ts C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules@sapphire\shapeshift\src\validators\StringValidator.ts:73 return this.ip(6); ^ ValidationError: Expected a string primitive...
Solution:
I fixed it, my dev had accidentally removed the .setLabel().

Need help for ContextMenuCommand

I have the below code: ```ts import { PaginatedMessage } from "@sapphire/discord.js-utilities"; import { Command } from "@sapphire/framework"; import { config } from "../../utils/config";...
Solution:
@Jarvo
- public override async contextMenuRun(interaction: Command.ContextMenuCommandInteraction) {
+ public override async contextMenuRun(interaction: UserContextMenuCommandInteraction) {
- public override async contextMenuRun(interaction: Command.ContextMenuCommandInteraction) {
+ public override async contextMenuRun(interaction: UserContextMenuCommandInteraction) {
...

How to use sapphire framework decoraters plugin

I saw a youtube tutorial for making a discord bot using sapphire framework in which the person used decoraters to make command but when i tried i am getting this weird error.
Solution:
Are you using "@sapphire/ts-config/decorators" in your tsconfig.json? Else, please show the aforementioned file. This error comes from using ES decorators rather than the legacy ones.

check if message starts with the prefix

how can I check if a message starts with the bot's prefix? Including the bot's mention
Solution:
Seeing as this is a follow up from your previous post and you do not have access to the command context you'll have to parse it out manually ```js const possiblePrefixes = ['!', '<@PUT_YOUR_CLIENT_ID_HERE_FOR_THE_MENTION>', 'etc']; const msg = {...

Get command used with a message object

Is there any way to know which command was used only by having a message object?

Duplicate identifier "Preconditions" when module augmenting "@sapphire/framework"

Please see screenshot
Solution:
unfortunately, the type keyword cannot be used. instead, it should be an interface because it will merge the content with the pre-existing interface
No description

Object literal may only specify known properties, and 'tasks' does not exist in type 'ClientOptions'

Hello there, I created a new project with sapphire new, using the minimal template. I'm trying to add the @sapphire/plugin-scheduled-tasks plugin. Following the doc, I use the npm install command and I added the register in the setup.ts....
Solution:
Interesting I think this happens because tsup outputs the file as .d.ts for CJS instead of .d.cts because it works just fine when using ESM For now if you add a line import '@sapphire/plugin-scheduled-tasks'; then it's fixed @Pandraghon pinging @vladdy here as well for reference...

Subcommands Refusing to work for anyone but me?

I have a command called lm and card which is in a leveling module, and these are the only subcommands in the module and they dont seem to work for anyone else but me. They were working a few days ago, was there a change that checks for bot owner permissions?
No description

Unknown Interaction

For some reason whenever my bot reboots, commands that clearly exist will error with “Discord API Error: Unknown Interaction”. The strange part about this is that it will often execute the command and then error. Is there some way to avoid this? It has also randomly happened on times that wasn’t after a reboot as well.
Solution:
seems to be working so far? nobody has reported encountering that issue recently so I’m going to assume deferring the reply fixed it.

Interaction handlers problem

hello, I have a problem when creating modals interaction, always get weird error logs (attachment 2) I don't know, what should I do? i need to create some registration sections (which is i copy from djs-docs for testing), when user execute command example: /register will show the embedded button, the button is fine, inside button(interaction handler) is the modals code (attachment 1)...
Solution:
Includes will be fine just make sure to return this.some as well. In fact better to do if(condition) return this.some() so you don't have a negated if condition.