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

Error [EMPTY_MODULE]: A compatible class export was not found.

I'm trying to add code to the ready event that runs every "x" minutes. The code is a bit long and that's why I created a second file for the ready event. (Also, I want to have that separately.) I have everything that has to do with the function I want to implement in a folder called: "Extra: and inside you will have the index.js file (which will have the listener ready )and will have another file that will have "channels.js" where you will publish the function and a "functions.js" that will be in charge of making some canvas images. ...
Solution:
Prefix the file names with a _ Every file is expected to be a class export, unless it's skipped with a leading _ Alternatively move the folder out of the listeners folder...

How to reset the command cooldown in JS

I've been searching around in the server and the only solution I found was written in TypeScript, any way to do this in JS?
Solution:
this.container.stores.get('preconditions').get('Cooldown').buckets.delete(this);
this.container.stores.get('preconditions').get('Cooldown').buckets.delete(this);
now the top link code is JS, see how easy it is to remove types....

Logic question

I have a bot that is in about 20k servers and serves somewhere around 21m users. It uses presence intent to give roles to users when they add a specific custom status. My idea was to split the bot up like so due to the fact that i'm getting slammed and won't to even distribute the load of the bot. This was my idea, but I realized would this even work as how would I add the roles to the users from the worker considering I cant use the same shard.
Solution:
If you mean rest as in http server then yes @sapphire/plugin-api but that doesn't take away the above. At the end of the day sapphire and discordjs are going to spawn 1 parent process with 1 token and route everything through that process. For true scalability however you'd want multiple processes.
No description

presenceUpdate require member cache?

I know some libs do this and honestly can't find in src where it's fired off, so was just wondering if this is this is the case here as well.
Solution:
Sapphire is a framework on top of DiscordJS. Sapphire only handles registering and firing commands, listeners, etc based on events and data provided by DiscordJS. That is all to say, this is a DiscordJS matter. And afaik for DiscordJS it does require cache yes...

listener not loading.

I have no idea what the issue is, but the listener just never loads. ```ts import { Listener } from '@sapphire/framework'; ...
Solution:
i've got it, i used virtual pieces rather than the default file system. i assume it has something to do with the nx setup, etc.
No description

Precondition not throwing errors.

I've setup this precondition to make sure the user is in a voice channel, when the user is in a voice channel it runs perfectly fine. But if one of the conditions is not met the error is not thrown and the command does not respond. ```ts import { Precondition } from "@sapphire/framework"; import { CommandInteraction, GuildMember, VoiceChannel } from "discord.js";...

Equivalent of z.function from zod in shapeshift?

The title describes the issue
Solution:
there is no function validation yet in sapphire. I tried to add it a month or so ago and I was following instructions from @vladdy and @kyra but I had no idea what they were describing or how to implement it. I think either of them could add it in an afternoon given not procrastinating on it but alas. The equivalent of safeParse is .run(data: unknown): Result: https://github.com/sapphiredev/shapeshift/#rundata-unknown-resultt-error-given-a-validation-you-can-call-this-method-to-check-whether-or-not-the which returns a Result on which you can call .isOk() / isErr() / .unwrap()...

Property 'getUser' does not exist

Am I doing something wrong here? https://pastebin.com/qV3dD31T...
Solution:
I ended up restaing VSC and the error just went away. Don't know how that makes any sense.
No description

args provided but not found?

e
Solution:
nvm again i forgot to put them in options option
No description

Validation error in `SlashCommandBuilder.addSubcommand`

I'm registering a command with a single sub command as such (pardon the poor indentation, copying to Discord is... annoying) ```ts registry.registerChatInputCommand( (builder) => builder...
Solution:
instead of importing the functions just pass the builder callback: ```ts registry.registerChatInputCommand((builder) => builder .setName('leaderboards') //...
No description

Decorator issue

Having a weird issue with the decorators.. I've just updated all of my dependencies to the absolute latest version, but the error is still persisting here. It seems to be quite random, but there are steps I can take every time to get the error. Note that I've always had "experimentalDecorators": true, as part of my tsconfig - everything I've seen so far suggests adding that. ...

DurationFormatter

how do i format ms to custom formatted duration? like i want this 5d 21h 45m 12s but not this 5 days 21 hours 45 minutes 12 seconds i use this: new DurationFormatter().format(some duration)...
Solution:

sapphire not acknowledging chat input commands?

i've properly registered a chat input command, and i'm able to send it from my client, shows up fine etc. however, chatInputRun for the command never seems to run - I put a log at the top of the function that never happens, and the interaction is never deferred etc. the same command works with messageRun, so I know it's registered with Sapphire in that sense at least. I also logged any time interactionCreate fires, and it's receiving the interaction perfectly fine... I'm at a loss, what am I mis...
Solution:
yep, was just about to update - was a precondition that somehow broke with a dependency update 😭 i disabled it and it ran fine

can we add a string to the command content response by PreMessageContentRun ?

Like i have in my messageRun command file: message.channel.send(‘hi’) In the event file, i use like: payload.messageContent += ‘ everyone’ then bot’ll send to channel: hi everyone...

How do I force a user to specify at least one input?

I'm working on a bot, and at the moment the bot errors out if the user does not specify any argument. For reference, this is how my command is structured: ```typescript public override registerApplicationCommands(registry: Command.Registry) { registry.registerChatInputCommand((builder) => builder...
Solution:
Strangely the issue doesn't appear to be occurring anymore.. will report back if it happens again.

Any common guideline for making plugins?

So what I'm trying to do is to create a module of commands which made available through plugin system. I used the following template to start up but it's currently not able to run properly. Problem : I mostly followed other plugins as example where you create a class extending Plugin and define the hook functions. Later on registering the hooks to the SapphireClient instance. My code roughly looks like this ```ts...

Just updated to 5.2.1 nothing working and no errors

My bot is apparently logged in, and good to go according to the logs. Discord shows the bot status green. But no commands at all work. I was on Sapphire 2 and I generated a fresh Sapphire project and basically painstakingly copied everything over sicne that was the easiest upgrade path for me. All of my secrets are in the .env file....
No description

Subcommand groups

how can I create subcommand groups that also have optional string / user selection in the command?

@sapphire/type Issues

Hi there, I had been attempting to use the eval command provided in the full template (because I was too lazy to write one) and, upon attempting to install @sapphire/type I'm given the error below (please see the attached image) and I had initally thought it was an error with me not having node-gyp installed (I do, and have verified it, I've uninstalled the XCode Developer tools and reinstalled just to make sure it wasn't that as well), since I had searched and attempted to troubleshoot before making a thread, however, upon closer inspection, it would appear that it's attempting to fetch a release that isn't there. I do apologize if I've missed something important, if that's the case, I was unable to find it and I am once again, highly sorry. Thank you for taking the time to read this :D Additional Information NodeJS Version: v20.23.1 Package Manager: pnpm...
No description