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

Method to Prevent Commands Stores loads subfolders

Hello, is there anyway to prevent a the commands store to load other subfolders like these prefix subfolder?
Solution:
Prefix the files with _
No description

Event from other bot

Hi everyone I have two bots running on SapphireJS. From bot B, I want to emit a custom event to bot A using client.emit(). I saw your documentation here: https://sapphirejs.dev/docs/Guide/listeners/listening-to-events-emitted-by-other-emitters ...

disable sync on every launch

how to disable the sync that happens on every launch?

Slash Command doesn't register or working

so apparently i'm trying sapphire framework for discordjs, i've follow the documentation but this code somehow doesn't register the slash command even message command isn't working, does anyone have solution for it?
Solution:
nevermind, i'd forgot to set the main in package.json to src/main.ts (which like index.ts), thanks for the help tough
No description

Pass data from Precondition to ChatInputCommand

Hi all. I am using Sapphire to handle my commands, and I have a precondition that checks if a guild has config related to it in the DB, and creates it if not, and I was wondering if there was any way for me to hold that data in the interaction/context. I tried to attach it to context ```ts public override async chatInputRun( interaction: CommandInteraction, _command: ChatInputCommand, context: PreconditionContext,)...
Solution:
there is no built in way to pass data, but you can use anything that's in JavaScript by default such as using a keyed map, object, array, database, etc

Context Command function not called, but Discord says bot is unresponsive

Hello! Apologies if I file this in the wrong location, but I'm quite unsure about what's broken within the code. But first, the code https://pastebin.com/QP7165k0. As the image shows, it aint responding, but other, regular slash commands work. I might be tripping, or skill issue but I am now stumped....
Solution:
Preconditions does not work on context commands and will break without sending an error. Make sure to not use a precondition on context commands
No description

i18n applyLocalizedBuilder

Hello, i have some problems with i18n. I am currently trying to localize slash commands, but i can't get it to work. My code is: ```ts registry.registerChatInputCommand((builder) =>...
No description

Can I create or change commands folder location?

Hello I kinda wanted to know if it's possible to change the commands file locations, like instead being in ./src/commands/ping.js, to be in ./src/commands/information/ping.js or ./src/plugins/information/commands/ping.js

interaction handlers with preconditions

Is it anyhow possible to make my own version of preconditions (or just extend sapphire's somehow) and add preconditions to it
Solution:
you'll have to overwrite the core listeners but other than that it's just a matter of adding code

precondition error logging in console

hey, when my precondition errors, its logged to console and i don't understand how to stop it?
Solution:
damn i just realized i had console.log in node_modules when i was testing something

client.application has a bunch of null values

Hi there, I'm very new to Sapphire so I've been going through the documentation/guide and am at the step to configure your own preconditions. Going off the example in the documentation where the bot owner id is grabbed from a configuration file. I'm trying to access mine through this.container.client.application.owner.id, however this.container.client.application has a bunch of null values. When I throw it all to my console, these are the results: ...
Solution:
Sounds like either your printing it before the bot fully connected to discord or your connection isn't working at all. Either way, this is a discordjs matter, not a sapphire matter.

default contexts and integrations

is there a way to set the default integration Types and contexts for ALL commands? all my commands are GuildInstall and Guild integration and contexts respectively and having to restate this in every command file is a bit annoying.

plugin usage

can we use sapphire plugins such as plugin-i18n without actually using sapphire?
Solution:
No

Commands don't trigger with newline starts

If a message is sent with a newline immediately after the command's name it won't be triggered. For example: ``` !say...
Solution:
No... I don't think this is gonna work. It goes pretty much against how we parse messages and commands. Might I recommend using Slash commands instead and showing the user a TextInput modal component which allows for multiline string input that way?...

How can i get registered Command JSON data?

like applicationBuilder.toJSON()?
Solution:
Alright, so getting the command JSON in Sapphire is pretty simple. There isn't one big toJSON() method for everything. The trick is to just make one yourself on each command. Basically, in your command file, you create a method that just returns its own JSON. You can call it toJSON or whatever you want....

Precondition position

I think that precondition positions are not working
Solution:
as you can see in the link I sent we dont actually check for duplicate positions, it's just going to be pushed or sliced into the array regardless

Reloading command pieces not working in Bun

Reloading a command piece, either with <piece>.reload(), with <CommandStore>.loadAll() or the @sapphire/plugin-hmr plugin, doesn't work and the command remains the same as before. After long trial and error I found that I could make it work by first unloading the piece (with <piece>.unload()), then removing the command file from the import cache (with delete require.cache[piece.location.full], this works in Bun with TS/ES6), and then loading the piece again (either with <piece>.reload() or with <CommandStore>.loadAll()), and the changes were successfully applied to the commands. This was tested in a minimal project, with only the following dependencies and file structure:...

How to manual disable precondition?

Hi, i made precondition that automatically enabled ```ts public constructor(context: AllFlowsPrecondition.LoaderContext) { super(context, { name: "RulesOnly",...
Solution:
i'd rather creating new instance ```ts declare module "@sapphire/framework" { interface CommandOptions {...