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

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

message listeners stopped working in sapphire v4 on my bot

hi, this is my listener code: ```js const { Events, Listener, container } = require('@sapphire/framework');...
Solution:
Okay Vladdy found the problem @owoer You forgot to call super.onLoad() in your onLoad method ```js onLoad() {...

Duplicate identifier 'Command'

I'm trying to create a basic slash command, but when I import the Command class from @sapphire/framework, it gives the error:
Duplicate identifier 'Command'
Duplicate identifier 'Command'
What can I do?...
Solution:
f1 => restart ts server

Context menu commands not being registered

Hi, on updating to v4 I experienced the following error:
ApplicationCommandRegistry[report] Failed to update command Banish (<id>) DiscordAPIError[40041]: An application command with that name already exists
ApplicationCommandRegistry[report] Failed to update command Banish (<id>) DiscordAPIError[40041]: An application command with that name already exists
...
Solution:
we'll hopefully get this out this week

Is there a way to disable ApplicationCommandRegistries logs?

They happen on start-up and I don't want them between all of my formatted logging. Is there a way I can disable them?
Solution:
If you use a custom logger you should extend the built in Logger class. See for example how @sapphire/plugin-logger works.

Context Menu Interactions Not Received

I'm using the basic context menu command register (attached) and my run function is async contextMenuRun(interaction), but I do not think it's the problem with the function since the command does not even seem to be received (check screenshot). Anyone know how to fix this? Common troubleshooting for these types of issues would also be useful. Thanks!
Solution:
@tk can you check if npm install @sapphire/framework@pr-590 fixes it for you too