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

Create store for helper classes to access them through the container for hmr to reload it?

Hello there, I do play with the HMR plugin right now and I noticed with some research that only pieces are getting reloaded on change (as intended). So I searched for a way to add my helper classes to the client container as pieces so they get reloaded aswell. So far I do think that I need to put my helper classes in a store and put them into this store but I didn't found anything related to register a store so maybe you smart guys can help me out by explaining or providing any source of tutorial for me how to do so 🙂...

Subcommand unintentionally triggers Events.MessageCommandRun

I have a /dpm subcommand is defined as: ```typescript subcommands: [ { name: "all", chatInputRun: "dpmAll" },...
Solution:
Set a default on one of the subcommands or handle the error

AutocompleteInteraction options#getUser doesn't exist

Why is it saying that the getUser doesn't exist even tho it does?
Solution:
auto complete doesn't have getUser user options cannot have autocomplete set to true read the docs ...

Working with interaction SelectMenuBuilder

When i send a component SelectMenu , and i have a interaction handler for that , but when i selected , nothing happen , how i can handle event after i select menu
Solution:
omg , i realize i named wrong folder , when i fixed , it works , thanks for ur help

Using Typescript in Sapphire.

I was changing between Javascript to Typescript in the framework, and ping command don't work. My code: ping.ts ```ts import { Command } from '@sapphire/framework';...

GUILD_MEMBER_UPDATE - oldMember & newMember

Stackoverflow ( https://stackoverflow.com/questions/66175307/discord-js-guildmemberupdate-not-being-called-except-on-bot-user-changes ) is telling me guild member update event get oldMember and newMember as parameter. ```javascript client.on('guildMemberUpdate', (oldMember, newMember) => { // Fire if user has a role...
Solution:
Not sure. Check your intents I guess. Haven't dealt with this event in a long time. Regardless, it's more of a DJS question because sapphire literally does absolutely nothing for events. We don't for example proxy forward them or anything, we also just use client.on(...) essentially.

API going to sleep?

I have an API up using the framework which is listening out for POST requests from a separate app (running on the same machine) however I seem to be running into an issue of what I would assume the API going to sleep or something... After a while the API no longer executes when called, but if I restart the bot it will execute the previous attempts then respond to new ones. I am using default settings....
Solution:
That is not inherently a feature of sapphire so this is something your hosting is doing.

API Routes Handling

I'm currently delving into routes and handling them but I have problems finding how to hand the process off to a middleware like express-routers. I want to essentially just forward every request to the express-router but I currently have 2 roadblocks: 1. the route parameter seems to not allow for wildcards 2. methods don't support handling all event types ...

HMR not Working correctly

I am using the @sapphire/plugin-hmr Plugin to reload my bot on code changes without relogging to discord. When I change the text in an embed for example and hmr reloads my changes, they are displayed correctly in discord with the new text. If you change console logs, add container.logger.info(xyz) or edit helper files, the changes there are not reflected correctly with the latest changes. If I want to see the changes I have to stop the dev process and restart the bot completely....
Solution:
This is expected behavior. @sapphire/plugin-hmr only handles "piece" files (commands, listeners, preconditions, etc)

Store a data in Client context Shappire

How can i store a object value in client context shappire Im trying to create a music queue cached for my bot...
Solution:
extend the client to store it

Type 'ServerResponse' is not generic

Hello guys, I just updated the sapphire packages and I am encountering an error with the plugin-api. In the ApiResponse (which extends) the ServerResponse it throws an error in the titel "Type 'ServerResponse' is not generic". Has anyone an idea how to fix this?...
Solution:
it is generic. Make sure you have a proper @types/node and all that

Is there a Example on how to work with the API Plugin directly in the bot?

I want to try out how that is working, is there an example Repository somewhere? Because the Docs are super limited.
Solution:
thats correct

Creating slash command with options and sapphire cli template

Hey there. I'm using the bot template from the sapphire cli and now wanted to try and create a slash command with options, but sadly don't know how to start. As I read the docs already, I know there's documentation at discord.js, but it doesn't apply to the template of the cli. Therefore any help with sapphire cli template in mind would be grateful.

Is there any utility to check if a member has permission to run a command?

Hi! I have a bot that needs to check if a member has permission to run a command and then do something accordingly (eg remove a role) and I'd rather not write something to check if the member has permission to use a command if it already exists
Solution:
You'll have to write your own function. Feel free to make a PR to @sapphire/discord.js-utilities after the fact.

Send and Reply from the editable-commands plugin do the same wrong thing.

So I tried out both of them and none seems to respond on the interaction. what I want: image 1 what I get; image 2 My code: ```js...
Solution:
Answer: Dont use the editable-commands Plugin for responses to Slashcommands. This is how a valid Reply looks like...

what is this regex supposed to mean?

Solution:
lowercase your names

How do I create subcommands with different text input fields?

Something like the image. The Docs only show how to create basic subcommands. Also in the Readme of the subcommand plugin it is not mentioned...

Best Approach on separating Commands from their "run" file to a separate Folder

For context, I am super new to discordjs and this framework so apologizes if this question sounds odd. I really dislike the approach that all examples in the example repository and docs are giving of having the command definition (if you call it like this) and the execution code of the command in the same file. What is the best way to separate them both? Or is it even possible?...
Solution:
```ts import { myRunFunction } from '../lib/commands/my-command'; import { Command } from '@sapphire/framework'; export class MyCommand extends Command {...

message commands are not working

trying to update to v4 and the bot is not recognizing commands. i have enabled loadMessageCommandListeners: true and the bot does have proper intents. is there anything new i should be updating?
Solution:
Possibly related to https://discord.com/channels/737141877803057244/1062989204549816320/1062989204549816320 please use search before making a new post....

Failed to overwrite global application commands

Since updating to BulkOverwrite, I'm getting the following error: ``` 2023-01-12 22:00:07 - DEBUG - ApplicationCommandRegistries(BulkOverwrite) Overwriting global application commands, now at 6 commands 2023-01-12 22:00:07 - ERROR - ApplicationCommandRegistries(BulkOverwrite) Failed to overwrite global application commands DiscordAPIError[50035]: Invalid Form Body 2023-01-12 22:00:07 - ERROR - 2[APPLICATION_COMMANDS_DUPLICATE_NAME]: Application command names must be unique...
Solution:
you're calling registerChatInputCommand twice ergo, twice a command with the same name...