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

Trying to compare 'messageUpdate' event

Hi, guys i try to compare oldMessage and newMessage in the event. But their is a difference when their is an embed in the message, its the property: content_scan_version The event gets fired, when i read the message. ...

Change in how discord links emojis?

I have a function on my bot that does emoji stealing. Recently had some users report that stealing an animated emoji only steals the static image now. I used to extract the emoji id and do guild.emojis.create({ attachment: https://cdn.discordapp.com/emojis/${emoji-id}, name: emoji-name }); and that worked for all emojis. But it seems discord emoji links are now of the form https://cdn.discordapp.com/emojis/{emoji-id}.webp?size=240&animated=true. Does anyone if this is behavior that was changed...

changed from npm to pnpm, bot doesn't work anymore

so I don't know what to supply to you other than a message. I have created a new folder, installed all the packages using pnpm that were necessary, pasted my src and then I ran npx tsc, when I run pnpm start or node ., doesnt matter, when I just turn on the bot using any method, it wont like respond, it is active, but does nothing. is there any particular reason for that?
Solution:
you didnt run pnpx prisma generate

Property 'send' does not exist on type *channel types*

I am following the guide on setting up a basic command using sapphire, but using channel.send throws an odd error. ```ts import { Command } from '@sapphire/framework'; import { Message } from 'discord.js';...
Solution:
Nvm I needed to type guard it with if (!message.channel.isSendable()) return;
No description

Interactions randomly fail in a dockerized bot

I am not sure if this is inherently a sapphire thing or a discord.js thing but My bot (code found here ) has a weird issue to it where it would occasionally just fail commands entirely https://alex.thefoxesare.online/powershell_vFxRKxUOPM.png without any reason in particular. A recurring problem was when a command I don't have permission to run is run and then any command after it would cause the unknown interaction error to happen, sometimes other interactions. I have never seen this happen in a locally hosted instance so I'm not exactly sure what's happening here. The VPS that the docker instance is on has 2GB of RAM and more than enough CPU and I haven't been hitting any of those limits....
Solution:
The makeshift solution is to prevent people from executing interactions for like 5 minutes or something. I don't have anything else to give for this particular problem.

Is there a way to make autocomplete options only accept a listed option - not "custom" inputs?

Title
Solution:
that is unfortunately not how autocomplete works because they only serve as suggestions. to do that, you would need to compare the inputted value on your end.

Profile Color Member

hi, can someone tell me how to retrieve the primary color code of the user profile and not banner ?

Subcommand not registering

Hello, I was not really sure whether I should post this in #discordjs-support or #sapphire-support, but since it's an issue regarding subcommand registration, I decided to post it here! I'm kinda new to all of this and I just made a new bot. I wanted to create a /channels command (here is the code: https://hastebin.skyra.pw/cezeqivufo.less) but when I try to run the bot, I get the following error: ``` 2024-09-20 17:40:06 - ERROR - ApplicationCommandRegistry[channels] Failed to register application command with name "channels" DiscordAPIError[50035]: Invalid Form Body...
Solution:
I just replaced the new SlashCommandBuilder() with (builder) => builder and now it works! ```ts // Pretty much like this: export class ChannelsCommand extends Subcommand { public override registerApplicationCommands(registry: ChatInputCommand.Registry) {...

Slash Commands Embeds

Im currently working on a discord bot and i am on the last step which is making the commands. i need help though. I wanna know if i am able to run the command and the bot responds in an embed message

Help with message deletion

I am currently implementing message deletion logging into my bot to replace another bot that doesn't log attachments upon deletion. I assume that the DAPI passes attachment information along with the rest of the Message object when messages are deleted. However, referencing the attachment via URL wouldn't work because, well, you can't reference a url that doesn't exist anymore. Is there a way to retrieve the raw image data or get a Stream from the Attachment object that is returned with Message#...
Solution:
u can actually use the url because they dont get deleted immediately like the message. i cant remember how long it takes for the attachment url to get deleted though

How does one check if a specific user was mentioned in a message?

I was thinking it would be something along the lines of MessageMentions#members.has('UserID'), is this correct?

Typing - Question message

So I have this and I am confused entirely what the reason is. Import is
import { EmbedBuilder, Guild, Message, User } from 'discord.js';
import { EmbedBuilder, Guild, Message, User } from 'discord.js';
...
Solution:
Okay so using npm instead of yarn worked, I was on latest v4 but it may have been my yarn lock file
No description

Keep getting "Shard 0 is reconnecting..." errors

My bot keeps getting "Shard 0 is reconnecting..." errors every couple of hours and I'm not sure why. Running discord.js 14.15.2.
No description

Question about developing in TypeScript

My bot which is used by 10,000 members is fully written in Sapphire for JavaScript. I was thinking about converting it to TypeScript to make the code better, and safer. I wanted to ask, from your experience, does using TypeScript make a difference in how you code? does it make a difference in the performance? Is it worth it? Cheers!...

Is there a way to make the bot press a button component within a message

Wondering if there's a way to simulate a button press on a message (particularly a message that wasn't sent by the bot).

getChannel does not exist for interaction.options

Howdy, I'm trying to get a text channel from a command channel option, but I'm getting the error that 'getChannel' property doesn't exist even though it appears as a method in the docs and I've seen it in other people's code. I'm using the typescript complete example bot as a base. Npm ls returns discord.js 14.14.1
ts:32:51 - error TS2339: Property 'getChannel' does not exist on type 'Omit<CommandInteractionOptionResolver<CacheType>, "getMessage" | "getFocused" | "getMentionable" | "getRole" | "getAttachment" | ... 6 more ... | "getSubcommand">'.

const channelOption = interaction.options.getChannel('channel', true);
ts:32:51 - error TS2339: Property 'getChannel' does not exist on type 'Omit<CommandInteractionOptionResolver<CacheType>, "getMessage" | "getFocused" | "getMentionable" | "getRole" | "getAttachment" | ... 6 more ... | "getSubcommand">'.

const channelOption = interaction.options.getChannel('channel', true);
...
Solution:
Type it as a ChatInputCommandInteraction. Your current type is ambiguous as to wether it's chat input or context menu.

Editing a message deletes it

To explain my system. I have a music bot that some events trigger certain message edits. Upon a user playing a song, an embed with buttons get sent (pic 1) this message gets stored within Guild class I extended with types. upon clicking one of the buttons, the message gets edited with new information. For example if someone pauses the song the button changes to another button. But the problem with that is that, upon editing the message. It deletes it. Pictures besides 1st one, show the code pretty much. 2nd pic shows how i store the message and what happens when a track starts playing 3rd pic shows whath what happens when player gets resumed (same thing happens with pausing or any event that edits the message stored)...
No description

MongoDB Discord.JS (Only saving to 1 profile)

```js const { Client, Message } = require('discord.js'); const calculateLevelXp = require('./calculateLevelXp'); const UserProfile = require('./userProfile.js'); const cooldowns = new Set();...

Help fetching users

I didn't know if this was a sapphire or d.js issue but this line of code im using to fetch the users just isn't returning the right amount of users with the specific role. I've tried just getting all the users then filtering them with the role and it also doesn't work correctly ```ts const supportRoleId = interaction.options.getRole('role', true).id const logChannelId = interaction.options.getChannel('log-channel', true).id...

role not being given

logs saying they were removed, but they weren't
Next