Sapphire - Imagine a Framework

SIA

Sapphire - Imagine a Framework

Sapphire is a next-gen object-oriented Discord.js bot framework.

Join

sapphire-support

discordjs-support

old-sapphire-support

old-discordjs-support

old-application-commands-and-interactions

use wildcard paths on InteractionHandlerStore#registerPath

Hi, are we able use wildcard paths while registering a new path for a store? or is their away to do this without writing a helper for that for example:
this.stores.get('listeners').registerPath(join(this.rootData.root, './handlers/events')).registerPath(join(this.rootData.root, "./integrations/**/*"));
this.stores.get('listeners').registerPath(join(this.rootData.root, './handlers/events')).registerPath(join(this.rootData.root, "./integrations/**/*"));
...

Interaction Handlers & "Button is not for you" response

Hi! My problem is: I have a bunch of buttons that implemented like interaction handlers, and my goal is simple - I want to respond to a user with "This button is not for you" if "parse" method fails. But I can't do that because if I respond to 1 handlers, others will break with "interaction already replied". Is there any sort of and event if sapphire couldn't find any parse method that will work so I can response with my message? Another solution I think of is just respond with any handler, and before responding check if interaction is replied. If it is - do nothing, but then - we need to handle replied interaction in our "run" method. Tbh adding this small feature feels like a pain so I don't even know if I wanna do that if there is no simple solution :D...
Solution:
Truth be told I would advice against it anyway because it goes principally against how Discord tells us to use interactions. Interactions should only be replied to once. The only consistent way to achieve this is to use something like discordjs' awaitComponents where you can user filter instead of sappire handlers. An example of this can be seen in PaginatedMessage i.e.e from @Dragonite

VoiceStateUpdate

help, im experiencing an issue where the newState object in the voiceStateUpdate event is either returning as 0 or not returning a VoiceState object at all. also oldState only returns something...

Problems with plugin api

Hey! I'm attempting to setup my bot with the plugins api. I've managed to make a route but whenever I start the bot I have no indication of the api starting. I've checked this.container.client.server.server.listening, which returned true and I also listed routes through the container. The problem i'm having is whenever I attempt to send a curl request or a web request to the url I get a connection refused error....
Solution:
you have to put listenOptions in the api object

Timestamp problem

Hi there! I'm using Timestamp from the time-utilities (latest) to convert a duration in milliseconds to a timestamp like this: ``` const timestamp = new Timestamp('HH:mm:ss');...

Is there a better way to handle both message and slash commands?

Docs say that you have to override messageRun method to handle message commands and override chatInputRun for slash commands. This leads to unnecessary code duplication, since logic would be mostly the same. discord.py or serenity expose something like hybrid commands , so you can write a single handler for any interaction, is there an equivalent for Sapphire?...
Solution:
just extract most logic to a separate function and call it from both, i.e. the ping commands from sapphiredev/examples repo

I have use @/ as Root

I have used @/ as root but now it doesnt finds the modules I'm not sure how to fix that anyone that can help me out?
Solution:
setting it in only tsconfig isnt enough. Ts doesnt recompute paths when compiling. Either use NodeJS built in submodule imports and switch to # instead of @ in the process, or use something like the module-alias package.
No description

Is there a way to make an Event (registerApplicationCommands) 'wait' before triggering?

Okay so I created a handler named unregisterer.js I'm calling it in another handler named bootstrap.js bootstrap.js is then imported into index.js then called as such await handlers() on ready event I use a custom structure named SlashCommand imported in every command file (to replace Command of @sapphire/framework): this only serves to prevent spamming registerApplicationCommands in every single command file...

SubcommandErrorEvent how to?

I have this code for defining listener for subcommand error event ```typescript import { ChatInputSubcommandErrorPayload, SubcommandPluginEvents,...

Button Interaction Pass Data

Hello im traying to make a coinflip game which is simple, but I need to pass some data to the button handler and I'm not sure how to do it, and I even need to send and embed to an other channel and interact with 3 differents button which modify the embeds in different ways, if someone can answer all of that I will be happy where some code if something is wrong let me know. ```ts export class GameCoinFlipButton extends InteractionHandler { public constructor(ctx: InteractionHandler.LoaderContext, options: InteractionHandler.Options) {...

How to organize commands?

Hello, Im new to TS and Discord.JS, but I have knowloadge on programming, but this framework is new to me, I need to make different commands, I have create 3 folders, user, admin, games, every dir has it owns games and class (not made all but im there), and this is a simple class Im not sure if this what Im doing is correct, but for organizing it should be. this is the code I have made if there is a better way of doing this lmk:...

Help me to setup this sapphire typescript

Hello im new to ts and discord.js, I have made some bot in discord.py, but I wanna level up and using typescript and sapphire, but I have no idea how to, please someone?

an easy simple question

what file handles parsing = for options?

Which type to use for context in scheduled task plugin error listener?

Currently updating my bot code to the new version of djs and sapphire. i struggle to find the correct type that has this piece.nameproperty, any idea? I checked skyra but their implementation looks more complicated than what I want to achieve. ```ts import type { Events, TaskErrorPayload } from '#lib/types'; import { Listener } from '@sapphire/framework';...

Better way of displaying an error response to the user for components? (this.none)

Hi, I was wondering if you could send an ephemeral message to the user when the interaction component (lets say a button) returns this.none() or do i have to have to pass an argument to this.some() with the error...
Solution:
the latter, none and some are only used to determine which handler to use among all the handlers as they are not statically bound to i.e. custom ids or commands due to the dynamicity of that data.

PaginatedMessage on a user-installed app inside a guild will return thisMazeWasNotMeantForYouContent

When running a slash command with PaginatedMessage, the bot will only return the intended response in DMs and Group Chats Using the command in Guilds will cause the interaction to return #thisMazeWasNotMeantForYouContent...

Questions to new API Implementation

So I am currently rewriting my api endpoints in sapphire. I came acros some questions: 1. How can I define that main route "/"? how should I name that file? get.ts ? 2. Following REST I want to create get, post, put etc routes for a specific slug e.g. birthday. Do I need to create 4 separate files for this with each a different filename? this does not really look like an effective way?...
Solution:
1. Yes 2. Yes, mind we follow the structure libs like Nuxt and Next also use here 3. routes/subfolder/file, or register your own routes folder just like you would register any other custom folder for a store. Has been asked many times before, finding an example with a search for it shouldn't be too hard. 4. In every extend. They're still Pieces with options. Just different options. 5. Answered above...

How would I add the prisma client as property to the Augment.d.ts?

as the title said. This is how our implementation worked for over a year, but while trying to upgrade all of our deps. there is no prisma client available anymore....
Solution:
I forgot to prisma generate after reinstalling prisma dep haha
No description

Roles being removed directly after being assigned

Hey all, I'm not sure if this is a Discord.js, Sapphire or me thing so I figured I'd just post here: This is logging output: ```ts DEBUG: Message Command - Unspecified Reason DEBUG: Break Command - Start...

Accessing a public method in a listener's class

Hi, I currently have a public method on my listener that i want to access from another listener, below is an example of my current code: ```ts ... export class UserEvent extends Listener { private interval: NodeJS.Timeout | null = null;...
Solution:
Seeing you use TypeScript, you can do this instead:```ts import type { UserEvent as TimerUserEvent } from './event-name.js'; export class UserEvent extends Listener { ......