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

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

API Plugin Documentation is not up to date anymore

Hi :) I just read in #@sapphire/plugin-api Methods Error that the plugin was reworked, could I request that the new usage is documented/adjusted in the guide? I am very confused on old vs new usage...

Dupliacte commands

When registering commands with Sapphire, it created duplicate ones on top of the old ones from legacy codebase. How can I delete duplicate ones so only the currently active (Sapphire generated ones) remain? Deleting all commands and re-registering them is also an option I can do, just not sure how

Freeze on await client.login()

```ts import './lib/setup'; import { LogLevel, SapphireClient } from '@sapphire/framework'; import { GatewayIntentBits } from 'discord.js';...

string-store & strings

I've been trying out string-store and it's a great utility, but it's becoming annoying to stringify everything (and it also makes my formatting look bad because a lot of times it forces prettier to wrap the lines). When I serialize a custom id, I have to do .setCustomId(store.serialize(Id.EditSomethingButton, ...).toString()), and when I just use a normal custom id, I have to do .setCustomId(Id.EditSomethingButton.toString()). I know this isn't a very big problem; should I just suck it up? (...

message kits

So I'm looking at the active sapphire bot and its dashboard and they have "message kits" that can change how the embeds look and such. I'm wondering if its just exclusive to them or is there away to can build something like this for myself. I'm using the template typescript version. I know I can setup centralized embeds for different categories, but I didn't know if there was a plugin already made for this, or would I have to create it myself ?...
Solution:
and @Xndo this would be a bot developer implementation which you would have to implement from your end, i dont think implementing this in the framework would make any sense

StoreRegistryEntries Augmentation

I'm finding it a little difficult understanding how to augment the interface, specifically the commands store because I have my own extended class from sapphire's Command, and I keep having to do as <Class> whenever I retrieve a command from container.stores.get('commands').get(commandName). How am I supposed to do it? Scrap the above. From what I can see each store is stronly typed and a new type can't be assigned. This would be confirmed when looking at skyra's codebase too because types are manually casted....

Re-registering Command Within Scope of chatInputRun

Hey all, In short, I've been looking for a way to re-register a command definition in a subcommand that allows an admin of a server to create a currency type (XP, SapphirePoints, etc., it's arbitrary). These currency types needs to show up in other subcommands for admin, therefore re-registering seems necessary to alter the choices presented for such fields. The only thing that works without restarting the client seems to be a call to this.store.loadAll()....
Solution:
I would first try doing it through discordjs' client.application.commands but if that doesn't suffice or you want to be lazy then I believe from the top of my head you can also just call .load() on the specific command as opposed to loading all because I'm pretty sure load all does just that but in a for loop. Other than that though, you are on the right track. Yours is a bit of an edge case honestly. What you can also consider is not limiting selection to options at all but instead providing an autoconplete. Yes autocomplete can be bypassed but you would handle that by checking if the input is valid and if it's not then asking for valid input through a string select menu. This is what I do @Dragonite as well. You can try /pokemon then type .. idk "pika" and it'll autosuggest Pikachu. But then if you type "/pokemon" and mash your keyboard and hit enter before the autocomplete populates you will get an ephemeral reply with a select menu with suggestions....
Next