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

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

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"
},
...

How to find the context responses of Identifiers

I am trying to find the context responses of the Identifiers.preconditionClientPermissionsNoPermissions (or other Identifiers) to handle my own response, but i can't find it anywhere

utilities-store

from what information I've read. I should think of this as more of a service? which would allow the use of all files inside the store to be used with strings instead of importing them for each command, making the command cleaner and shorter?
Solution:
You can expose functions to this.container.utilities.<your thing>. As per the readme example it would be this.container.utilities.sum.add(...). If you want to put raw strings in there use public class properties or getters. So yes I suppose you're right. It's a bit of a niche thing for people who don't like many imports. I don't use it personally....

api auth via expo

so i am using api plugin and trying to auth with expo but i get an error browser error ```...
Next