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

Listener run() signature

Feel like I'm missing something obvious.. how do I find out the correct signature for a run method of any given listener - they're different for each event. I'm sure there's an obvious way to get this, without trial and error and debugging to see what's available to it - where am I not looking? ```ts import { Events, Listener, ListenerOptions } from "@sapphire/framework";...
Solution:
The only thing you can do is extends Listener<typeof Events.GuildCreate> but that won't implicitly type the run parameters, it'll just error if you provide the wrong types. Sadly TS offers nothing better.

PaginatedMessageEmbedFields empty array

So im kinda confused with the docs and im always getting empty array's when im trying to setItems over an array. i logged already my output from the array and its just an double Object (as it should be afaik) when im accessing the content inside that Object i get my Output as i wanted it but for some reason the PaginatedMessageEmbed can't access it... am i missing something? Thats some of my code: ``` ...
Solution:
You're assigning the result of .make() to a different variable and then you call the original object's run. Change the last line to pages.run(interaction) or dont assign it to a different variable.

Issue registering command on a specific guild using guildIds

Hello, I am having some issues trying to register a slash command to a specific guild. I have this "dev" command that should be registering on one guild (my dev guild), for that im specifying the guild ID in the guildIds array in the registry options. I had an issue before were the command was being registered into both (global and guild) so it was showing duplicated commands. To revert that, I deleted every global slash command aswell as guild commands and let sapphire handle the registration o...
No description

Subfolders Inside Commands Folder

Can i put the commands inside subfolders in commands folder ? example command path : commands/public/ping.js...

Encountering Error `TypeError: emitter.getMaxListeners is not a function`

Happens as soon as I run the code. I am using ts-node so I have no idea if this is the reason why.
Solution:
I mean, using ts-node is like a minefield, it doesn't always behave as desired and most of the time it's more efficient to use tsc --watch + node . 😅
No description

Problem loading virtual pieces

If I go by file system mode, all commands & listeners get loaded. But if I go by virtual piece route, only 1 command gets loaded. Here is my repo - https://github.com/MRDGH2821/Discord-Ban-Utils-Bot/tree/rewrite-sapphire (rewrite-sapphire branch)...
Solution:
Solution: 1. Explicitly put piece name, there's no way to set it dynamically (unless you set it in a variable & assign it wherever needed) 2. Don't use virtual pieces...
No description

Am I doing this wrong? Message doesn't send for preconditions, but the precondition works FINE

It just says the usual "The application did not respond."
Solution:
you need to implement chatInputCommandDenied listener still wherein you can send error.message. Also see https://sapphirejs.dev/docs/Guide/preconditions/reporting-precondition-failure...
No description

Problem with loader file generator

generate-loader is generating a loader at unintended location with .js extension applied 🤔 Also I have nested listeners, so the paths for those are not getting generated porperly...
Solution:
Fixed it in v1.9.3 @MRDGH2821. I swear I encountered and fixed that bug before but it somehow slipped through the cracks. I swear I had it working when I implemented this.
No description

ChatInputCommand

How to know if a interaction comes from a slash command?

[EMPTY_MODULE] Error:

I’ve looked at some of the other posts that was also related to this issue and used those solutions but i still don’t have a solution, file:
Solution:
interaction-handlers should be its own folder, not nested inside listeners.
No description

Error Handling

[ERROR] Encountered error on message command "test" at path "C:\Users\cmart\Desktop\Discord Bots\Sapphire\src\commands\Developer\test.js" Anyway of removing these error messages if the type of the error is a string? I don't want this error showing up on console when I do stuff like, for example: ```js...
Solution:
I opened a PR to add an example

PaginatedMessage: refresh pages after setPages()

How can I update or refresh PaginatedMessage after use setPages()? Currently, I have to click next/prev button to refresh all pages....
Solution:
Sounds like you're trying to modify the pages after calling run. That is not what PaginatedMessage was designed for. Run should always be the last thing called.

NPM script stops working when tsconfig extends @sapphire/ts-config

My npm package has a simple build script:
"prebuild": "rimraf dist types",
"build": "tsc",
"prebuild": "rimraf dist types",
"build": "tsc",
...
Solution:
to your prebuild add tsconfig.tsbuildinfo, that'll probably fix it. It's the cache file for incremental builds which are enabled by the config.

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.