#djs-help-v14
78874 messages · Page 4 of 79
--env-file=config
Loads environment variables from a file relative to the current directory, making them available to applications on process.env.
any documentation for components v2 or am I not looking correctly 😭 ?
discord.js documentation:
- stable release: learn more
- developer release: learn more
ah I see, it seems that my cache is using the old style and not the new one
is this part of the website documentation still up? if I go on incognito or a different browser I get the updated one
use ctrl + f5
sweet thanks
what r ideal limits for caching with reactionmanager and reactionusermanager for reaction roles in a server with abt 400 members
that's really not that big
you shouldn't need explicit limits
if i have a bot only for js that server is it unnecessary to put limits on caching
yeah, caching size shouldn't be an issue
it isn't for almost all users
it's only when you really start to scale
should i start caching anything if the server member count hits a higher number
You should not worry about it
Unless you grow to several thousands servers
caching is built-in
what we're talking about is limiting or clearing that cache
which you don't need ^^
what is the best what to capture a guildScheduledEvent that is recuring getting canceled. Events.GuildScheduledEventUpdate does not seam to fire. when the recuring event gets canceled.
if you mean the entire event series being cancelled, you're looking for GuildScheduledEventDelete
but if you mean a single event in the series, there isn't an event for that yet
the cancellation of a single event in the series in new enough that no part of it is documented in the api
darn, That is what I am looking for
how would i retrieve a container from a message?
Message#components discord.js@14.19.1
An array of components in the message. This property requires the GatewayIntentBits.MessageContent privileged intent in a guild for messages that do not mention the client.
appreciate it
export default {
data: new SlashCommandBuilder()
.setName("test")
.setDescription("test"),
async execute(interaction: ChatInputCommandInteraction) {
const container = new ContainerBuilder()
const text = new TextDisplayBuilder().setContent("Hello World")
container.addTextDisplayComponents(text)
await interaction.reply({ content: "hello world", components: [ container ], flags:[ MessageFlags.Ephemeral ] })
}
}
Error: data.components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
am I supposed to wrap the container in a ComponentBuilder or something?
you're supossed to send the IsComponentsV2 flag as well
v10: MessageFlags - IsComponentsV2
read more
also, unrelated question but do i have to send that flag when editing a message with a container?
yes
I am assuming that if I don't send a component v2 and have a flag added, it wouldn't error out?
if you send the cv2 flag you can't send anything except components
so you can't "send the cv2 flag and don't send a component", that'd be an empty message
unless you were just asking whether you can send v1 components in action rows
i see, so I can only send cv2 and nothing with it?
you can't send nothing
that too unless it is a limitation from discord
it is possible to use v1 components
what about content + embeds + cv2?
@pseudo urchin
ah that's a discord limitation I am assuming?
it's discord's designed way, yes
not a "limitation" per se
it's how it was planned
since you can do content with text components and embeds (mostly) with containers
and pinging works as normal with containers?
as if it was content, yes
You can control which entities receive notifications via the allowedMentions option. You can:
- Set a default on the client
- Set for a specific message
- Use the
repliedUserkey to disable in-line reply mentions
{ ..., allowedMentions: { parse: ["users", "roles"] } }
sweet thanks
just to point out, when editing a message flags is readonly
no, you can edit them
that's how embed suppression works after all
Type 'MessageFlags.IsComponentsV2' is not assignable to type '`${bigint}` | MessageFlags.SuppressEmbeds | "SuppressEmbeds" | Readonly<BitField<"SuppressEmbeds", MessageFlags.SuppressEmbeds>> | RecursiveReadonlyArray<`${bigint}` | MessageFlags.SuppressEmbeds | "SuppressEmbeds" | Readonly<...>>'.```
and how you can now add cv2 components to a message that previously didn't have them
yes, that's currently a typings issue
it says that it doesn't accept that flag, which isn't accurate in runtime, it'll be fixed in next release
it doesn't say that it's readonly though
oh, im tripping then, my bad
for now you can ts-ignore that
it'll work in runtime just fine
will do, thx for helping me out
for me at least it seems that I can only use everyone in message whilst in cv2 it doesn't seem to work. Unless I am missing something
Ran npm update and it seems to not update discord 14.18 to the latest. (not really sure on how to "force" or just to get it to update)
It's a known issue, will be fixed in the next patch release which should be pretty soon
npm i discord.js@latest
ah I see alright ty
Ah thank you! Now to see if my bot is more broken 
coffee ☕
It's a minor release so there aren't any breaking changes, nothing should be broken
Keep in mind this isn't #archive-offtopic
Yeh, that's what im checking for right now, Currently making a new bot for my company, then i gotta update my global bot cause i think it's still on like... 14.9.0 
oh my bad, never seen you in djs help so, i assumed it a general
You can't reply to interactions with the new components v2?
Right?
can someone send me docs to the components v2 webhook thingy on how to make it
components v2 or webhooks with components v2?
webhooks with components v2
just send the flag and withComponents: true
no like
cuz i want to implement it i alr have withComponents: true i just need a method on how to create the embed with ocmponents
how to create a webhook?
oh
you can't use embeds and v2 components
if you send the IsV2Components flag you can't send anything else apart from components
content, embeds, polls, stickers, etc
so this isnt possible for the itme being?
it is, that's not an embed
it's a container
the source code is even linked there
i didnt know what it was so i just assumed its an embed
embeds must have a color unlike that component
and you can check the code there
aight tysm
And if you're curious how this message was built, check out the source code!
Imagine reading 
Made a kinda guide / turtorial for the new components according to the recetnly most asked questions here on that topic
if you have any questions or advices for me to that topic just ping me^^
In MessageComponentEmoji, can I do emoji: { name: "<:fluxlike: 1031262536240201748 >" }? Or do I have to use the id field and pass in emoji id 1031262536240201748 in this case?
If you're using a custom emoji like :fluxlike:,
you must use the id field, not just name.
emoji: {
id: '123456789012345678' // use the emoji ID
}
i personally recommend
emoji: {
:fluxlike:
}
Do I also have to use the name field for custom emojis?
u wont have to but i recommend it to make sure that it definetly gets loaded
This will work? emoji: { :fluxlike: }
okay somehow it doesnt let me edit it right lol
nah it didnt let me edit it right xD
what is even a MessageComponentEmoji?
Oh lol, but still I checked code and that format is not there.
ApiMessageComponentEmoji?
that’s not a thing…?
oh, yeah that is in dtypes
nvm then
true lol thought he just wanna use a custom emoji in his components
probably for buttons
Yes
ye works in the same way like explained
I don't think this is gonna work in any way, not a object.
yeah that's not how js objects work
and you can't have a link button with an emoji
and no idea why you're stringifying that url when it should be a string already 
there are a couple of cursed things in that picture
that wont work with js objects it should be more like this then
replyOptions.components = [{
type: ComponentType.Button,
style: ButtonStyle.Link,
emoji: {
id: '1031262536240201748',
name: 'fluxlike'
},
url: `${tweetUrlFormatted}`
}];
}```
^^
lol don't judge me 🤣
interesting never tried that lol (i anyways dont like link button XD)
What do you mean?
👀
oh, must be missremembering then
That makes sense, documented way
btw @rose tangle thanks to ur help
Do I have to do :fluxlike: or just fluxlike works?
Cereal already gave you the code
just fluxlike without : like i sended u in the code
Okay perfect, thank you @vague echo

Just confirming 100%.
btw general question, does it make sense to change all embeds to components?
still wondering if discord will remove embeds after we have components so-
Legacy message component behavior will not be deprecated and will continue to be available to your apps on a message-by-message basis. However, we recommend using the new components for new projects and features.
https://discord.com/developers/docs/components/overview
thx^^
is there any video explaning how to use the new components?
Not one made by us
what's the recommended method of checking current channel type? for checking if interaction is in direct messages
<Interaction>.channel?.type === ChannelType.DM, import ChannelType from discord.js
do channels not always have types?
They do
Someone remember how to log the request body of a command when you get the DiscordAPIError[50035]: Invalid Form Body error ?
How can I exactly replicate this but with componentsv2? There will be multiple items in the same embed and also multiple buttons.
it should be logged with the error already if I'm not mistaken?
they are but in [Object] , i lowkey dont want to search all my commands
but what's the error?
it should tell you specifically what validation failed
DiscordAPIError[50035]: Invalid Form Body
5.options[5].options[3][UNION_TYPE_CHOICES]: Value of field "type" must be one of (3, 4, 5, 6, 7, 8, 9, 10, 11).
at handleErrors (file:///home/lilly/Desktop/Coding/Lilly%20redo/node_modules/@discordjs/rest/dist/index.mjs:686:13)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async SequentialHandler.runRequest (file:///home/lilly/Desktop/Coding/Lilly%20redo/node_modules/@discordjs/rest/dist/index.mjs:1087:23)
at async SequentialHandler.queueRequest (file:///home/lilly/Desktop/Coding/Lilly%20redo/node_modules/@discordjs/rest/dist/index.mjs:918:14)
at async _REST.request (file:///home/lilly/Desktop/Coding/Lilly%20redo/node_modules/@discordjs/rest/dist/index.mjs:1231:22)
at async file:///home/lilly/Desktop/Coding/Lilly%20redo/dist/deploy.js:9:5 {
requestBody: {
files: undefined,
json: [
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object]
]
},
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: { '5': [Object] }
},
code: 50035,
status: 400,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/775530257645830145/commands'
looks like commands[5]
from start or from end ..
from start? that's how arrays work
they also dont log in the same order than all my commands
lilly... please xD
so 5th command could be technically my 17th on my command list..
I'm pretty sure at least the error description is accurate on the indexing
could log both just in case
just log the 5th array entity before registering
Do you load commands asynchronously?
Or in parallel, to be precise
you can't do author image or footer image with v2 components
or small footer/author text
-# at most this (-#)
technically my 5th in the array ( knowing that it starts at 0 ) so my 6th command technically is that ..
LockCommand: {
name: 'lock',
description: 'Lock a channel',
description_localizations: { fr: 'verrouille un canaux de discussion', ja: 'チャンネルをロックする' },
options: [ [Object], [Object] ],
default_member_permissions: '0'
},
doesnt exactly fit the error
even the one before that
pretty sure it's not the 5th in the array, but literally the one at index 5
^^
Index 5 is the 6th command
i just said that ..
thought you meant you accessed [6]
what about this one then
or is it random per rest call?
you ask to log ...? no?
well you said your 5th command is your 17th
so log that one
other than that, probably only a good old .find() would help
https://pastebin.com/f42JcbLS , the entire log
The order changed again?
Nvm
commands.find((cmd) => cmd?.options.find((sub) => sub.type === subcommandType && sub.options.find((subOption) => ![3,4,5,6,7,8,9,10,11].includes(subOption.type))))
I think?
this can only be the Pet, Poll or Settings Command
The error also mentions options[5], so that can help narrow it down to your pet and poll command since those have 6 or more options in them based on the entire log you sent
*And settings command, capyblappy added
Nvm then, it's good as it is
could be so nice if the error also could possibly perhaps tell what it received ...
you'll have to ask discord that
I usually do util.inspect with infinite depth
either way, inspecting your commands it looks like you put a subcommand inside another subcommand https://github.com/Lilly3252/lilly/blob/Lilly-v3/src/slashyInformations/moderation/settings.ts lines 131 and 230
Although, I initially did this for shapeshift
ah... yeah ... my bad
so my 5th in the error was my 10th in my log ...
how... helpfull 
thank you nontheless ❤️
so
am i the only one that cant open the source code mts
how and with what are you trying to open it
i need more info on the components v2
thats not what i asked
just open it in notepad
thx
Someone has a guide or a bot example with a user install command made with djs ?
SlashCommandBuilder#setIntegrationTypes() discord.js@14.19.1
Sets the integration types of this command.
well yeah that part is done, i was wondering if theres more than that
Not really. Deploy and handle the interactionCreate as usual, just not assuming it‘s in a guild or you got access to the channel to send
Well, maybe you want contexts: [..] too
alright , cuz this was happening so i was wondering if i was missing something important
Does your interactionCreate maybe check inCachedGuild()?
oh right it does
if (!interaction.inCachedGuild()) {
return;
}```
i guess i need to remove that check right
i guess i will need to debug deeper than expected now , thanks
cuz my interaction goes immediately in <cached>
so this is happening :
Argument of type 'ChatInputCommandInteraction<CacheType>' is not assignable to parameter of type 'ChatInputCommandInteraction<"cached">
Yea, can’t assume that it’s cached anymore
imma blame crawl's framework for the moment
Was thinking abt adding a field that specifies whether the interaction must be cached, but it might not translate to TS well
theres 2 type , cached and the other was what , raw ?
Yes
holy saint mary joseph
oh , it was simpler than expected
Does anyone happen to have any suggestions what I could do regarding this one? :)
yayyyy ❤️ modifying yuudachi framework was the solution afterall !! ❤️
Why not use interaction.options.data?
It’s defined the same way, except that you can’t modify the Array
I'm not sure, I wrote this code a long time ago and was directed to use _hoistedOptions, maybe that was before data existed
The data field would definitely be suitable, thank you for your advice!
I see there is no .from() method for the new component types. does that mean that when editing the message, I will have to read and update the json itself?
Hello does anyone know what the rate limit for .setActivity() is for RPC
discord ratelimits are dynamic, and not set in stone, afaik, but you can see it by checking the headers https://discord.com/developers/docs/topics/rate-limits
how to make this status in your discord bot?
it is not documented
is this in line with discord rules?
discord.js does not support features until they are officially documented.
While there might be a way for these features to work, it can change at any time without any notice
If its not documented we dont support it
Making your bot appear as on mobile is technically not in line with Discord's guidelines, no
Okay
isn't it? i'm pretty sure you just have to set ws.identifyProperties.browser to Android iOS
where do i put the isComponentsV2 flag?
in flags field
message.reply({
flags: Flags.isComponentsV2,
components: [...]
})
thnx
const container = new ContainerBuilder()
const text = new TextDisplayBuilder().setContent("Hello World")
container.addTextDisplayComponents(text)
message.channel.send({ flags: Flags.isComponentsV2, components: [ container ] })```
`TypeError: Cannot read properties of undefined (reading 'isComponentsV2')`
Flags isn't really a thing in this case, you have to import it, and it's MessageFlags
Doing so goes against the documentation which specifies bots should identify as they library they use
well, looking at the docs i don't see anything that declares this as a requirement, just a guide. some libs even provide this option natively. doesn't seem like anything "against discord's guidelines", just a way to indicate good practices (+ the device is still the lib you are using)
and given the fact that these fields are free for you to insert literally any string, since you can write your own lib, this has no relation to any risk
ContainerBuilder discord.js@14.19.1
A builder that creates API-compatible JSON data for a container.
const resultsContainer = new ContainerBuilder({
components: [
{
type: ComponentType.TextDisplay,
content: `${raceResults}`,
},
{
type: ComponentType.TextDisplay,
content: `Race ID: ${race.raceId}`,
},
{
type: ComponentType.Section,
accessory: {
media: {
url: message.guild.iconURL(),
type: ComponentType.Thumbnail,
}
}
},
],
});
im getting serialized error
that's not saying a whole lot
nvm im using embeds containers are very confusing
So far I haven't understood how to use this ContainerBuilder, can someone explain?
#announcements message inspect the code in this file
I'm guessing it isn't possible to have 2 buttons as accessories for 1 section
Nvm, I thought it said addButtonAccessory hence why I asked, realised it said set so obviously only 1.
Batty what is the buildStrategy?
what function is used for collection button responses from container buttons
These all are interactions
.createMessageComponentCollector i was using this but this doesn't work for container buttons
Have you updated to the latest version?
Yes, it‘s a known bug and will be fixed in 14.19.2
My bad
any alternative?
Well, show your code. collectors in general should work, just not if used with certain settings
const message = interaction.reply({
components: [secondContainer],
flags: MessageFlags.IsComponentsV2,
});
const collector = message.createMessageComponentCollector({
componentType: ComponentType.Button,
time: 60_000,
});
Yeah, don’t use componentType restriction for now
TypeError: message.createMessageComponentCollector is not a function
You didn’t await the reply
So guess your issue is unrelated to the mentioned bug after all
Trying out the new V2 components, and I have optional flow which is giving me a type problem:
await interaction.deferReply();
if (!member) {
return await interaction.editReply({
content: 'Did not obtain a Member instance for Yourself',
});
}
await interaction.editReply({
// Type 'MessageFlags.IsComponentsV2' is not assignable to type
// 'BitFieldResolvable<"SuppressEmbeds", MessageFlags.SuppressEmbeds> | undefined'.
flags: MessageFlags.IsComponentsV2,
components: [container],
});
Known issue, will be fixed in the next patch release, you can ts-ignore it for now
ah, thanks 👍
Does anyone know why it’s not catching errors here? The catch block isn’t catching the error
try {
commandData.execute.command(interaction as Discord.ChatInputCommandInteraction, { subcommand: commandNameData.subcommand, group: commandNameData.group });
} catch (error) {
logger.error('There was an error while executing a command:');
logger.error(error);
return interaction.error('Komut çalıştırılırken bir hata oluştu.');
}
Because you don’t await the promise probably
And there is no error method on ChatInputCommandInteraction 
I just learned this now
wdym? didn't understand
<ChatInputCommandInteraction>.error() is not a method
oh that's my custom method
to reduce the boilerplate

now that I look at it, doing interaction[(interaction.deferred || interaction.replied) ? 'followUp' : 'reply'] actually makes more sense
what flag is 1 << 15, just use Enums
It's just the standard one in the dev docs, could replace it with 32768 instead if they really wanted to
I haven't updated to the new version yet and since the docs aren't out yet, I don’t really know how to use the builders. Until examples are released, I'm sticking with the old version
that's why the IsComponentsV2 enum isn't there yet
documentation suggestion for @orchid moth:
MessageFlags discord.js@14.19.1
@orchid moth MessageFlags.IsComponentsV2 is there
I haven't updated to the new version yet
Hard coding values like these isn't really recommended since discord can change it at any time, and then you'll be lost trying to find out what 32768 is actually
Ohhhh, my bad
that’s true
the docs are out for 14.19.x wdym
does it include components v2?
I mean, im talking about the guide ofc
I wouldn't even be able to use components v2 right now without any docs from discord anyway
return ctx.sendMessage({
components: [
new ContainerBuilder().addSectionComponents(
new SectionBuilder()
.addTextDisplayComponents(new TextDisplayBuilder().setContent(ctx.locale('cmd.premium.content')))
.setButtonAccessory(
new ButtonBuilder()
.setLabel(ctx.locale('premium.support'))
.setStyle(ButtonStyle.Premium)
.setSKUId(client.env.SKU)
),
),
],
flags: MessageFlags.IsComponentsV2,
});
Uncaught Exception: RangeError: Premium buttons cannot have a custom id, label, URL, or emoji.
wdym "ofc" you said docs, they are two very different things. please be mindful of the words you use
can i edit a button inside of a container
Error message seems pretty straightforward
well you can ask help here on how to use what
ah yes my bad
you're right about that, I should've said guide instead of docs
I don't want to waste anyone's time, so I'll just wait for the guide
I'm not in a hurry anyway
People come in this channel to give help and recieve help anyways, you wouldn't be wasting anyone's time 
Yes
whats the mthod
you're right for the small errors or unclear points, but I don't think anyone will sit here and explain the entire components v2 builders to me from start to finish
For that you can read the example code from #announcements
i need to get initialContainer and new container and replace one with other?
I haven't bothered with it since I couldn't open the MTS file
You make a new builder from the component data on the message (or still have the original builder laying around) and then access the .components to get to the builder you want to change. Similar to how it works with changing a button in an existing ActionRow
never changed button from actionrow
message is the one im trying to edit button on right?
wait but how do i get first message
you open it with your editor
oh when I clicked it it was trying to open as a video
I had no idea it contained text 
Depends. What is the event causing you to want to edit it?
im making module system and has two buttons: enable, disable, it sets state in database and i want to edit the message
What does external mean here? It cannot be assigned as a property so how to add a reason when editing a soundboard sound?
when do you want to edit? What parameters/structures to you have accessible then?
when i click enable/disable
external means it’s re-exported from another package
In this case discord-api-types it doesn’t make sense… lemme check that
SoundboardSound#edit() discord.js@14.19.1
Edits this soundboard sound.
// Update the name of a soundboard sound
soundboardSound.edit({ name: 'new name' })
.then(sound => console.log(`Updated the name of the soundboard sound to ${sound.name}`))
.catch(console.error);
parameters/structures?
I was expecting it to be optional and assignable (like for soundboard sound create options), is this a bug?
Yeah, it's not in the typings, will be fixed in the next patch release
That’s a bug in the typings, it‘s missing on the interface but the method does accept it. ts-ignore for now, will be fixed🐌
Alright, thanks
@ancient gust #app-commands
I like that you can tag a role and get pinged inside TextDisplayBuilder
can we use select menus in containers?
You can add an action row that can hold a select menu
so it works
anyone tried before cuz i didn't see anywhere
Try it, you'll be first
Yes
can you send me just one example
ContainerBuilder#addActionRowComponents() discord.js@14.19.1
Adds action row components to this container.
In there do the same thing you‘d do for ActionRows outside of a container
what is default value of allowedMentions
https://discord.js.org/docs/packages/discord.js/14.19.1/MessageMentionOptions:Interface shows only repliedUser as defaulting to true
even for interactions. repliedUser is also true?
did you try it
yeah
can you use ephemeral and componentsv2?
yes
how the cuz I cant get it working am I tweaking???
MessageFlags.Ephemeral | MessageFlags.IsComponentsV2
oh its | im cooked
hey so i made couple of slash commands and they dont seem to be registering anyone know why. I got this error earlier but was able to register them after Could not register commands! SocketError: other side closed but they dont show up
my dumbahh did [MessageFlags.Ephemeral, MessageFlags.IsComponentsV2]
That should work?
but try union
Interactions can’t reply to any user‘s message, so that‘s irrelevant
so why did you make it nullable?
what if i use interaction.user.toString() in the message?
is it possible to perform a channel search for messages using discord.js like from:ronykax in:#general?
<Interaction>.channel can be null and accessing type from null would error
but how is that possible?
Then you add a user mention. That’s unrelated to repliedUser, which is about pinging on reply.
how can a interaction not be in a channel
so by default it shouldn't ping me?
It can’t. But the channel can not be cached/accessible because user app
yeah | worked
ah, thanks!
refresh your discord. that error is a network error
That depends on what you mean by „by default“. I think Mark understood your question differently than what I think you meant, so elaborate
and should not happen when registering
unless you register them every time your bot start, which you shouldnt
like if i do not pass allowedMentions in the client consturctor or reply options
i've done that multiple times... i've also tried on ios and canary still nothing. I also kicked the bot from the server and invited it back and now all the commands are gone 💀
It’ll use discord’s default, which is parse all mentions
how are you registering your commands
but why does passing allowedMentions: { repliedUser: false } in the interaction reply options does not mention me, but not passing it does
Because now you‘re deactivating all mentions (since you didn’t pass any).
ohh, so if i pass an empty object, it would have the same effect?
can bots forward messages yet?
documentation suggestion for @shadow pier:
Message#forward() discord.js@14.19.1
Forwards this message
what about an interaction reply, could i possibly forward that? 
It‘s a Message. So yes
what is this rightclick context menu stuff called? and how do I achieve something like this using djs?
to then for example read out the content of a message wihch got rightclicked
Other Interactions: Context Menus
read more
oh it is a context menu lol.
Thanks
oh so how would that work if Message.Ephemeral was set?
-#
hi noulith
It won’t
I dont think it's that because on my test bot it works fine i'm able to register them but on my main bot they don't seem to wanna work
What is manageexpressions called
I wanna check that in role perms ManageExpressions this isn’t working
ok
v10: PermissionFlagsBits
read more
ManageEmojisAndStickers ManageGuildExpressions
Thank you
basically, it's the function that customizes how the websocket should behave/initialize. and the init i used is exactly the same as the one used internally, except it changes how the browser identifier is defined (being Discord iOS instead of @discordjs/ws x.x.x. but the device field is kept as @discord/ws...)
why so many channel types that should have a name attr dont?
DMChannels dont have names
what about the other ones?
They do
why does it say it doesnt
It doesnt
Read the last line
yes, but the first line
thats because your variable is typed as that
it can be any of those
but a DMChannel doesnt have a name
so it'll complain
how disable (This interaction failed) ?
By replying to the interaction
There is a way other than replying?
for buttons
ButtonInteraction#update() discord.js@14.19.1
Updates the original message of the component on which the interaction was received on.
// Remove the components from the message
interaction.update({
content: "A component interaction was received",
components: []
})
.then(console.log)
.catch(console.error);
ty
Why does this fail?
this looks lke a question for #1081585952654360687
the embed builder is erroring from my addFields
and the embedbuilder is from discordjs, so I think it goes here
the error comes from the code you're using inside addField, not from addField itself
the error is from the validator of the embedbuilder and i've shown what my code outputs
- for a async map, you must Promise.all afaik
okay
store the addFields content in a variable and log it
helloo, i don't know why i have this error can u help me plss
when using componentsv2, you gotta set the "isComponentV2" flag on the message body
oooh it's true... sorry for the inconvenience tysmmm
Is there some sort of inline on TextDisplayBuilder()?
So that you can but them side by side instead of on top of each other
for inline text, only in embeds
is a https://discordjs.guide/interactions/context-menus.html#context-menus handled like a command interaction?
like can I use one file for both?
both create a interaction, yes
whether you can use one file or need multiple, depends on your setup
djs doesn't handle that part, you program that
okay that confirms part of it, how can I deploy both then?
they're just commands with a different type
you deploy them the same way
and can deploy them alongside slash commands
and should, actually
no like i mean do i make two entries and one has type: 3 in it?
If one of those entries is a slash command, then yea
You follow the same steps you would when deploying slash commands, except for the command's data, you're constructing a context menu command rather than a slash command
alr thanks
Hi, do you know how to shrink the embed?
To have it like that
And not like that
with the components V2
what?
maybe you're mistaking embeds with containers?
you can't have embeds when using v2 components
yes container mb
regardless, there is no means of controlling how discord renders anything
it's much smaller here
what is much smaller?
the length
i think i found a bug, but unsure if it is a bug with discord.js or with discord itself
// normal message
const messageSent = await message.reply({
content: "test",
allowedMentions: { parse: ["users"] }
})
await messageSent.edit({
content: "test test",
allowedMentions: { parse: ["users"] }
})
// components v2
const messageSentComponents = await message.reply({
components: [
new Discord.TextDisplayBuilder().setContent("test")
],
allowedMentions: { parse: ["users"] },
flags: Discord.MessageFlags.IsComponentsV2
})
await messageSentComponents.edit({
components: [
new Discord.TextDisplayBuilder().setContent("test test")
],
allowedMentions: { parse: ["users"] },
flags: Discord.MessageFlags.IsComponentsV2
})```
if you send a message and then edit the message, when using `allowedMentions: { parse: ["users"] `, it is not meant to ping the user it is replying to.
when using components v2, when editing the message, it seems to edit it to ping the user.
could someone else try this and see if it happens for them too?
both messages should not be pinging the user its replying to
just curious since there was a bug relating to allowedMentions fixed in the latest version (14.19.2), what version did you test this on?
if not 14.19.2, does the issue persist after updating?
14.19.1
let me try, didnt notice the update
its worse
it now pings on the first message, then edits it to have no ping
behaviour has completely changed in 14.19.2
it now pings by default to replied user, when replied user is not specified
first bot is on 14.19.1, second on 14.19.2
assuming this is a bug, ill make a bug report
I'm actually unable to reproduce the new behavior on 14.19.2
I can reproduce the first behavior on 14.19.1, but if not reproducible after fixing the previous bug with allowedMentions, I'd lean towards it being fixed
even when running that exact code i sent?
yes
can you show your client constructor?
globalThis.client = new Discord.Client({
shards: "auto",
intents: [
"Guilds",
"GuildMembers",
"GuildBans",
"GuildEmojisAndStickers",
// "GuildIntegrations",
// "GuildWebhooks",
"GuildInvites",
"GuildVoiceStates",
"GuildPresences",
"GuildMessages",
"GuildMessageReactions",
"GuildMessageTyping",
"DirectMessages",
// "DirectMessageReactions",
// "DirectMessageTyping",
"MessageContent",
// "GuildScheduledEvents",
].map(e => Discord.GatewayIntentBits[e]),
partials: [
"User",
"Channel",
"GuildMember",
"Message",
"Reaction",
// "GuildScheduledEvent",
"ThreadMember"
].map(e => Discord.Partials[e])
})
hmm looks fine
though your maps are unnecessary
but nothing that should change the mentions
could reinstall just in case ig
Thank you so much for explaining it in more details for me that helped a ton and i learned something new from you and that code you shared about mobile! You're a very smart developer and got great talent. Thanks 👍
still happens after a reinstall npm r discord.js npm i discord.js
ill do some more testing including a blank bot to see what happens
ok actually I think I misinterpreted what you were saying
yes this is a bug introduced by the fix to the other bug
go ahead and open an issue
ok cool thanks
i was worried somehow my bot was breaking something and i had to spend hours digging through it to figure it out lol
hey there I'm updating and I wanted to see if this was the best/correct way to get button components off interaction.message.components
let componentRow = ActionRowBuilder.from(interaction.message.components[i] as ActionRow<MessageActionRowComponent>)
// pre discord.js 14.19.2
// let componentRow = interaction.message.components[i];
I check if the message has the flag. then if the components is an action row
if(interaction.message.flags.has(MessageFlags.IsComponentsV2)) return;
const messageComponents = interaction.message.components[0]
if(!(messageComponents instanceof ActionRow)) return
would you say this is high priority, since it breaks allowedmentions for anyone that updates
why is it for an message delete event and it had an attachment it most of the time successfully adds the attachments and sometimes its invalid like this
gonna be honest, I'm a little confused by both of your code snippets
- all of a message's components will always be in
<Message>.components, regardless of components v2 or not - at no point should you be modifying existing data from the api, so even before components v2, you should've been creating a new builder (assuming you use the builders)
- neither of you are getting a button component specifically, but if you are just looking to get the row the button is in, sure that's fine
attachments dont exist anymore when messages are deleted
then how come they work sometimes?
race condition?
Because the times it does work are when the attachment still exists on Discord long enough for your bot to fetch it
no its works fine
no im saying its a race condition. thats why it sometimes works and sometimes doesnt work
hm ok so the bot is basically a ms too late or something?
Yes, nothing you can do about that. Discord doesn't promise how long an attachment will persist after the message it resides on is deleted
thanks for clarifying
also i heard about proxy urls being able to fix this, is this true?
personally I wouldn't say so just considering potential issues that would be way higher priority than this
but it's true that this broke some functionality
I can't attest to that unfortunately
if a message is deleted, you should not rely on it being there by any means, proxy or not
the only way is to save the attachment somewhere before its deleted then?
the only way to get around it, which you definitely should NOT do, is manually download every attachment so you have a copy of it when the original message is sent
it is not true, it will just expire slightly later since it has a cache iirc
but: 1 - that will take a lot of storage
and: 2 - that probably violates privacy laws
you can avoid storage by just sending it to another channel
This is exactly why Discord attachment URLs expire
lol i see
how do bigger bots always attach attachments then? is it cuz they use webhooks or something?
anyway thanks for the help, issue created https://github.com/discordjs/discord.js/issues/10865
Webhooks would not solve this, no. The only way to be able to re-attach a deleted item is to already have a copy of it's content prior to deletion
I'm grabbing buttons from an ActionRow to create new buttons to change the labels
but this is the error that happens with code i was using from before 14.19.2
Property components does not exist on type TopLevelComponent
Property components does not exist on type FileComponent
This is a typeguarding issue, as FileComponent is a valid TopLevelComponent but would not have child components
If you check the type of the componentRow first to confirm its an ActionRow, this should address it
is there a typeguard for ActionRow built in to discord.js
No, typeguard was not need for components v2 to work so it was left out. would be a nice qulity of live tho
Think about making an issue for it as a feture request
If there's an option to do interaction.awaitModalReply is there a way we can easily capture a button interaction event without having to create an explicit event listener for every button click event?
ah yeah it would make sense for this one imo
ty guys! 😄
on the message/channel, yes
documentation suggestion for @hexed marsh:
Message#awaitMessageComponent() discord.js@14.19.1
Collects a single component interaction that passes the filter. The Promise will reject if the time expires.
// Collect a message component interaction
const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId';
message.awaitMessageComponent({ filter, time: 15_000 })
.then(interaction => console.log(`${interaction.customId} was clicked!`))
.catch(console.error);
guide suggestion for @hexed marsh:
Message Components: Component interactions - Component collectors
read more
NICE!
How to I set a timer? Like if someone uses a command they have to wait 15 minutes to do it again
something like this but for 15 mintes
setTimeout(callback[, delay[, ...args]])
Schedules execution of a one-time callback after delay milliseconds.The callback will likely not be invoked in precisely delay milliseconds.
Otherwise, cooldowns are covered in our guide
Additional Features: Cooldowns
read more
thanks
(container.components![2] as TextDisplayComponent) = (new TextDisplayBuilder().setContent("**Amount to deposit: **\n> " + inlineCode(`${amount}$`)))```
am i missing something obvious?
`Type 'TextDisplayBuilder' is missing the following properties from type 'TextDisplayComponent': content, id, type, equals`
A builder is not a component
Where has container.components come from? They generally arent designed to be modified directly like this
You can try calling toJSON on the builder to do this
const message = interaction.targetMessage;
console.log(message);
-> undefined
am I missing something?
interaction logs out as this: https://sourceb.in/eRVuKx63cM
targetMessage is a getter, if you have message caching disabled or for other reason it isnt cached, this can happen
makeCache: Options.cacheWithLimits({
MessageManager: {
maxSize: 100,
},
GuildMemberManager: {
maxSize: 50,
keepOverLimit: (member) => member.id === member.client.user.id,
},
UserManager: {
maxSize: 100,
},
}),
sweepers: {
...Options.DefaultSweeperSettings,
messages: {
lifetime: 3_600,
interval: 3_600 * 3,
},
users: {
interval: 3_600,
filter: () => (user) => user.id !== user.client.user.id,
},
},
?
Hmm, though it should always arrive with the interaction
Can you log interaction.options directly
That is your client, not the interaction
Think we found the problem
aha omg thanks lol
i was passing my client first then interaction, but in the command i was using interaction first
in what situation emoji.name can be null?
Discord native emojis I think, the unique comes through as the id
emoj is an instance of GuildEmoji
i wanted to know if there is any case in which a server emoji can be null
I mean, if the docs say its nullable there must be, at least according to Discord
Discord docs say "can be null only in reaction emoji objects"
const message = interaction.channel?.messages.cache.get(messageId)
const container = message!.components[0] as ContainerComponent```
Yeah - much like embeds, the component structure you receive is intended to be read only. Modifying it invalidates the cache
im kinda lost, how can i get a container object that im able to write?
thought i was already able to as i assigned it to my container obj
I mean it is editable, but you cant assign a builder to it
Its more like a raw JSON component
is Builder.from being added in any newer updates to the componentv2 stuff?
no idea
so should i edit .content or .data.content?
A ContainerComponent has neither of those...
ContainerComponent discord.js@14.19.1
Represents a container component
a textdisplaycomponent does
data.content
actually wait idk
Again these arent meant to be edited at all
im trynna edit a message with a edited component that i get from another message, am i not able to do that?
i could just make a loop but thatd make my code slower if i can just change that directly
also i figured it out, just need to .toJSON() and u can edit it normally
actually no, it doesnt work like that, typescript just isnt throwing a syntax error
Does setDefaultMemberPermissions(permissionflagbits) hide the command from people without the permission
Yeah
What about for role equivalent is there like a setDefaultMemberRole
Or do I have to make the command check for the user role after the execution
DiscordAPIError[50035]: Invalid Form Body
data.components[0].accessory.emoji[MODEL_TYPE_CONVERT]: Expected an object/dictionary. Promise {
Can someone help me with this?
const sections = new SectionBuilder({
components: [new TextDisplayBuilder({
content: `## Sistema de Vendas\n- Status Vendas: ${statusvenda}`,
})],
accessory: {
type: ComponentType.Button,
custom_id: 'vendastoggle',
label: 'Alterar Status',
style: 2,
emoji: client.db.General.get('ConfigGeral.Vendas.Status') == false ? ":desligar:" : ":Ligado:"
}
})
Emoji should be an object, not a string
emoji: { id: "…", name: "…" }
ah oh yes true thank you
Neither - roles should be managed by the admins of the guild in Server Settings > Integrations
Is it possible to hide the command from people without the role
just like permissionflagbits
Not with the bot API, it operates only on permissions
Modifying role configuration requires an Oauth2 grant
Otherwise - yes, this is what changing server settings will do
why does a button interaction from components2 have no ButtonInteraction.component?
wdym?
I cant replicate this
Works for me using both ActionRow buttons and Section accessory buttons
Not tried it on an action row, but was getting no .component property on accessory. I've turned my computer off now, but I'll look again in the morning and post my code if I can't work it out.
Hey!
I'm pretty sure it's impossible, but I'm asking just in case I missed something.
Is it possible to add a field to upload a file in a modal?
No
ru talking about that?
no, they are talking about modal interactions
oh got it. im wondering when we able to use select menus in modals too
btw it would be amazing if we could ensure that the sizes of these select menus fit exactly into the container
or as much as the length of the embeds
we have no control how stuff is displayed
those are questions for discord
i wish we can manage that but when :D
Never
are you trying to edit a container and update the components within that container?
const container = new ContainerBuilder({ components: interaction.message.components[0].components })
const section = container.components.find(e => { return e.data.data.id === 144 })
const accessory_btn = new ButtonBuilder()
.setEmoji(stringEmoji)
.setDisabled(true)
.setStyle(ButtonStyle.Secondary)
.setCustomId("0")
section.setButtonAccessory(accessory_btn)
await interaction.update({ components: [container] })
Error: Expected a string primitive
at _StringValidator.handle (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2615:70)
at _StringValidator.parse (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:90)
at TextDisplayBuilder.toJSON (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:1708:33)
at C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:2169:64
at Array.map (<anonymous>)
at SectionBuilder.toJSON (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:2169:35)
at C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:1871:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\@discordjs\builders\dist\index.js:1871:35)
at C:\Users\AnthonyVault\Documents\GitHub\wetbot\node_modules\discord.js\src\structures\MessagePayload.js:151:46 {validator: 's.string()', given: undefined, stack: 'Error: Expected a string primitive
at _St…js\\src\\structures\\MessagePayload.js:151:46', message: 'Expected a string primitive'}
Can someone help me out, what am I doing wrong here with the new Container component?
const container = new ContainerBuilder();
container.addMediaGalleryComponents((gallery) =>
gallery.addItems((item) =>
item.setURL("https://...")
)
);
container.addTextDisplayComponents((textDisplay) => textDisplay.setContent("Hello World"));
await channel.send({
components: [container]
});
Not setting the flag
Oh is there a flag I need to set on the client?
On the client? No
In the send
The components v2 flag
Ah, perfect thank you
const initialMessageContainer = message.components[0].toJSON() as APIContainerComponent;
const container = new ContainerBuilder(initialMessageContainer);
then you can do .find without calling .data.data - just do .data.id
thanks
at this line const command = interaction.client.commands.get(interaction.commandName) it throws an error saying that interaction.client.commands is undefined, even though thats how it is in the tutorial
Its like that in the tutorial if you define it in the earlier steps of the tutorial
so im trying to access commands before they are initialized?
maybe
thats not possible, this part appears at the end of my bots startup when all commands are already registered
its only initializing the interaction listener
Can you share your code? I cant confirm otherwise
sure, sec
the thing on pastebin is my extended client that has all methods for using the bot, deploying listeners happens in start()
Well you define Bot.commands, but at no point do you define client.commands
You dont seem to be following our tutorial
Which is fine, but some aspects wont work the same as you're discovering
this.client.commands then?
Uhh, maybe, if this is bound to your event listeners
It doesnt appear to be
Im not sure exactly what this Bot class achieves
How would you access it from within a command?
This class doesnt extend client, it has a client as a child property
yeah the naming is unfortunate
i made it just to group all of bot startup code in one place, for my own convenience
Well your commands are attached to the Bot class and not client, so its up to you to either move them, or provide access to get one from Bot
noted, i did that^ and it seems to have helped :-)
Yeah I think I misunderstood what you meant before, thats right
So to hide the commands from people without let's say, senior moderator role, I have to do it via the server settings
yup
what parameters does the interaction.respond() method take, in context of returning a choice for autocomplete?
docs say ApplicationCommandOptionChoiceData but i cannot tell what it is
AutocompleteInteraction#respond() discord.js@14.19.1
Sends results for the autocomplete of this interaction.
// respond to autocomplete interaction
interaction.respond([
{
name: 'Option 1',
value: 'option1',
},
])
.then(() => console.log('Successfully responded to the autocomplete interaction'))
.catch(console.error);
array of names and values
Also if I just put like
Try:
--code
Catch:
Return
And it gets an error will it say this interaction failed or will it do "this application is thinking" forever
If you successfully defer and then error later it will be thinking forever
If youre unable to defer/respond at all, it will fail
So if I only put a return it will fail?
It isnt that simple
It all depends on what has or hasnt been successfully executed before the error
for permissionOverwrites.edit, does setting, let's say SendMessages: null set it to what it originally was?
context is for a lockdown - set it to false on lockdown, then to null when lifting the lockdown
documentation suggestion for @signal jewel:
PermissionOverwriteOptions discord.js@14.19.1
An object mapping permission flags to true (enabled), null (unset) or false (disabled).{
'SendMessages': true,
'EmbedLinks': null,
'AttachFiles': false,
}
what's wrong here?
const {
ButtonBuilder,
ButtonStyle,
ContainerBuilder,
TextDisplayBuilder,
SeparatorBuilder,
ActionRowBuilder
} = require('discord.js');
module.exports = {
name: 'inscribir',
aliases: ['ins'],
args: false,
run: async (message, client, args) => {
// Texto principal
const text = new TextDisplayBuilder()
.setContent('**Inscripciones abiertas**\n¡Ya puedes inscribirte al evento!');
// Separador visual
const separator = new SeparatorBuilder();
// Botón en un ActionRow
const button = new ButtonBuilder()
.setCustomId('inscribir')
.setLabel('Inscribirme')
.setStyle(ButtonStyle.Primary);
const actionRow = new ActionRowBuilder().addComponents(button);
// ContainerBuilder con los componentes correctos
const container = new ContainerBuilder()
.addTextDisplayComponents(text)
.addSeparatorComponents(separator)
.addActionRowComponents(actionRow);
await message.channel.send({
components: [container.toJSON()]
});
}
};
no message flag
and I think its not needed to use .toJSON() for your container, just container is enough
no, you forgot to add the message flag as you use components v2
Overview: Components Overview
read more
I don't understand what you mean with flag
Message#flags discord.js@14.19.1
Flags that are applied to the message
like this?
await message.channel.send({
container,
flags: MessageFlags.IsComponentsV2
});
no not really
why did you remove the components:
how can i remove buttons from a container by editing the message?
each component has a unique id field, if not set the id is started from I think 0 (might be 1) and incremented for each component in the message
so if you look at the JSON body of your message, you should see the id field with the value you can use to identify and modify the component
i don't want to modify it i want to remove it
then use the parent (action row) component's .setActionRowComponents() and don't include the button
where do i get the channels of a CategoryChannel
documentation suggestion for @covert vine:
CategoryChannel#children discord.js@14.19.1
A manager of the channels belonging to this category
right i looked into that object and havent found anything in it
its literally just categorychannel.children.cache - returns a collection of channels
im so dumb
how can I constrain the possible choices in a command option only to the choices offered by autocompletion?
You cant, a user can always submit the currently entered text
ConnectTimeoutError: Connect Timeout Error (attempted address: discord.com:443, timeout: 10000ms)
at onConnectTimeout (/home/container/kaeru/node_modules/@discordjs/rest/node_modules/undici/lib/core/connect.js:237:24)
at Immediate._onImmediate (/home/container/kaeru/node_modules/@discordjs/rest/node_modules/undici/lib/core/connect.js:206:11)
at process.processImmediate (node:internal/timers:478:21) {
code: 'UND_ERR_CONNECT_TIMEOUT'
}
What the hell is this error
First time seeing it
related to me okay
This happened to me too, when I used termux
hello :) i cannot get my discord.js bot to stop pinging me when i reply, i have changed my client constructor to this.client = new Client({ intents, allowedMentions: { repliedUser: false } }); and have even tried adding allowedMentions to my replies but it won't stop pinging me whenever it replies, how can i stop it from pinging me (djs version: ^14.19.2)
Same error occurs for my bot too
tag suggestion for @radiant epoch:
Errors such as ECONNRESET, ConnectTimeoutError, SocketError: other side closed indicate a network issue
- Free or shared hosting providers often come with significant limitations
- Another indication of these issues are 'Unknown Interaction' errors.
I'm posting this command to discord:
new SlashCommandBuilder()
.setName(this.name)
.setDescription(this.description)
.setContexts(
InteractionContextType.Guild,
InteractionContextType.BotDM,
InteractionContextType.PrivateChannel
)
.setIntegrationTypes(
ApplicationIntegrationType.GuildInstall,
ApplicationIntegrationType.UserInstall
)
.addSubcommand((subcommand) =>
subcommand
.setName("server")
.setDescription(
"Run this as a server-wide event and have multiple people win the event."
)
.addIntegerOption((option) =>
option
.setName("max_wins")
.setDescription("How many people can win the event.")
)
)
.addSubcommand((subcommand) =>
subcommand
.setName("personal")
.setDescription("Create a game only you can participate in.")
.addBooleanOption(ephemeralOption)
)
It keeps erroring:
2025-04-29 17:37:26 - ERROR - 1.options[0][TAG_FIELD_MISSING]: Field "type" is required to determine the model type.
2025-04-29 17:37:26 - ERROR - 1.options[1][TAG_FIELD_MISSING]: Field "type" is required to determine the model type.
When I remove both of the subcommands, it works fine. Also tried removing the max_wins option from the first subcommand and it still showed an error for that subcommand. I don't see where I have to put a type for a subcommand.
can i put custom discord emojis in autosuggested command options?
they broke allowedMentions
ahh, alright, I'll downgrade to 14.19.1 for now then
its broken in all 14.19 versions
then what should I downgrade to?
its broken in a different way, but only if you use components v2
14.18.x but no components v2 then
alright, I don't think I have used components v2 ever, so it'll be alright
or keep the version and use REST calls
i marked this as medium priority, but it might be classed as higher. if someone has a big bot and updates to it, people could use this bug to ping everyone on the server with it
This will be fixed in the next release
its because of this i think
Yes
idk why it was changed, i changed it back to that and it seems to work fine
This was done fix the previous bug which in turn caused another issue
this is an inbetween change i believe. the stuff after the // compomponents v2 comment was not there in 14.19.1
so i think it was fixed, then changed again which broke it
because this is what the pull request change shows. it doesnt have the components v2 stuff since that was added, then changed again
idk im just guessing i may be wrong
Yes, I believe the above changes will be what ends up being again. It was simplified thinking only the message by client should have allowed_mentions as setting it for others (message_refrence) produced error. But we didn't account for message reply where this.isMessage was referencing the replied message causing the current issue
i have a question to an <message>.createMessageComponentCollector(...)
on the <collector>.on("collect") - that happens when someone clicks on the message component (in my case a button) right ?
so i could do something like
<collector>.on("collect", interaction => interaction.followup("..."))
?
Yes, but followUp only works after replying first.
Sure this is only a quick question.
ok ty
How do i remove how my bot is addable?
that seems more like a discord question then a discordjs question in #useful-servers the last server there you might find an answer
Kk Thank You
Hi there! I am trying to use components v2 and I am getting a very absurd error:
Code: ```ts
const container = new ContainerBuilder();
const header = new TextDisplayBuilder().setContent(
[
# ${name},
'- Created by Lunasa',
'This error tends to occur when things are silly.',
'## Fix',
].join('\n'),
);
container.addTextDisplayComponents(header);
const fix = new TextDisplayBuilder().setContent(
'The fix for this is very simple. You just gotta download the attached file and boom!',
);
const section = new SectionBuilder()
.addTextDisplayComponents(fix);
container.addSectionComponents(section);
container.addSeparatorComponents(separator => separator.setSpacing(SeparatorSpacingSize.Large));
await interaction.reply({
components: [container],
flags: MessageFlags.IsComponentsV2,
});
Error:
error: Received one or more errors
errors: [
{
"name": "Error",
"validator": "s.instance(V)",
"message": "Expected"
},
{
"name": "Error",
"validator": "s.instance(V)",
"message": "Expected"
}
]
at new BaseError (1:23)
at new CombinedError (D:\Development\terra\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:1845:5)
at handle (D:\Development\terra\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:1965:23)
at parse (D:\Development\terra\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:90)
at toJSON (D:\Development\terra\node_modules\@discordjs\builders\dist\index.js:2170:37)
at map (1:11)
at toJSON (D:\Development\terra\node_modules\@discordjs\builders\dist\index.js:1871:35)
at map (1:11)
at resolveBody (D:\Development\terra\node_modules\discord.js\src\structures\MessagePayload.js:150:49)
at D:\Development\terra\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:192:56
Sections needs Text display and an accessory
bruh, well thanks
np
you can add the text displays directly to the container if you want a section without an accessory
Hello, getting this error when using MessageFlags.IsComponentsV2, 1 << 15 works perfectly fine, anyone knows a solution?
Edit: Code above is return await interaction.editReply({
you need to update to 14.19.2
let meowceptionChannel = await client.channels.fetch("1364348815095763047");
if (meowceptionChannel.type !== ChannelType.GuildCategory) {
return;
}
let meowCeptionJSON = {};
for (let entry of meowceptionChannel.children.cache) {
let channel = entry[1];
meowCeptionJSON[channel.url] = 0;
};
interaction.reply(JSON.stringify(meowCeptionJSON));
``` i am trying to collect all ids of channels but it doesnt work, i am probably going to do this manually but i really wonder why it doesnt work
it retrieves the id of the channel it sent its first message in only
define "doesn't work"
what does it actually reply (show)? does it error?
it retrieves the id of the channel it sent its first message in only
which is weird because it has no relation to it??? maybe it can only see that one channel
oh wait, cached channels....
it doesnt have the other channels cacged
do you not have the Guilds intent enabled or do you overwrite the caches?
i think its the first one
im not trying to bitch out but this is why i enable all intents and permissions, because i dont have to deal with this lol
that's a really bad idea
Guilds is the only one that's "important", at least if you want to rely on caches
Hi, how can we send an ephemeral and compnentV2 message ?
The ephemeral option when replying to an interaction will be removed in v15
- {..., ephemeral: true}
+ {..., flags: MessageFlags.Ephemeral}
``` Read [here](<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR>) on how to specify multiple flags
If I have this code;
const reason = await this.getReasonViaModal(interaction);
const content = // irrelevant, but basically an embed
const response = await reason.reply({
content,
withResponse: true,
});
Where reason is of type ModalSubmitInteraction and response is obviously of type InteractionCallbackResponse.
However, the response message has a string select menu, how would I apply a component collector to it, because when I try it errors saying Property createMessageComponentCollector does not exist on type InteractionCallbackResponse.
The fetchReply option when replying to an interaction will be removed in v15.
- {..., fetchReply: true}
+ {..., withResponse: true}
```This returns an [InteractionCallbackResponse](https://discord.js.org/docs/packages/discord.js/14.17.3/InteractionCallbackResponse:Class)
Use `<InteractionCallbackResponse>.resource.message` to get the message
check the last two sentences ^^
Oh
Right cause component collectors can only be applied to messages, right
Hello, just wondering if it's possible to set a context menu command to work as a user-installed bot, i've tried setting integration_types to [0,1] to no avail, i've tried using .setIntegrationTypes([0,1]) and still nothing, i would really appreciate some help with this!
did you re-deploy?
also you should use the enum instead of raw values, but it's the same thing
v10: ApplicationIntegrationType
read more
i have a bit of code in my index.js that automatically refreshes, deploys, and removes commands, i can send a snippet if that'd help?
you shouldn't deploy on start
and wdym by "refreshes and removes"?
you only need a single rest.put() or application.commands.set()
there shouldn't be any other calls while deploying
it just checks if there are changes that needs to be made to the deployed commands, and if there are it deploys them
maybe it isn't checking properly, give me a second to have a look
or just deploy manually and avoid that logic altogether
ill just deploy manually and see if that fixes it
well i can use the context menu command in servers the bot isn't in now, but it doesn't show up in dms, strange
if i deferupdate a component on a message, and then edit the message itself, does that resolve the component interaction?
for example, <Component>.deferUpdate() but then I do <Message>.editReply();
the defer consumes the interaction
not the editReply
and theres also no such thing as <Message>.editReply
you call it on the interaction webhook
is userselectmenu builder is new in components v2?
it was there before as well isn't it?
Is there a limit of TextDisplayComponents? I receive the error "Invalid Array Length" if I try to add a 4th section. Each section separated by a separator.
thanks
@muted aspen ^^
Oh alright, ty
How to use v2 components
the same way you use regular components, but also passing the IsComponentsV2 flag
Is it possible to make a section with only a button and a thumbnail ?
Is there any guide in the website
nope
I'm not sure how'd that look either way, the positioning for both is the same (assuming you mean a button accessory)
nope
:(
Too bad .. Thank you!
An is this possible to add a color ?
to a container, yes
ContainerBuilder#setAccentColor() discord.js@14.19.1
Sets the accent color of this container.
or if you're using raw data
v10: APIContainerComponent - accent_color
read more
Perfect, thank you! 🙃
ValidationError > s.object(T)
Expected the value to not be an array
Received:
| [ { url: 'https://www.icegif.com/wp-content/uploads/2023/07/icegif-93.gif' } ]
hey im having couple of issue's my bot does not seem to want to register slash commands in a guild ive tried removing the bot and adding the bot still nothing but if i make a new server and invite the bot the commands show up so im not sure what im doing wrong. Yes i've restarted my client and tried different clients
the error is self descriptive, where are you doing that
how are you registering the commands?
const mediaGallery = new MediaGalleryBuilder()
.addItems([
{
description: "Imagen",
media: [
{ url: 'https://www.icegif.com/wp-content/uploads/2023/07/icegif-93.gif' }
]
}
])
const registerCommandsPromise = (
guildId
? rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commandData })
: rest.put(Routes.applicationCommands(clientId), { body: commandData })
).then(() => ({ type: 'registerCommands' }))
const timeoutPromise = timeout(
() => ({ type: 'timeout' }),
config.timeouts?.commandRegistration || DEFAULT_CONFIG.timeouts.commandRegistration
)
media is a single item, hence why it's not plural
then like this?
no, the same thing you were doing but without wrapping in an array
if you deploy to a single guild then it won't appear in others
Where?
in the 14.19 announcement
DiscordAPIError[10062]: Unknown interaction```
I am getting this error on autocomplete. Is this due to timeout?
yes, you replied past the 3s interaction lifetime
ideally you should have all autocomplete values ready to reply, without needing external calls (like to a db)
channel is undefined
also, i cant see the documentation of Client.channels.cache
like what key should .get()
all djs collections are keyed by their snowflake ids
the only exception is probably unicode emojis reactions?
it works fine it creates them in guilds but its just wont create them in one guild
are those commands deployed globally?
yeah
Makes sense, I'll see what I can do
or well, either they aren't, or you didn't invite the bot as a member
i am going to test console.log all the values
I was replying to @weak karma here
well they are tho and i did invite the bot properly because i invited the bot to a different server and it created the slash commands perfectly. It just won't create them in the one server i need them to be created in
you don't need them to "create them" to a specific server if they're deployed globally
by definition if they're deployed globally, they're available to either all servers or none, depending on your context types
i literally just split the values logged them and it just works lol
hey i'm back :D i now can't send, in the same message, 2 embeds with a URL added to both of them, for some reason
if you're using the same url to both, they're deduped to a single one
ahhh, how to circumvent?
don't set the same url
or well, the exact same
if you really need them to have the same url, you could add a # to the end of either
for a browser it should resolve to the same url
yes i know im deploying them globally but they deploy everywhere other then that one guild if that makes sense
alright, thx :)
could you log client.application.commands.fetch() and see if your command is there?
in runtime, post your client login
does anyone know the reason for this?
there seems to be this s command which ive used in a different python script, but no matter how many times i update my commands it doesnt go away
dispatchFor(name: string, interaction: ChatInputCommandInteraction) {
const callback = this.interactionMap[name];
if (callback === undefined) {
interaction.reply("Outdated command.");
} else {
callback(interaction);
}
sounds like you didn't pass the BotDM interaction context type to your command data
you need to re-deploy to let discord know what commands you have, it can't read your code
syncCommands() {
(async () => {
try {
await this.rest.put(
Routes.applicationGuildCommands(
process.env.GUILD || "MISSING",
process.env.UID || "MISSING"
),
{body: this.data}
)
} catch (error) {
console.error(error)
}
})();
}
``` i run this everytime i restart the script
Well you shouldn't run that every time your bot starts...first off
and apparently you're still passing that one command you want to delete
or that code never runs
it does run, it does update my commands when i change them
how do you know
how would i go about that?
are you using builders or raw data?
i did that with discord.py, idk why i shouldnt, its the best and easiest careless way to do so
ContextMenuCommandBuilder#setContexts() discord.js@14.19.1
Sets the contexts of this command.
I'm replying to @summer tundra
i'm using a builder
@summer tundra for builders
hi can somebody help me?
PS C:\Users\stryde\Desktop\gears> npm run deploy
> discord-bot@1.0.0 deploy
> node src/deploy-commands.js
node:internal/modules/cjs/loader:1228
throw err;
^
Error: Cannot find module '../../config.json'
Require stack:
- C:\Users\stryde\Desktop\gears\src\commands\owner\eval.js
- C:\Users\stryde\Desktop\gears\src\deploy-commands.js
at Function._resolveFilename (node:internal/modules/cjs/loader:1225:15)
at Function._load (node:internal/modules/cjs/loader:1055:27)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)
at Module.require (node:internal/modules/cjs/loader:1311:12)
at require (node:internal/modules/helpers:136:16)
at Object.<anonymous> (C:\Users\hollowed\Desktop\gears\src\commands\owner\eval.js:2:21)
at Module._compile (node:internal/modules/cjs/loader:1554:14)
at Object..js (node:internal/modules/cjs/loader:1706:10)
at Module.load (node:internal/modules/cjs/loader:1289:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\stryde\\Desktop\\gears\\src\\commands\\owner\\eval.js',
'C:\\Users\\stryde\\Desktop\\gears\\src\\deploy-commands.js'
]
}
Node.js v22.14.0
PS C:\Users\stryde\Desktop\gears>
you're most likely to reach the ratelimit, and it's an unnecessary api call when you didn't update anything
Because you can get rate-limited/blocked from Discord. The applicationCommand endpoints are restricted endpoints that only allow a small number of requests
path is incorrect, or you put your config.json file in the wrong place
ah thanks
when should i?
when you did update something
imagine doing more things manually~
Manually. When you actually make changes to the data of a command (not the execute...as that doesn't get stored on Discord's servers)
that doesn't answer the question
You shouldn't need to be changing the data of commands very often
well what do u want to see
i already have to run 2 cli commands to run the script
are you changing your data constantly for it to be an issue?
then do it in bulks
console.log(await client.application.commands.fetch())
Again. Not the execute
The data
at one point you won't be changing your command datas at all
ok?
and if you're changing constantly, and deploying constantly, you'll reach the ratelimit either way
i wont, i dont know why i shouldnt, discord.py users do it the way i do
so you might as well just do it manually
instead of reaching it faster when doing unnecessary calls
Discord.py and DiscordJS use the same endpoints. It's just as bad practice in python as it is in JavaScript
and see if your command is there
ive never heard anyone say anything about it being bad in discord.py community
Collection(17) [Map] {
0|kyots | '1366771764310577262' => <ref *1> ApplicationCommand {
0|kyots | id: '1366771764310577262',
0|kyots | applicationId: '962055416802603098',
0|kyots | guild: null,
0|kyots | guildId: null,
0|kyots | permissions: ApplicationCommandPermissionsManager {
0|kyots | manager: [Circular *1],
0|kyots | guild: null,
0|kyots | guildId: null,
0|kyots | commandId: '1366771764310577262'
0|kyots | },
0|kyots | type: 1,
0|kyots | nsfw: false,
0|kyots | name: 'channels',
0|kyots | nameLocalizations: null,
0|kyots | nameLocalized: null,
0|kyots | description: 'Set the panel, logs, and notify channels for the ticket system.',
0|kyots | descriptionLocalizations: null,
0|kyots | descriptionLocalized: null,
0|kyots | options: [ [Object], [Object], [Object] ],
0|kyots | defaultMemberPermissions: PermissionsBitField { bitfield: 8n },
0|kyots | dmPermission: true,
0|kyots | integrationTypes: [ 0 ],
0|kyots | contexts: [ 0, 1, 2 ],
0|kyots | version: '1366771765031862413'
0|kyots | },
then they aren't aware of rate limits
idk man, i think they are as smart as js people
and that's the one command you can't see?
How does autocomplete work, is there a guide 
it's an api related issue, independent of what library you use, whether or not they mentioned it to you isn't the problem
i cant see any of them only in one server tho. If i invite it to a different server it creates them all
do you have the Guilds intent?
yes
can you check if the guild is in client.guilds.cache
so they built entire api wrapper without completely understanding the api? 
it's unlikely they aren't aware, and it's most likely it was just never mentioned to them
or maybe dpy has some extra logic where it can know when it should actually call the api
🤷
they have their own (optional) command framework after all so it could be possible
yep its there
- ice ౨ৎ chat (734867158475079690)
what seems to be the problem?
ah I my slash commands won't register for a server. It's weird because i can invite the bot to a diff server and it will create them. It just won't create them in that one guild
It could be you didn't invite the bot with the Create Application Commands permission
try reinviting the bot?
Aka, kicking it and reinviting it should fix it
yep i tried that multiple times i also tried restarting my client and using a diff client
is there a limit to how many slash commands a server can have?
yes, 100 per bot
that should be okay i only have 17 right now
why is it still throwing even when I added a try catch?
you aren't awaiting it
Sorry if it's already been asked. But are you using applicationCommands or applicationGuildCommands?
it's not about that tho, he's crying about sending the message to dm
how do you know they aren't there?
are you an admin?
you aren't awaiting it
aaah mb ty!
but awaiting the cache 👍
yeah im a admin
yep kinda weird right 😂
yeah you dont have to, so move your await to the ticket_member.send()
go to server settings > integrations > your app and see if the command is there
tag suggestion for @little arch:
Resources to understand Promise:
- MDN: learn more
- Guide: learn more
- JavaScript info: learn more
(await is a part of promises)
ik what it is, I just didnt feel like removing it
oh yes that thing my bot does not show up there actually but if you look at audit looks it shows this
yep done that
meaning there are no commands registered for that server
he is using global commands 
thats the whole problem we are trying to solve :3
oh really oops mb
If I have a command interaction, that gets used by displaying a modal, then when the modal gets submitted, that's a ModalSubmitInteraction.
Now, given this code:
const response = await reason.reply({options here..});
Where response is of type InteractionCallbackResponse,
How can I edit the message of response later, if before I want to edit it, it gets edited elsewhere, and I can't fetchReply that edit, how would I re-edit the message? I can't fetchReply because I call other methods within the class where this is taking place, which use it up and edit it.
sounds like an api problem tbh, ask in ddevs #useful-servers
and don't say that "it won't create them for that guild" since it sounds like you are deploying per guild
which you aren't
you are deploying globally
i still feel like it has something to do with some funky permissions 
is the reply an ephemeral one?
yeah i tried that didn't really get a answer that helped im actually about to give up and go back to prefix commands
Nope
you should be able to fetch it and use the reply like a regular message then
.edit() and everything
Fetch the initial interaction, or the response variable?
well if you can pass around your response, that already has the message
response.resource.message
maybe make a thread in #986520997006032896 then so it doesn't get lost
^^
it says commands are registered but, when i run these commands on my guild, it says sending command, The application did not respond. i think my deploy-commands.js isn't working properly
require('dotenv').config();
const { REST, Routes } = require('discord.js');
const fs = require('fs');
const path = require('path');
const commands = [];
const commandsPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(commandsPath);
for (const folder of commandFolders) {
const folderPath = path.join(commandsPath, folder);
const commandFiles = fs.readdirSync(folderPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(folderPath, file);
const command = require(filePath);
if ('data' in command) {
commands.push(command.data.toJSON());
}
}
}
const rest = new REST({ version: '10' }).setToken(process.env.TOKEN);
(async () => {
try {
console.log(`🔄 Registering ${commands.length} commands...`);
const data = await rest.put(
Routes.applicationCommands(process.env.CLIENT_ID),
{ body: commands }
);
console.log(`✅ Successfully reloaded ${data.length} commands.`);
} catch (error) {
console.error('❌ Deployment failed:', error);
}
})();
if you can use the command then it's deployed correctly
you are just not handling it when you actually receive an interaction for that command
issue is from not replying to the interactionCreate event
or you're doing it too late and getting (and maybe ignoring) an error
how do i create a channel
https://discord.js.org/docs/packages/discord.js/14.14.1/createChannel:Function
GuildChannelManager#create() discord.js@14.19.1
Creates a new channel in the guild.
// Create a new text channel
guild.channels.create({ name: 'new-general', reason: 'Needed a cool new channel' })
.then(console.log)
.catch(console.error);
await guild.channels.create()
what you linked is an internal function
dont have guild
how would you create a channel then
Then where are you going to create a channel 
nevermind
this is interactionCreate.js:
module.exports = {
name: 'interactionCreate',
async execute(interaction) {
if (!interaction.isChatInputCommand()) return;
const command = interaction.client.commands.get(interaction.commandName);
if (!command || !command.slashExecute) return;
try {
await command.slashExecute(interaction);
} catch (error) {
console.error(error);
await interaction.reply({
content: 'There was an error executing this command!',
ephemeral: true
});
}
}
};
tag suggestion for @merry lily:
If you aren't getting any errors, try to place console.log checkpoints throughout your code to find out where execution stops.
- Once you do, log relevant values and if-conditions
- More sophisticated debugging methods are breakpoints and runtime inspections: learn more
i guess interaction should have a channela ttribute right
yes
BaseInteraction#channel discord.js@14.19.1
The channel this interaction was sent in
it even has a guild attribute
dam
interaction.guild.channels.create() i literally cant find the options without so much digging
Hello, there's a PermissionFlagsBits for "ManagePermissions" of a channel, I only fund ManageChannels and my bot cannot any permission of the channel with this permission
well you only need to go to the docs of the interaction type you have, see it has a guild property, see that has a channels property, and see that has a create method
what error are you getting?
what about category id and category position
that's ManageRoles in the API
Wait, what do I do if it is ephemeral
it's not an actual message, so you can only edit through the interaction webhook
aka interaction.editReply()
and only for 15 mins
posted thanks again ^_^
So I added Manage roles permission to MyBotRole, then in permission overwrite I have
{
id: interaction.client.user.id,
allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.ManageRoles]
},
But I got a Missing Permissions error 
A category is technically a channel...so it depends on how you want to find it. You can do channel.parent or you can fetch the category by ID just like any other channel...or pass it as an input in a slash command
the bot needs to have all permissions in that channel its trying to add
Yes, View Channel, Manage channels and manage permissions are checked in the category where the ticket is created
but if i remove manage roles, it's good
ah make sure the bots above the role you are trying to add / remove
It's a category soo
don’t you need manage channel perms to update that?
Yes, I tried to had this permission on the creation of the channel
Category has the permission for my bot but it's not working xd
can ephemeral messages not be edited with <Message>.edit?
how can i fix this, the problem is after running commands it shows problems in terminal:
PS C:\Users\stryde
\Desktop\gears> npm run deploy
> discord-bot@1.0.0 deploy
> node src/deploy-commands.js
✅ Loaded command: eval
✅ Loaded command: ping
🔄 Registering 2 commands...
✅ Successfully registered 2 commands
PS C:\Users\stryde\Desktop\gears> npm start
> discord-bot@1.0.0 start
> node src/index.js
✅ Loaded 3 events
✅ Logged in as Gears#0463
Command eval not found
(node:9688) Warning: Supplying "ephemeral" for interaction response options is deprecated. Utilize flags instead.
(Use `node --trace-warnings ...` to show where the warning was created)
Command ping not found
tag suggestion for @merry lily:
The ephemeral option when replying to an interaction will be removed in v15
- {..., ephemeral: true}
+ {..., flags: MessageFlags.Ephemeral}
``` Read [here](<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR>) on how to specify multiple flags
Hmm are you sure? I tried with and the channel is just not created with Missing permission error, I added "manage permissions, manage channels" to everyone on the category and the bot just can't do that
the category is one specific category not to be passed
i meant like how do i put the created channel in a category
so im trying to get my upvote/downvote buttons to update when pressed but....
[DEBUG] Button pressed: upvote
[DEBUG] Message ID: 1366811348629196882
[DEBUG] Processing component 0, type: 17
[DEBUG] Processing component 1, type: 1
[DEBUG] Buttons found in ActionRow:
[DEBUG] Button 0: customId = comment_button, label = Leave a comment
[WARN] Could not find one or both buttons in component 1
[DEBUG] Attempting to edit message with updated components...
where are they stored if not actionrow? as when i press i get the confirm messages, but nothing changes
we'd have to look at your code, not just the debug logs