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

Module augmentation does not work

I recently updated my project with the latest versions of typescript and @sapphire/framework, and then I run into the problem that augmenting typing no longer works. I thought the problem would be pnpm, I even tried with the .npmrc configuration file "shamefully-hoist=true" but I'm still trying with yarn and the same thing happens, I don't know what to do. These are the versions I am using and my tsconfig file....
Solution:
normally module augments should work just fine if everything is done right though. The last time I had difficulties was when I had incorrectly published some package (i think it was pieces) where it was missing some files in dist. Maybe check that out for your own packages? Check the files array and check the dist?
No description

Conflicting types

I use the latest version of djs (14.14.1) and it seems like it has different types for taking the result from parsing.
Solution:
anyway if I write the code like this then it works fine: ```ts import { ApplyOptions } from '@sapphire/decorators'; import { Awaitable, InteractionHandler, InteractionHandlerTypes, Option } from '@sapphire/framework'; import { AutocompleteInteraction, type ApplicationCommandOptionChoiceData } from 'discord.js';...
No description

new to sapphirejs and discord bot overhaul

hi , i'm a new learner to make discord bot , i've gone a bit trought the basic of discordjs , was able to make work slash command , i switch to sapphirejs from a friend recommandation , but i didnt find how do we manage to send our command to discord api, i would love some direction help its been like 2day i'm learning to make discord bot , still on the basics of doing !ping command , slash command with multiple approach , done js / ts and now trying with sapphire...

Dump and load cached messages.

I'm not the one that usually works with the Discord Bot in our system, but I usually learn somethings. I know the Client keeps a cache of messages and such, ultimately I want to be able to get who deleted a message and why, is there a way to access the cache of messages directly, since Partials don't let me see anything from the onDeletedMessage....
Solution:
if you only want to get who deleted a message, the way i do it in bots i have for some servers is by fetching audit logs and comparing the author and stuff

How do interaction handlers pair up with commands

Hello! I'm trying to develop a little discord bot and I loved how complete the sapphire framework is. I've come across the interaction handlers section and tried to implement a command using a Select Menu one. The thing is, to trigger an interaction handler I first need to "make" the interaction through a command (like displaying a button). Let's say the command has a name param, how can I give the interaction-handler that information? Am I not using the right tool for what I'm trying to do?

Implement paginator , selection

so I want to have like a menu where you can pick several buttons and each button will show several options but each option should also have a paginato, what's the best class for this?
Solution:
I do something similar in my bot, I could not find a prebuilt class that handles that. Paginated Message would work but it’s not designed for that kind of functionality specifically so you’d have to override it. I use interaction handlers to do it in mine and it works really well. https://sapphirejs.dev/docs/Guide/interaction-handlers/what-are-they...

Any way to register a database client to the application command

Let's take this example: ```ts import { Command } from "@sapphire/framework"; ...

Using Paths w/ TypeScript

I'm trying to use TypeScripts Paths to make it easier and cleaner to import modules, although I always get: Cannot find package '@modules/mongodb' imported from C:\ExampleDirectory I've tried using node -r tsconfig-paths/register ., but that doesn't work and it still shows the same error above. ...
Solution:
Turns out that compiling it then running it with tsx works perfectly fine ```json "main": "dist/index.js", "type": "module", "scripts": {...

Select Menu Listener Fails To Register

Hello, I'm trying to implement a Select Menu Listener and get an error that a compatible class export cannot be found. I've copy-pasted the code exactly from the framework documentation/example and still receive the error. ...
Solution:
Nvm! I see it should be it's own folder, as mentioned in the forum post here: https://ptb.discord.com/channels/737141877803057244/1200406268435759176/1200407647694884965

Argument examples

Are there any examples for duration arguments available? I'm struggling with duration arguments for punishments and am looking for something that would accept either a "permanent" string or a duration with the type of a string, e.g 1h, 30d, 1m Iirc there was a plugin for this but I can't remember what the name is or where to find it....
Solution:

Message commands not working

When I run, nothing happens. No errors, no bot response. Here's the code: https://github.com/Bolaside/CrBn...
Solution:
Nevermind, I forgot to set loadMessageCommandListeners to true, silly me

Issue with @sapphire/plugin-api

Hello, I have installed @sapphire/plugin-api using the following command: ``` npm i @sapphire/plugin-api...
Solution:
Try setting your module (and moduleResolution) to node16. They are the modern options for module stuff. Alternatively you can install and extend @sapphire/ts-config which will cover most of the config. - All of those subselections of esnext like esnext.array are implied by esnext so you're duplicating there - exclude isn't necessary like that. Exclude is to exclude something that was previously included, unless you have a node_modules directory inside src it does nothing - You can change include to just src, tsc will automatically resolve the whole directory glob....

Precondition Command

In a global precondition, is it possible to get the command object for the command the precondition is being run on?
Solution:
The command is the second parameter of the run function. Example: https://github.com/sapphiredev/framework/blob/main/src/preconditions/Enabled.ts

Is documentation page outdated?

I'm a first-time sapphire user, but I couldn't find an answer to my question. The documentation says this website is written for the 3.x version of @sapphire/framework The last published version is 5.0.7...
Solution:
Updated now

Precondition i18n

Per this example here https://www.sapphirejs.dev/docs/Guide/preconditions/global-preconditions is it possible to like use one i18n function for it to work for all them with the message or do I have to take special precautions and check which type it is?
Solution:
If so, no, but you don't send messages through the preconditions anyway. You to that through listeners. And you identify the identifier there then send the translated message. See https://github.com/skyra-project/skyra/blob/main/src/listeners/commands/messageCommandDenied.ts for an example.

Got this error when executing command /kick

I never got this error before, i edited my /kick command and after doing so i executed the command the command works but after like 1-3 seconds of executing the command it crashes and throws this error:
Solution:
seems like it’s coming from there
No description

How to add string options

i need help with how to add string options if i add then them the normal way ie: .addStringOption((option) => option.setname etc) it wont work...
No description

Error when using @sapphire/type

Error: Cannot find module '/workspaces/shim/node_modules/@sapphire/type/prebuild/type-node-v115-linux-x64-glibc-2.31/type.node'
Error: Cannot find module '/workspaces/shim/node_modules/@sapphire/type/prebuild/type-node-v115-linux-x64-glibc-2.31/type.node'
...
Solution:
use yarn instead of bun

Commands + Listeners not registering

My commands and listeners are not registering/running. I suspect its because I'm using tsx but am not sure what the best way to resolve it would be
Solution:

Delete Message Instantly

https://github.com/skyra-project/skyra/blob/main/src/lib/util/functions/messages.ts does the deleteMessageImmediately function in the file above actually delete the message instantly? Faster than doing <Message>.delete()?...
Solution:
it still calls message.delete but doesnt throw an error on error codes.