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

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

Export Commands and Parameters

This is only loosely related to Sapphire, but I was wondering if there is an easy way to export a CSV or something that has the commands and parameters in it for documentation purposes. I have roughly a hundred commands and have never gotten around to doing any documentation, but I’m finding the need to write docs for them now. Is there an easy way to do this or does anyone have any ideas on how to best do it?
Solution:
Use this.container.stores.get('commands') to get a Map<string, Command> which can be turned into a Command[] then use a JSON to CSV converter library (or parse it out yourself)

Error

node:internal/modules/cjs/loader:1148 throw err; ^ Error: Cannot find module './lib/arrayStrictEquals.mjs'...

Cannot find how I can use buttons

I want to create a message with some buttons for people to click on and recieve some messages something like what it is in the attached image. What I cannot figure out is how do I use it. I tried to read the documentation and I'm pretty sure im missing a big gotcha https://sapphirejs.dev/docs/Guide/interaction-handlers/buttons...

Validation error

What can cause this error on button click? It's this specific button (dailyneko-modal), nothing else causes this. dailyneko-cancel works. Components creator:...

main bot spawn child bot?

Hey guys,
I want my discord bot to spawn another discord bot via a listener “child process”, does sapphire support anything like this or maybe even djs itself? Thanks so much 🙏...
Solution:
Sapphire is just a framework on top of discord.js so no, what you're trying to do requires some extra steps which neither sapphire or discord.js do for you. You have to write the logic for spawning the child bot yourself.

baseUserDirectory with tsx

How do I use baseUserDirectory with tsx? Seems that it doesn't load the ts files relatives to main ts source code