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

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 { ......

string-store input validation

Hi, is there a way I could make a string-store Schema validate its input before serializing, or would I need a separate schema (eg zod) for that?

Precondition variations

I feel really bad creating a thread for this, but just as a sanity check [['ModeratorOnly', 'EventStaffOnly'], 'BreakRoom'], Means (ModeratorOnly || EventStaffOnly) && BreakRoom right?...
Solution:
Yes, it does

crash when loading a autocomplete

The code show an error when I am trying to use a autocomplete in a command ```ts import { InteractionHandler, InteractionHandlerTypes } from '@sapphire/framework'; import type { AutocompleteInteraction } from 'discord.js';...

string-store enum

Hi, is there a way I could store an enum using string-store? or maybe a 1 byte uint. I'm trying to encode an ApplicationCommandType
Solution:
You define an integer of the size you want, you then cast it later. For 1 byte uint that'd be uint8 :)

Precondition doesn't return an error message

```ts import { ApplyOptions } from '@sapphire/decorators'; import { Precondition } from '@sapphire/framework'; import type { PreconditionOptions, PreconditionResult } from '@sapphire/framework'; import type { CommandInteraction, ContextMenuCommandInteraction, GuildMember } from 'discord.js';...
Solution:
Fixed, the problem was from my chatInputSubCommandDenied

How to get name&description (default and localized)?

I know about container.stores.get('commands') , but I don't want to use decorators. Also, I want to get to the localized variants of the name&description. Any ideas how to do it except for adding i18n sapphire plugin or it's the only option?

MikroORM with Sapphire (AsyncLocalStorage)

Is there a good way of creating AsyncLocalStorage contexts when working with sapphire? This is used for forking the EntityManager instance in MikroORM but I can find some other use-cases for it as well. My first idea is rather messy and I'm not sure if it even works: I would monkey patch all loaded pieces and wrap their run() methods with a function that would create the context. Is there a better way to do this?...

Skipped piece

[Trace] -> [structures/EClient.js] [STORE => listeners] [LOAD] Skipped piece 'C:\Users\Des\Desktop\kannabot-v2\dist\listeners\giveaways\giveawayReactionAdded.js.map' as 'LoaderStrategy#filter' returned 'null'.
[Trace] -> [structures/EClient.js] [STORE => listeners] [LOAD] Skipped piece 'C:\Users\Des\Desktop\kannabot-v2\dist\listeners\giveaways\giveawayReactionAdded.js.map' as 'LoaderStrategy#filter' returned 'null'.
...

Sapphire does not load any folders

Every folder in my /src folder haven't been loaded for unknown reason
No description

extendedpaginatedmessage

export class ExtendedPaginatedMessage extends PaginatedMessage { constructor() { super();
Object.defineProperty(this, 'maximumPageAmount', { value: 100 });...
Solution:
export class ExtendedPaginatedMessage extends PaginatedMessage {
public maximumPageAmount = 100;
}
export class ExtendedPaginatedMessage extends PaginatedMessage {
public maximumPageAmount = 100;
}
...

How to transpile TypeScript using Bun?

I haven't been able to successfully transpile the code and run it using the bun build command.
Solution:
bun start in package.json:
"scripts": {
"start": "bun src/index.ts"
},
"scripts": {
"start": "bun src/index.ts"
},
...
Next