#djs-help-v14
78874 messages · Page 44 of 79
What parts
Ideally you should be looking at the actual interaction class you are expecting, like the one below
ChatInputCommandInteraction discord.js@14.22.1
Represents a command interaction.
Ah ok, that makes more sense. I assume CommandInteraction is just a base
why doesnt my code work ? it doesn't put any status on the bot, it's a user application bot
i wanna do something like this
Popular Topics: Frequently asked Questions - How do I set both status and activity in one go?
read more
@kindred bolt ^^
ye but like, it doesnt work
did you open this on a guild that bot is in?
no in DM
Hello I have this command now the issue is intially this command works well and shows me the data from my MongoDB database now when the data size is more than 5 I am using pagination to show that.. So I am using buttons underneath the embed, Now the issue is when I click this button ➡️ I get interaction failed message on discord no errors in the console now I am not understanding what is the issue here
This is my full code: https://sourceb.in/bZ4YkJJudh
and your bot doesn't have the status in dm?
you can put a console.log at the top of your button callback to make sure it's at least executing
yes I tried that its executing, I think I messed up with the custom id
to me it sounds like it's the interaction lifetime
yes I fixed that!
you don't want to make async actions before replying
basically when I am checking with customId over there its returning me the page as an output now when I did interaction.customId it now retruned me the full customId
which is custom-page-all
well you should also change this imo
otherwise it may not work all the time
depending on your db's ping, which is impossible to predict
okay I did not get this one..
what do you mean by interaction lifetime here?😅
you only have 3s to reply to interactions
you don't know how much it'll take for you to get the data from your db
generally it won't take much but it's still an unpredictable variable
okay now I understand that!
so you should defer at the top, before querying, and after the query you can edit the defer to the actual response with the db's results
yes you are correct db ping can sometimes get high and can take more time during read operation
okay thanks for the suggestion
show your code
quite a bit late, but was scrolled up - yes, thye don't because nothing is actually updated. the timestamp is only set once, when timing out. afterwards it pretty much stays there forever and is just compared to for if the member is still timed out or not.
the only other case when it's changed is when you're manually removing the timeout, in which case it'll get set to null instead of a timestamp.
Am I being really silly - does DJS support select menus in modals yet? If so, which builder is it? I'm trying with StringSelectMenuBuilder but it's giving me an API Error saying I'm using the wrong type
check #announcements
we would post there if this feature that is still being released by discord was supported
Ohhh is it not fully out yet
I'd just seen a post about it and assumed it was out fully because it'd been announced.
discord announcing something does not mean we (discord.js) automatically support it
we have to actually implement stuff and then make a release with that new stuff
No I'm aware - I saw this a little while ago, and just ran with the assumption
is it true djs is waiting for file upload before releasing modal update?
no idea
im hoping not 🙏
i just checked the prs again and idk what theyre waiting on, they just did pr for file uploads
on free time
ooooo
maintainers don't exist solely to maintain d.js and sleep
they have lifes too
im aware
lmfao i dont think he was talking about djs
was he not talking about a file uploads pr on discord's api repo
but i ask because theyre now working on file uploads when that isnt even announced yet by discord dev
we have such PRs too
fair enuf
ohhhh i see what you mean
who knows tbf
thats why i think they wait for file uploads to release the entire modal update
yea would check out, but i hope it don't happen cus discord took years to release this update, it'll take them more years for file uploads
if it took them years of not working on it
a week or two won't make a difference
anyway
what
they were not working on this stuff for past years
i cant help but assume you're just trying to ragebait 😭
everything we've said you have a stark opinion
everyone keeps asking, the answers are the same
no ETA on when we release it, for now we don't support it
we are well aware this is open source, and that people maintain it for free - or rather some of the core maintainers are sponsored. we're not in here demanding anything, i asked "hey, has this feature that got released by discord a few weeks ago been ported to the api wrapper yet"?
like, jheez, we get it
and i have said no, pointing to where you can find out when it will be
^ you actually didn't even remotely, you just said "soon we're all volunteers stop asking". it wasn't exactly a helpful answer.
if you say so
but this is getting offtopic
feel free to continue in #archive-offtopic
im not moving to another channel just to fuel a random debate with some random proficient discordjs user 🤣 im in the middle of working on a bot, but ive wasted a load of time now having to talk through this
#archive-offtopic please
Is it possible that subcommands could have different permissions set for them
no
no since its based on base command
Alright thanks
anyone knows how to use new modal components in js
its not yet released in discord.js
ok thx
hi
how can i add file such as this #announcements message
can i get a code such as this to learn how can i do this?
no need to mention random people to get attention, anyone here can help -- not only them
Popular Topics: Display Components
read more
read this guide to see how to create such messages
i can do it but i have problem with file
Is the modals select menu feature added?
Okay
.addFileComponents(
new FileBuilder({
url: "https://cdn.discordapp.com/attachments/1411745112236625951/1418319468114870272/King.txt",
name: "King.txt" // هنا بتحط الاسم مباشرة
})
])
)
check this
where did you get f.setFiles() from?
f is already an instance of FileBuilder
....
what "...", I am asking you a question
.addFileComponents(
new FileBuilder({
url: "https://cdn.discordapp.com/attachments/1411745112236625951/1418319468114870272/King.txt",
name: "King.txt" // هنا بتحط الاسم مباشرة
})
)
check this
@dense jackal Now?
don't wait for me to tell you if its right or not, you can test that stuff yourself as well, but if I remember correctly this is how you can use it yes
ok
.addFileComponents(
new FileBuilder()
.setURL('https://cdn.discordapp.com/attachments/1411745112236625951/1418319468114870272/King.txt?ex=68cdb070&is=68cc5ef0&hm=61c79e7332557dfa423ad5dfb5378ed2119669205196a145aebfc06377d7cb25&')
)
this didnot working
I'd suggest reading the FileBuilder docs - or asking a specific question.
documentation suggestion for @lofty topaz:
FileBuilder discord.js@14.22.1
error in link
[antiCrash] :: Uncaught Exception/Catch (MONITOR)
CombinedPropertyError (1)
Received one or more errors
input.url
| MultiplePossibilitiesConstraintError > s.string().url()
| Invalid protocol for file URL. Must be attachment:
|
| Expected any of the following:
| | - attachment:
|
| Received:
| | 'https://cdn.discordapp.com/attachments/1411745112236625951/1418319468114870272/King.txt?ex=68cdb070&is=68cc5ef0&hm=61c79e7332557dfa423ad5dfb5378ed2119669205196a145aebfc06377d7cb25&'
at _ObjectValidator.handleIgnoreStrategy (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:2119:72)
at _ObjectValidator.handleStrategy (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1983:47)
at _ObjectValidator.handle (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:2089:17)
at _ObjectValidator.parse (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:90)
at FileBuilder.setURL (/home/container/node_modules/@discordjs/builders/dist/index.js:1585:36)
at CustomClient.<anonymous> (/home/container/index.js:2269:7)
at CustomClient.emit (node:events:529:35)
at MessageCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/MessageCreate.js:32:14)
at module.exports [as MESSAGE_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:352:31) uncaughtException
Popular Topics: Display Components - File
read more
read this part of the guide ^
afaik FileBuilder is for local files... you don't need to use FileBuilder if you have an image URL already.
FileBuilder#setURL should start with attachment://
☝️ the djs guide has good helping points in it
FileBuilder#setURL() should be able to support arbitrary URLs as well
no, you need to recreate the attachment through AttachmentBuilder.
Had the same issue with my message logger
Seems like it requires attachment:// URLs, thus - local only
weird
ThumbnailBuilder#setURL() does support it
Then again, if you have the URL for something already why would you want to build a file, it's already a file
What do you even use this method for anyway, the only thing I can think a thumbnail is used in is embeds/containers - but they both have their own builders like EmbedBuilder()#setThumbnail
for setting the URL of an thumbnail accessory in a section?
there's no other way I can think of to put an arbitrary url in the sections accessory
CombinedPropertyError (1)
Received one or more errors
input.url
| MultiplePossibilitiesConstraintError > s.string().url()
| Invalid protocol for file URL. Must be attachment:
|
| Expected any of the following:
| | - attachment:
|
| Received:
| | 'https://cdn.discordapp.com/attachments/1411745112236625951/1418319468114870272/King.txt?ex=68cdb070&is=68cc5ef0&hm=61c79e7332557dfa423ad5dfb5378ed2119669205196a145aebfc06377d7cb25&'
at _ObjectValidator.handleIgnoreStrategy (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:2119:72)
at _ObjectValidator.handleStrategy (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1983:47)
at _ObjectValidator.handle (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:2089:17)
at _ObjectValidator.parse (/home/container/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:90)
at FileBuilder.setURL (/home/container/node_modules/@discordjs/builders/dist/index.js:1585:36)
at /home/container/index.js:2271:6
at resolveBuilder (/home/container/node_modules/@discordjs/builders/dist/index.js:2224:12)
at /home/container/node_modules/@discordjs/builders/dist/index.js:1795:75
at Array.map (<anonymous>)
at ContainerBuilder.addFileComponents (/home/container/node_modules/@discordjs/builders/dist/index.js:1795:56) uncaughtException
Link not supported
i think
no I just got informed it is not
but if you already have a link, why not paste that link
discord formats it nicely (you can already see it in the error you sent)
Ohhh I see where it's used, fair play. Haven't played with components yet.
just put the link of the file inside a text display component
they beat me at my own game!
basically yes, people can still click on it and download the file when they click it
i want file in container
it is the better than link
do you have that file locally
Yes
const file = new AttachmentBuilder("./King.txt");
cool, then just follow the code snippet that's placed on the "File" section of the guide I sent you
const file = new AttachmentBuilder('../assets/guide.pdf'); // << you already have this line
//... container
.addFileComponents(
file => file
.setURL('attachment://guide.pdf');
)
//...
await channel.send({
components: [container],
files: [file], // << do not forget this line!!
flags: MessageFlags.IsComponentsV2,
});
DiscordAPIError[50035]: Invalid Form Body
components[0].components[4].file.url[UNFURLED_MEDIA_ITEM_REFERENCED_ATTACHMENT_NOT_FOUND]: The referenced attachment ("attachment://King.txt") was not found
at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:762:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:1163:23)
at async SequentialHandler.queueRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:994:14)
at async _REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1307:22)
at async TextChannel.send (/home/container/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:195:15)
at async CustomClient.<anonymous> (/home/container/index.js:2278:1) {
requestBody: {
files: [],
json: {
content: undefined,
tts: false,
nonce: undefined,
enforce_nonce: false,
embeds: undefined,
components: [Array],
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: 32768,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined,
thread_name: undefined,
applied_tags: undefined,
poll: undefined
}
},
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: { components: [Object] }
},
code: 50035,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/channels/1362042671799074877/messages'
}
?????
show your code
const file = new AttachmentBuilder("./King.txt");
const container = new ContainerBuilder()
.addTextDisplayComponents((txt) => txt.setContent("## ShareBot"))
.addSeparatorComponents((sep) => sep)
.addTextDisplayComponents((txt) => txt.setContent("تجربة"))
.addSeparatorComponents((sep) => sep)
.addFileComponents(file =>
file
.setURL("attachment://King.txt")
)
.addSeparatorComponents((sep) => sep);
await message.channel.send({
components: [container],
Files: [file],
flags: MessageFlags.IsComponentsV2,
});
in your message payload you used Files instead of files. its written in lowercase only
oh sorry
I made an RP Discord bot, and on the test bot the z.<rp-character id> <message> feature works, but on the verified bot it doesn’t. All the intents are enabled, but it still doesn’t work. Tag me, or reply to this message please
tag suggestion for @slim parcel:
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
whats the max number of input fields a modal can have?
tag suggestion for @cedar kindle:
Learn more about modal limits at the Discord Developer Documentation
thanksi
how could I achieve this layout with images on the right using discord.js + components v2?
you can use sections with thumbnail accessories
guide suggestion for @dusky tree:
Popular Topics: Display Components - Section
read more
i cant use this inside of an embed?
you asked about components v2 which is mutually exclusive with embeds, so no
(also in general embeds don't have any such capability)
you can however use sections in containers
Mm okay makes sense, that's the issue I've been running into. I'm using slash commands at the response output was an embed which I'm trying to convert to use components v2
then you should look into containers (on the same page as the guide above, just farther down)
Will do, thank you!
The buttons at the bottom will be left aligned
that's the only drawback
does d.js have anything similar to game.BindToClose: RBXScriptEvent from roblox?
i don’t quite know what that does
Yeah I dont understand the question at all
node has event listeners for process exit
It says that color is deprecated, but when i change the color: into colors:, i will never be able to create the role. Saying that they cannot convert undefined into number. What's wrong here?
colors takes an object
make sense
Hi, I have a question - I’ve been trying for the past 3-4 hours to hook up ComponentsV2 with a webhook so it can send messages, but the component types keep mismatching. The Discord API keeps complaining that, for example, a Container shouldn’t be Type 17 but Type 1 (Action Row). Is there a way around this? Whenever I try to convert the types, most of the data breaks
Component types are the same across Discord tho
The Discord API keeps complaining that, for example, a Container shouldn’t be Type 17 but Type 1 (Action Row)
I imagine you're just misinterpreting an error along the lines ofValue of field "type" must be one of (1,)
this error means you're only allowed to use action rows as the top level component, which suggests you're missing theIsComponentsV2flag
like this?
flags: MessageFlags.SuppressEmbeds | 1 << 13,
IsComponentsV2 is 1 << 15, why not use the enum for it as well?
sry mb xD
huh? I think I passed the entire components object correctly, but it still complains - and I even added the IsComponentsV2` flag.
const payload = {
components: messageOptions.components ?? undefined,
username: nickname || messageOptions.username,
avatar_url: avatarURL || messageOptions.avatarURL,
flags: MessageFlags.IsComponentsV2,
files: messageOptions.attachments ?? undefined,
};
{
"components": [
{
"type": 17,
"accent_color": 16711680,
"spoiler": false,
"components": [
{
"type": 12,
"items": [
{
"media": {
"url": "https://i.imgur.com/v4llTPJ.png"
},
"spoiler": false
}
]
},
{
"type": 14,
"spacing": 1
},
{
"type": 10,
"content": "> @_lefes_ nie udało ci się zweryfikować!\n- Spróbuj ponownie."
}
]
}
],
"username": "_lefes_",
"avatar_url": "https://cdn.discordapp.com/avatars/508345738137305118/3e626c47383aa7040deaf059fd365c1c.webp?size=4096",
"flags": 32768
}
Failed to send webhook: DiscordAPIError[50006]: Cannot send an empty message
Did you enable with_components in the query parameters?
in webhook url?
Yes
No, I didn’t add it - because I couldn’t find any documentation for it anywhere
is there a way to put seconds in timestamp or i should do it using footer
embed
same error..
Sorry for asking something so dumb, but it’s literally the first time I’m trying to send ComponentsV2 through a webhook - with embeds and all. It wasn’t that hard
try {
const url = new URL(webhookURL);
url.searchParams.set('with_components', 'true');
webhookURL = url.toString();
const webhookClient = new WebhookClient({ url: webhookURL });
const payload = {
components: messageOptions.components ?? undefined,
username: nickname || messageOptions.username,
avatar_url: avatarURL || messageOptions.avatarURL,
flags: MessageFlags.IsComponentsV2,
files: messageOptions.attachments ?? undefined,
};
If ur using WebhookClient, then why aren’t you using camel case?
Don’t need to set it in the url then. It’s part of the webhook.send method
WebhookClient#send() discord.js@14.22.1
Sends a message with this webhook.
Thought you were using /rest package
WebhookMessageCreateOptions discord.js@14.22.1
Options that can be passed into send.
There’s withComponents along with your normal message options (as camel case)
You won’t get proper autocomplete unless you write the object inside of the webhook.send method, or you type payload properly by TS (or JSDocs if using VSC or any editor that supports it)
Thanks, man, that with_components tip really helped me - I just added it to the webhook payload, and the message finally went through
const payload = {
components: messageOptions.components ?? undefined,
username: nickname || messageOptions.username,
avatarURL: avatarURL || messageOptions.avatarURL,
files: messageOptions.attachments ?? undefined,
flags: MessageFlags.IsComponentsV2,
withComponents: true,
};
lmao
are voice channels always cached?
SInce I need to fetch one
guild channels, if you haven't changed the cache limits and if you have the Guilds intent, are always cached, yes.
How can I fetch a voice channel?
const channel = client.channels.cache.get("222086648706498562");
const channel = guild.channels.cache.find(channel => channel.name === "general");
- Caches in discord.js are Collections which extend the native Map structure.
- learn more
THanks! How can I use this djs bot here quickly?
wdym
where can I find all events cheat sheet
in the docs? just like most libraries
which event is the one that triggers when a user joins a vocal channel
voiceStateUpdate
Guys can I juse modals inside here for example?
I want to show the user the modal when he joins the channel
async execute(oldState, newState) {
console.log("ENTRATO O CHE?")
const channelJustJoined = newState.channel;
if (channelJustJoined){
// Se il canale in cui e' entrato l'utente e' un canale di creazione
// Create the modal
const modal = new ModalBuilder()
.setCustomId('myModal')
.setTitle('My Modal');
// Create the text input components
// .......
modal.addComponents(firstActionRow, secondActionRow);
// Show the modal to the user
await interaction.showModal(modal);
}
return;
}
Does it have to work only by slash command? Can I make a way maybe using DMs?
It can only be triggered by a slash command, button press, or context menu
You could send a message in the channel or DMs
Yeah thats what I was thinking.
SEnding him a message with a button so it would open the modal
Ty for the help Chewi ❤️
What is "Access to file uploads has been limited for this guild"
A limitation of the ability to upload files in a particular guild
I want to check if the interaction triggered is a ButtonInteraction, how can I check if its that or a command?
if interaction == Interaction.ApplicationCommand but for buttons?
maybe if interaction.isButton()?
if(interaction.isButton())
BaseInteraction#isChatInputCommand() discord.js@14.22.1
Indicates whether this interaction is a ChatInputCommandInteraction.
That also exists
thanks guys, how can I handle my button code? not inside interactionCreate right|? its messy
yeh u handle it inside the interactionCreate event
js do something like
if(interaction.isButton()) {
return buttonHelper(interaction)
}
and handle all ur buttons inside here
but if the code is pretty big how can I handle it better?
Also now while receiving a buttonInteraction interaction my interaction.member is null
if u dont want to put it all inside the createInteraction function then do what i said above
if u want the guild member of the user who interacted with the button fetch it using interaction.user.id
❤️
No, don't do that
Just get it from interaction.member
forgot that got sent through with the btn interraction @sturdy ravine ^
Hi all!
I have a question about how this function works:
member.permissions.has('ManageGuild') || ```
Will this also check if the user has "ManageGuild" permissions because of a role the user is in or just check if the user has those permissions (at user level)?
Thanks!
Can someone help me create programming code for websites and online games?
That is very much not what this server is for, no.
member.permissions.has() checks if the member has the provided permission from any role
Perfect, thank you!
Hey!
When a modal is open, there's no way to add/remove fields based on a text input content right?
there isn't
How so i make the bot status like this? Like u are online in a mobile
client.user.setActivity()
discord.js does not support this, as you have to actively go against discord's specifications
Thanks for the confirmation, maybe one day haha
yeah it would be very nice to have
Ahh okay
Yea ik i meant the mobile icon
node-gyp try to not be annoying and error: impossible
Does anyone here know about MetaTrader?
not the place to ask use #archive-offtopic
yes, thanks
Is there a way to make it so a bot follows-up a command with an ephemeral message asking for user's input. and then follows up the original command/interaction with a public message ? The point being showing the user's original input in chat. Because right now I can't figure this out and end up with something like this
yes. get the orginal message and reply to that
you cant use interaction followup for that since it will show orginal message delete as in your screenshot
but a slash command is not a message, it's an interaction, right ?
even if I pass it around and do originalInteraction.followUp it ends up like this
the slash command returns a message right? then reply to that message after following up with an ephemeral message
I will try that
do something like this
const message = await interaction.reply()
await interaction.followUp({ flags: MessageFlags.Ephemeral })
message.reply()
Will do !
it never crossed my mind to get the message, I tried storing the interaction tho
each followup is separate from each other
you can followup original interaction ephemerally, and then do another followup to the same interaction non-ephemerally
doing it this way will not require your app's bot to be in the channel to reply to the message, unlike in the code above
export async function chatInput({
interaction,
store,
}: ChatInputCommandContext) {
const ogInteraction = interaction;
await ogInteraction.deferReply({ flags: MessageFlags.Ephemeral });
// stuff
await ogInteraction.followUp({
flags: MessageFlags.Ephemeral,
content: "Eph,",
});
// other stuff
await ogInteraction.followUp({
content: "non eph",
});
}
That's what I tried before, it act not as you would expect
hm
This interesting, isn't it heh
oh
you don't have 2 followups there actually
you only have one
because you never replied
Mmmh
you said you will reply later, and then never did so, only following up
so the first one is being treated as reply() by discord
Ok let's see
I think what I am trying to do is actually impossible
reply non-ephem with a placeholder
followup ephem asking the user
edit reply to show data taken from user
don't see much point in having 2 followups be public
you can edit the original reply since that will keep the command usage
and you can update the ephemeral followup after taking user input as well
yes, but you can't edit an ephemeral message to be non-ephemeral, that's the problem
why do you need 3 messages
you have a public reply(), and an ephemeral followup
ask the user ephemerally, edit the already existing public message
you can edit both just fine independently, you don't really need to edit ephemerality of them
if you need to separate the original reply() from data provided by user, follow up non-ephemerally
but after you reply()
the actual reply is needed for followups to be followups
I don't think that's such a good idea to have a placeholder message in public channel while the user do their stuff. That's polluting (imo) and what if the user takes a long time or change their mind ?
then you can have a timeout on your end
but at this point it's either or
either you keep it public to show it publicly how you want
or you reply ephemerally and have a non-ephem point to nowhere when they submit
you can even just leave a defer itself running non-ephemerally
pretty sure if you try to follow up ephemerally it shouldn't get treated as a non-ephem reply
but then i never tried that, so am not 100% sure
I'm trying your proposals to no success
You should try it for fun, it's a head scratcher this one
show
I'm updating my logging to components v2 and struggling with resending images. I'm taking the message event and extracting the attachments. I'm trying to rebuild them into a gallery but no luck so far. What am I missing here?
const attachment = message.attachments[0].attachment;
const file = new AttachmentBuilder().setFile(attachment);
const exampleGallery = new MediaGalleryBuilder().addItems((mediaGalleryItem) =>
mediaGalleryItem.setURL(attachment),
);
await interaction.editReply({
components: [exampleGallery],
files: [file],
allowedMentions: {
parse: [],
},
flags: [MessageFlags.IsComponentsV2, MessageFlags.Ephemeral],
});
what does "no luck" mean here
The message sends with a image gallery but the image is "Image not found"
const attachment = message.attachments[0].attachment;
that line looks quite wrong
message.attachments is not an array but a Collection
Well I threw this snippet together to try and demonstrate. I'm actually using map
then please show actual code
so that we can look at actual issues, not code threwn together that might be wrong in different places
After receiving a message event containing an image and attempting to resend it:
const [exampleGallery, attachments] = message.attachments.reduce(
(acc, attachment) => {
acc[0].addItems((mediaGalleryItem) => mediaGalleryItem.setURL(attachment.attachment));
acc[1].push(new AttachmentBuilder().setFile(attachment.attachment));
return acc;
},
[new MediaGalleryBuilder(), []],
);
const channel = message.guild.channels.cache.get(message.channelId);
await channel.send({
components: [exampleGallery],
files: attachments,
flags: [MessageFlags.IsComponentsV2],
});
Send the "image" but the image is blank with "Image Not Found"
what is the attachment.attachment supposed to be?
What do you mean? It's the field that is returned as part of a message attachment collection. Actually in that collection each attachment has attachment, url, and proxyURL. From what I can tell in the case I'm testing, attachment and url are the same.
Message has a Collection of Attachments, yes
but those Attachments in that Collection are already Attachments
there is no Message.attachments.first().attachment
Only AttachmentBuilder has an attachment prop
but on a constructed instance, not as a requirement on passing to it
Well, when I'm console logging attachment in the .reduce, the object definitely has attachment.attachment
show
code and log
then it might just happen to be an undocumented property which we serialize
it's still undocumented by us and might not even be there tomorrow, so you can see why i'm reacting this way
if it's the same, use the url since that one actually exists
Okay, so you're saying I should switch to using attachment.url
When I do that, I get the same result
and what url(s) do you pass to the gallery
const [exampleGallery, attachments] = message.attachments.reduce(
(acc, attachment) => {
acc[0].addItems((mediaGalleryItem) => mediaGalleryItem.setURL(attachment.url));
acc[1].push(new AttachmentBuilder().setFile(attachment.url));
return acc;
},
[new MediaGalleryBuilder(), []],
);
const channel = message.guild.channels.cache.get(message.channelId);
await channel.send({
components: [exampleGallery],
files: attachments,
flags: [MessageFlags.IsComponentsV2],
});
the urls, not variables
You want the actual URL of the image I'm using?
the one you're passing into the gallery that doesnt' work
is the chunk size limit for all managers (users, messages, etc) the same 100?
https://cdn.discordapp.com/attachments/1195823057131012128/1418623823233945640/Byl6BHzEv7tWDGa5QUgztneq8C8TGYelu8ywVMTTRUH2e9keboyLqL4YhmzaU3vjgA.png?ex=68cecbe4&is=68cd7a64&hm=cfb2d1e91a971c30da3a4dcaa1fd39437ec730a2e4544cc7ea3f8f838fc6ec08&
is that what's in the gallery you built or just in the Attachment log
This is attachment.url from above. In practice, it would be whatever attachments the user sent in their messages. I'm limited to whatever's in the message.attachments collection
and is it actually
please just log the media gallery
hi i have one question
i can use title on a container ?
container is not an embed
i know but i want a title in container
then use a text component
Here's the media gallery logged
"type": 12,
"items": [
{
"media": {
"url": "https://cdn.discordapp.com/attachments/1195823057131012128/1418623823233945640/Byl6BHzEv7tWDGa5QUgztneq8C8TGYelu8ywVMTTRUH2e9keboyLqL4YhmzaU3vjgA.png?ex=68cecbe4&is=68cd7a64&hm=cfb2d1e91a971c30da3a4dcaa1fd39437ec730a2e4544cc7ea3f8f838fc6ec08&"
}
}
]
}
You are really right, I didn't think about it.
I just checked to confirm that the media gallery url is identical to attachment.url
Does discord just not allow images from its cdn to be resent in an image gallery? I don't have this problem with my current components v1 application but that version just resend the image. I don't attempt to place it into an embed
Hi!
I'm updating my code to v14 and I'm unable to have the content of the messages deleted again
I was using:
client.on('messageDelete', async message => {
.......
if (message.content !== null && message.content !== undefined) {
if (message.content.length < 1024) {
---Return message.content
I'm getting the log of deletion of a message but the message.content is empty every time
sounds like you don't have the MessageContent intent
or they're partial messages
though they'd be null in that case
the !== undefined is always true
Message#content doesn't claim to be nullable in the docs...isn't it just ""?
It's not null, it will be '' alsways
when you don't have the intent it's empty, on partial messages it's null
o7
hello, i have an issue with the embed,
first image show the last lines in the embed,
second image show when i do
const lines = description.split('\n');
for (let i = Math.max(0, lines.length - 10); i < lines.length; i++) {
console.log(`Line ${i + 1}: "${lines[i]}" (${lines[i].length} chars)`);
}```
so, when i log the description, i will see the correct content
but in Discord, few lines will be missing
Discord.js version: 14.21.0
Discord trims whitespace
It’s fine, but last lines
- 002
- 001
- 1 more line
Does not appears
I tried to do something like this
embed.setDescription(description.slice(100))
It worked and showed the last lines correctly.
But the length of this is less than 3000
What’s on the first 100 characters?
Some other roles
Roles from 1 to 100
SomeText
-100
….
-001
SomeText
I am trying since yesterday
Why is that if
...
.addSectionComponents(
section => section
.addTextDisplayComponents(
textDisplay => textDisplay
.setContent("La stanza verra automaticamente **eliminata** se vuota!"),
textDisplay => textDisplay
.setContent('Lo staff di **Gaming House** si occuperà della gestione!'),
)
.setButtonAccessory(
button => button
.setCustomId('endbutton')
.setLabel('Avanti')
.setStyle(ButtonStyle.Primary),
),
);
If I remove .setButtonAccessory it gives me an error CombinedError: Received one or more errors
Accessories are required for Sections
I mean I can directly click on the TextDisplayComponents, why do I need a button
did my example not work?
Blame Discord
Are you answering me? xD
¯_(ツ)_/¯
Yea
wtf, why do I need a button there If basically a textDisplayComponent is a button that I can even listen to as an interaction
Hey everyone, noticing a problem where when using select menus the value doesn't reset to the placeholder... Same doesn't happen with mobile. Is it a desktop app error or am I doing something wrong?
oh wait no still happens on phone. can i reset without editing the whole message each time someone uses it?
FOrza napoli
LOL yeah italian moment gg
So I thenhow I filter(catch) this TextDisplayComponents interaction?
You can prevent the error by not using a section when you don't need an accessory. Just replace the whole section with a text display
that's how they developed it for some reason, it's only shown to you though. but editing the message is the only way
WHy
async function chooseChannelName(interaction) {
console.log(interaction.type)
const selectedOption = interaction.values[0];
const channelName = selectedOption === 'private' ? 'Stanza Privata' : 'Stanza Pubblica';
await interaction.update({ content: `Hai scelto una **${selectedOption}**. Ora, per favore, inserisci il nome della tua stanza vocale personalizzata.`, components: [] });
// Imposta un collector per il messaggio di risposta
const filter = m => m.author.id === interaction.user.id;
const collector = interaction.channel.createMessageCollector({ filter, max: 1, time: 60000 });
collector.on('collect', async m => {
const roomName = m.content;
await interaction.followUp(`Perfetto! La tua stanza si chiamerà **${roomName}**. Procedo con la creazione...`);
// Qui puoi chiamare la funzione per creare il canale con il nome specificato
// createVoiceChannel(interaction, roomName, selectedOption);
});
collector.on('end', collected => {
if (collected.size === 0) {
interaction.followUp('Non hai inserito un nome per la stanza. Per favore, riprova.');
}
});
gives me DiscordAPIError[50035]: Invalid Form Body?
please show the full error
DiscordAPIError[50035]: Invalid Form Body
data.content[MESSAGE_CANNOT_USE_LEGACY_FIELDS_WITH_COMPONENTS_V2]: The 'content' field cannot be used when using MessageFlags.IS_COMPONENTS_V2
yes, you cant update the message to have no components and content when they had componentsv2
So I have to add componentsv2?
that's not what the error means. you can't use the content field when using components v2
So how would I send the interaction.update?
you make the update message also componentsv2 or you use a followup instead
making a message an IS_COMPONENTS_V2 message is an irreversible action. as soon as you do it, the content field is permanently removed
still need to get acquainted with componentsV2
ty boys
which Componentv2 is basically an input text field?
Popular Topics: Display Components - Text Display
read more
oh text INPUT field...none of them
you can use a modal for text input
how would the user know to click on the text display?
a button that does not look like a button isn't really intuitive
there's no text displays interactions
I think updating the message in any way resets its state, someone shared that Message#supressEmbeds(false) works
The TextDisplayComponents seems already like a button and it is actually
its a window menu basically
textdisplaycomponent is NOT a button in any way. it's purely a DISPLAY component
I think you misunderstand what a text display is, it really sounds like you're referring to something else
a text display quite literally only displays text, like a message's text
I mean this one
its basically a button
thats a select menu
Yeah meant that, my bad
it also doesn't take user input. it only uses predefined options
mhhh only option is a modal? There's not an input field component
then for your original question, you have a section, you still need an accessory
or slash commands
make a button on your cv2 message that opens a modal...that modal has a text input component...use that text however
Ill try thanks
👀
I'm studying Components v2. I got curious, is it possible in cv2 to split text into two columns like it was in fields embed?
like:
field1 field2
text1 text2
no. there is no inline feature for cv2
Guys any idea why on my second discord account the modal from my bot works as expected while on my first account it doesn't show up?
const collector = interaction.channel.createMessageCollector({ time: 15_000 });
collector.on('collect', m => {
console.log(m);
});```
for some reason the message content field appears empty
my bot has the messages content intent
nvm i was missing GatewayIntentBits.MessageContent in my intents
Are you using the same Discord client
Discord bots still can not stream just asking its been a while since i coded on i started coding on V10
they cannot stream
FYI I'm pretty sure I figured out the problem. My bot is moderating certain images and deleting the original message. For some reason, when resending the image in a components v2 media gallery I get "Image not found", but if I resend the image as a basic file attachment it renders correctly. Both methods use the same message attachment URL. I haven't tested this for an embed. I'm not sure what's causing this distinction.
Deleting the original will mean the image is gone
I don't understand how sending it as a file attachment is the same url?
If I navigate to the image that was deleted, using the attachment URL, the image is still on the cdn
I've tested this. Components v2 doesn't work, but a basic message send does.
const [exampleGallery, attachments] = message.attachments.reduce(
(acc, attachment) => {
acc[0].addItems((mediaGalleryItem) => mediaGalleryItem.setURL(attachment.url));
acc[1].push(new AttachmentBuilder().setFile(attachment.url));
return acc;
},
[new MediaGalleryBuilder(), []],
);
const channel = message.guild.channels.cache.get(message.channelId);
// This results in Image not Found
await channel.send({
components: [exampleGallery],
files: attachments,
flags: [MessageFlags.IsComponentsV2],
});
// This sends the image correctly
await channel.send({
files: attachments,
});
wait, actually, why are you both setting gallery to be url of already sent message, and then upload the files from that same message as attachments in that same message

I wasn't sure about that part. The docs were confusing on whether I needed to include the attachment in files in order to send it in a media gallery.
media gallery takes urls
https://my.image.com is a url
attachment://myimage.png is also a url that would be pointing to attached file with that name
Okay, I commented out the files part of the components v2 message. Same result
then no idea
It may just be a discord thing
if all the urls are set correctly then it's not looking like our fault
might be better of asking in ddevs
Yeah, thanks for the help. Thinking about it, I'm not surprised that I can't add an image to a media gallery that's probably marked for deletion but the image definitely hasn't been garbage collected by discord yet. Resending the image in a basic message might not check for whether the original image was deleted
it's deleted immediately
if you're still able to open it in your browser it's because it's cached locally on your pc by that browser
good point
and eventually still might happen to be cached by the cdn, but that's rarely the case
Could not DM family_guy323213: DiscordAPIError[50007]: Cannot send messages to this user
0|Penguin | at handleErrors (C:\Users\Mssmi\OneDrive\Desktop\nate assets\custom bots\nate\node_modules\@discordjs\rest\dist\index.js:762:13)
0|Penguin | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
0|Penguin | at async SequentialHandler.runRequest (C:\Users\Mssmi\OneDrive\Desktop\nate assets\custom bots\nate\node_modules\@discordjs\rest\dist\index.js:1163:23)
0|Penguin | at async SequentialHandler.queueRequest (C:\Users\Mssmi\OneDrive\Desktop\nate assets\custom bots\nate\node_modules\@discordjs\rest\dist\index.js:994:14)
0|Penguin | at async _REST.request (C:\Users\Mssmi\OneDrive\Desktop\nate assets\custom bots\nate\node_modules\@discordjs\rest\dist\index.js:1307:22)
0|Penguin | at async DMChannel.send (C:\Users\Mssmi\OneDrive\Desktop\nate assets\custom bots\nate\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:195:15)
0|Penguin | at async Object.execute (C:\Users\Mssmi\OneDrive\Desktop\nate assets\custom bots\nate\Messages\hr cmds\moderation\ban.js:54:4)
0|Penguin | at async execute (C:\Users\Mssmi\OneDrive\Desktop\nate assets\custom bots\nate\Events\PrefixHandler.js:61:4) {
0|Penguin | requestBody: {
0|Penguin | files: [],
0|Penguin | json: {
0|Penguin | content: 'You have been banned from **penguin development**.\n**Reason:** t.',
0|Penguin | tts: false,
0|Penguin | nonce: undefined,
0|Penguin | enforce_nonce: false,
0|Penguin | embeds: undefined,
0|Penguin | components: [Array],
0|Penguin | username: undefined,
0|Penguin | avatar_url: undefined,
0|Penguin | allowed_mentions: undefined,
0|Penguin | flags: undefined,
0|Penguin | message_reference: undefined,
0|Penguin | attachments: undefined,
0|Penguin | sticker_ids: undefined,
0|Penguin | thread_name: undefined,
0|Penguin | applied_tags: undefined,
0|Penguin | poll: undefined
0|Penguin | }
0|Penguin | },
0|Penguin | rawError: { message: 'Cannot send messages to this user', code: 50007 },
0|Penguin | code: 50007,
0|Penguin | status: 403,
0|Penguin | method: 'POST',
0|Penguin | url: 'https://discord.com/api/v10/channels/1387256255499866232/messages'
0|Penguin | }
DiscordAPIError: Cannot send messages to this user
Your bot is trying to send a DM to a user, but failed to do so:
- The user has DMs disabled or the bot blocked
- The user no longer shares a guild with the bot (make sure to send informational DMs before banning/kicking)
- The bot is trying to DM itself or another bot
Note: You cannot check if you can send a DM beforehand but have to handle the rejection case
const mainContainer = new ContainerBuilder()
.setAccentColor(0x0099FF)
.addTextDisplayComponents(
textDisplay => textDisplay
.setContent('!\n**Choose category'),
)
.addActionRowComponents(
actionRow => actionRow
.setComponents(
new ChannelSelectMenuBuilder()
.setCustomId('choose')
.setPlaceholder('Scegli la categoria')
.setChannelTypes('GuildCategory')
),
)
guys how can I list all categories in my guild.
But this is inside DM
I am using ChannelSelectMEnuBuilder but it lists nothing
use .setChannelTypes(ChannelType.GuildCategory), not a string
damn it still lists nothing
Does the server even have any categories? If not thats your issue, if it actually shows nothing then its probably not something about djs
Yeah it does actually. Could it be because its a DM?
But I need the select menu to list em all :((
I’m not entirely sure - are the new components for the Discord modals ready and usable, or how does that work?
Since its a DM do I really need to populate it statically or dinamically? Please no...
Yh, there arent any guild channels in a dm lol
not available in djs yet, no etas as always
Ah, thanks for the info.
you need to populate it dynamically
there's no way for discord to know which guild's channels you'd want to show
nooooooooooooooooo
well it's not that hard
just iterate over the channels, if it's of .type category then add it
and done
though it wouldn't work if you have more than 25 categories, that'd be the only issue
25 max for a select menu?
for the manually populated menus, yes
string or number currently
you'd use a string in this case, your option value would be the category id
technically there's also a 25 limit for the automatically populated ones, but it's how many it shows at a time, not how many it "holds", if the user types something they can filter and it can show others than the currently 25 shown
thanks @rose tangle ❤️
Can't I send using a button?
my code is
await interaction.deferReply();
const select = new ChannelSelectMenuBuilder()
.setCustomId('starter')
.setPlaceholder('Make a selection!')
.setChannelTypes([ChannelType.GuildCategory])
//.addOptions(options) --- IGNORE ---
//.addOptions( --- IGNORE ---
.setMinValues(1)
.setMaxValues(10);
const row = new ActionRowBuilder()
.addComponents(select);
await interaction.editReply({
content: 'Select users:',
components: [row],
});
no
wouldn't it be aesthetically better?
once the user unfocuses the menu, the interaction is sent
well that's more of a design choice
I don't think one is objectively better than the other
but that's how discord decided it
Only because people may unfocus to look at other things because they don't know
if you're making a submission flow where the user needs to select many things before submitting, you could use a modal once djs supports select menus in modals
yea sure
using a modal? Wait arent modals only for inserting text? how could I Use a modal here
you used to be able to submit only text, yeah
until a few weeks ago when they added select menus and text displays
but djs doesn't support that yet, it will in the future though
uh in modals? sheesh so cool
Is there a limit to how many options I can provide with an autocomplete interaction?
25
thanks 
I've been trying to use thumbnail while using componentsv2 but I've been having issues with it, is there a way to do it?
share your issue
you aren't really using a thumbnail anywhere there
Popular Topics: Display Components - Thumbnail
read more
here's an example if you need one, it needs to be inside a section
sorry I sent you the old one
https://gist.github.com/DogitoMB2006/92da35378639b55d121af93ad1516585
there is a space in bewteen the thumbnail and where hanma is, is there a way to fix it?
for example like this, I tried to use title but I'm seeing is not possible
Error in specs command: TypeError: (intermediate value).setTitle is not a function
make the section's text display have the text you want to show alongside the thumbnail
I'll try.
something like
.addSectionComponents(
new SectionBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder()
.setContent(`**Hanma V.0.01**`)
)
.setThumbnailAccessory(thumbnail)
)```?
that's what you have already no?
new SectionBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder()
.setContent(`**Hanma V.0.01**`)
)
that text display should contain all the text you want in the section
you can add 5 of them in a single section, though there's no visual difference other than a new line
ohhh
thanks it worked lol thanks for the tip
.setAccentColor("#364f6a");
Argument of type '"#364f6a"' is not assignable to parameter of type 'number | RGBTuple | undefined'.
just to confirm this is correct
it's correct
write it as 0x<hex>, 0x364f6a in your case
if you really need it to be a string, like for user input, then you can use the resolver
resolveColor discord.js@14.22.1
Resolves a ColorResolvable into a color number.
can someone give me an example using footer with componentsv2 obtaining the iconurl
for example
There's no analog in cv2
any way to fetch multiple channels ? like 20 channels at once
ChannelManager#fetch() discord.js@14.22.1
Obtains a channel from Discord, or the channel cache if it's already available.
// Fetch a channel by its id
client.channels.fetch('222109930545610754')
.then(channel => console.log(channel.name))
.catch(console.error);
If you don't specify an ID, it fetches all channels for a guild
no
mainly I have 20 guilds
and 20 define channel
any way to fetch those 20 channel at once
to avoid api rate limit in case
Why are you fetching them though, arent they in your cache?
if i m using interaction.reply()
whats the tag to enter for displaying user selected in the command ?
like
/user {option: user}
reply: {user} is user
its just an xample
const user = interaction.options.getUser('option-name')
depends on what option you pass in
um:
name:'member',
description:'The member to ban',
required: true,
type:ApplicationCommandOptionType.Mentionable,
},
{
name:'reason',
description:'The reason for this ban',
type:ApplicationCommandOptionType.String,
},
],
permissionsRequired: [PermissionFlagsBits.BanMembers],
callback: (client, interaction) => {
interaction.reply(`${ta}`)
how to make it so like: royalmessager was banned from the server for {reason}
ive put optionss: []
then {} and fdefined all the options
why is member a mentionable option
that should be a User option
alr
Slash Commands: Parsing options - Command options
read more
tysm
When is modal components getting added for d.js
when theyre ready + 1 day for every time someone asks
ehm ok
How to add a String/Channel/Role SelectMenu into a modal
😭
or can we use discord api to add 
Not ready in discord.js yet
yh but you cant receive the interactioncreate event
async addcategorycommand(interaction){
console.log(interaction.type)
await interaction.deferUpdate();
const selectedOption = interaction.values;
await addCategoryToDB(interaction.client.dbPath, selectedOption);
const mainContainer = new ContainerBuilder()
.setAccentColor(0x0099FF)
.addTextDisplayComponents(
textDisplay => textDisplay
.setContent('!\n**Scegli** la categoria del gioco a cui giocherete!'),
)
await interaction.followUp({components: [mainContainer]});
}
ANy idea why I get
DiscordAPIError[50035]: Invalid Form Body
components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
Not setting the IsComponentsV2 message flag
ty ❤️
How do I modify the content of addTextDisplayComponents of my ComponentBuilder?
Are you trying to update a TextDisplay from a message?
more or less
it is just the text display in the components or are their other components
I think that's not aesthetically pleasing tbh. Tips? ahah
you could put the select menu in the container
btw to answer this is you just need to replace the text display with a new one
Warning: Supplying "ephemeral" for interaction response options is deprecated. Utilize flags instead
So here is the problem?
await interaction.deferReply({ ephemeral: true });
or here
return await interaction.followUp({
content: '',
components: [emptyContainer],
ephemeral: true ,
flags: MessageFlags.IsComponentsV2,
});
tag suggestion for @sturdy ravine:
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
❤️
do I even need to remove it from here
await interaction.deferReply({ ephemeral: true });
```?
And why do I get this
I need to OR it?
Bitwise OR, yes
I need to remove ephemeral from here too?
return await buttonInteraction.reply({
content: '❌ Solo chi ha eseguito il comando può utilizzare questi bottoni!',
ephemeral: true
});
```?
also yes, flags should be used for deferReply
it should be switched to flags.
ephemeral is depreciated in favor of flags per the above bot message
so I'll remove it from deferReply and have it only on the interaction's reply with flags
do you need the deferReply?
Yea
then use it with the ephemeral flag
yep
sorry missed the "it" in your message
will I also need
to have IscomponentV2
await interaction.deferReply({ flags: MessageFlags.IsComponentsV2 | MessageFlags.Ephemeral });
or just the main ephemeral flag
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
they are not related aint they
you do not need to add the cv2 flag
one thing to note: is that once the ephemeral or cv2 flag has been added to a message it can not be removed
I mean who cares no? Why would you remove the cv2 flag ?
embeds do not work in cv2 including links embed , Discord events, etc.
I still don't understand if the role selection has been added to modal windows or is it still in development?
Error: Cannot properly serialize component type: 18
its not announced in #announcements so d.js doesn’t support it yet no
but yes it is available using the Discord API, and you can show modals with the select menus using client.rest to send raw API requests
there is as of now absolutely no way of receiving modal interactions with select menus as the d.js validators will stop it
Got it, thanks
Hello, could you please tell me how to move the right-side buttons to the bottom?
This is how it's done in component v1, but I want to do the same in component v2.
const thumbnailComponent = new ThumbnailBuilder({
media: {
url: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQXE_Gu7jDGVgOIv6I8iQguv4TXQx8_igS5AQ&s',
},
});
const container = new ContainerBuilder()
.setAccentColor(0x0099FF)
.addSectionComponents(section =>
section.addTextDisplayComponents(td =>
td.setContent('# test voice channels')
)
.setThumbnailAccessory(thumbnailComponent)
)
.addSeparatorComponents(separator => separator);
for (const ch of voiceChannels) {
container.addSectionComponents(section =>
section
.addTextDisplayComponents(td => td.setContent('\u200b'))
.setButtonAccessory(btn =>
btn
.setCustomId(`vcbtn|${ch.id}|${roleId}`)
.setLabel(ch.name)
.setStyle(ButtonStyle.Secondary)
)
);
}
await message.channel.send({
flags: MessageFlags.IsComponentsV2,
components: [container],
});```
To move buttons to be the same as components V1, just don't use a section. Use an actionrow instead
ContainerBuilder#addActionRowComponents() discord.js@14.22.1
Adds action row components to this container.
These buttons are now in a row on the left
Correct. There's only right align and left align
Is it possible to make something like 5 buttons in a row across?
ehh, that’s how an action row works?
you have 2 options for buttons
- the old style of action rows...1-5 buttons left aligned on a horizontal row
- a single right aligned button attached to a section component
or use 5 action rows to make it “left vertically aligned”
Ok yes that's an option as well...a bad one but you do you
yeah its a bad one lol, but its one possible option too
oh
guys client.application.commands.set takes about an hour to work, but what if i loop through every guild and perform a
guild.commands.set would it immediately update the commands for all servers??
global commands haven't taken substantial time to deploy/roll out for years at this point
ow guess i was stuck in a cave 💀
You need to restart your discord app to clear your commands cache on the client
(Ctrl+R)
oh
that one is quite odd, because there used to be a forward repair mechanism for it, where using it once would re-fetch them so the second would be correct
seems like it still persists (the duping of commands)
duping? that's something else entirely
If you have duplicate commands on your server, you registered both global and guild commands.
You can remove the duplicates by resetting either the global or guild commands
- Resetting global commands:
rest.put(Routes.applicationCommands(clientId), { body: [] }) - Resetting guild commands:
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] })
that means you deployed the same command globally and to the guild
ah i see, ty
I’m converting a pdf into an image and trying to send that image through filebuilder in components v2. does filebuilder only accept urls? because using attachment:// doesn’t seem to work
You need to attach the file to the message using the attachment builder and files property
Popular Topics: Embeds - Attaching images
read more
The above guide is for embeds but the principal is the same for components V2
tysm. after struggling for another 15 minutes i realized i had forgotten to install the required system libraries for the image conversion library to work properly

Is there any way to set a voice channel's status through a bot?
how do we do components v2?
Unfortunately its not documented by discord, so its not a thing in discord.js.
You can, however, make a raw API request to /channels/channelId/voice-status
hello, does known as badge exist somewhere in dapitypes?
guide suggestion for @olive lantern:
Popular Topics: Display Components
read more
Aaah, okay. Thank you!
or it's protected from being exposed? cause i want to check whether user had pomelo experiment and just display badge of it ( e.g in userinfo command )
no, its not a thing
that's a shame
guilds are always cached?
if you haven't manipulated the caches and you have the Guilds intent, yes
same as channels and roles
how do I get the text from a modal?
ModalSubmitFields#getTextInputValue() discord.js@14.22.1
Gets the value of a text input component given a custom id
i am getting this error in embed field since long time: Expected: expected.length <= 1024
although i am checking the length to be less than 1024
is there a good way to check string length for Discord or Embed staff
the method DiscordJS does it is by using zod to validate the object using a schema
export const embedFieldPredicate = z.object({
name: namePredicate,
value: z.string().max(1_024),
inline: z.boolean().optional(),
});
you can implement your own pre-validate it or you can run .toJSON() which will run the built in validate
public toJSON(validationOverride?: boolean): APIEmbedField {
const clone = structuredClone(this.data);
validate(embedFieldPredicate, clone, validationOverride);
return clone as APIEmbedField;
}
Is there anyway to remove the warning since it isn't coming from any of my files > ```
(node:25940) DeprecationWarning: The ready event has been renamed to clientReady to distinguish it from the gateway READY event and will only emit under that name in v15. Please use clientReady instead.
at WebSocketManager.triggerClientReady (C:\Users\ytblu\Desktop\C4 Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:389:15)
at WebSocketManager.checkShardsReady (C:\Users\ytblu\Desktop\C4 Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:368:10)
at WebSocketShard.<anonymous> (C:\Users\ytblu\Desktop\C4 Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:198:16)
at WebSocketShard.emit (node:events:518:28)
at WebSocketShard.checkReady (C:\Users\ytblu\Desktop\C4 Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:184:12)
at WebSocketShard.gotGuild (C:\Users\ytblu\Desktop\C4 Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:158:10)
at WebSocketManager.<anonymous> (C:\Users\ytblu\Desktop\C4 Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:238:15)
at WebSocketManager.emit (C:\Users\ytblu\Desktop\C4 Bot\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:287:31)
at WebSocketShard.<anonymous> (C:\Users\ytblu\Desktop\C4 Bot\node_modules@discordjs\ws\dist\index.js:1190:51)
at WebSocketShard.emit (C:\Users\ytblu\Desktop\C4 Bot\node_modules@vladfrangu\async_event_emitter\dist\index.cjs:287:31)
The warning is triggered when the ready event fires, not when the listener is added
Aaaaah! Alright, thank you!
you can also get rid of it by listening to what it says
You can use the newListener event to trace who’s adding the listener
'newListener'
The EventEmitter instance will emit its own 'newListener' event before a listener is added to its internal array of listeners.Listeners registered for the 'newListener' event are passed the event name and a reference to the listener being added.The fact that the event is triggered before adding the listener has a subtle but important side effect: any additional listeners registered to the same name within the 'newListener' callback are inserted before the listener that is in the process of being added.
Guys I have one design question. Imagine I have a discord bot, but sometimes I want to trigger some events from my HTTP backend server, that is imagine sending an HTTP request to my backend for "Creating a channel", my backen triggers bot's command/function to create a channel. Is this possible and if yes then how to do it? Based on my research, Discord.js does not allow you to expose Bot's APIs as HTTP, so the only way to do so is to run separate app (like express or fastify) as a backend and in the handler of the endpoint trigger the Bot's function. But to be honest I don't like this method because running 2 in parallel with each other is a good idea (based on my experience). So long story short, what are the possible options/strategies to expose Bot's endpoints?
This is not a Discord.js question try over in #1081585952654360687 or a general programming discord #useful-servers
should i use deferReply on every command that uses the database?
i feel like thats a question for this chat
I mean, imo it depends. A leaderboard were you fetching loads of data? Yes. A simple command? No. But if your db is over the other side of the world then maybe
You have 3 seconds, if your queries are long then yes if not then there’s no need
It's generally just a good idea to use defer any time you hit an external entity. Those are unreliable and unpredictable
But ya, it realistically doesn't matter for tiny database requests. It adds extra latency on the response for the protection against a very rare circumstance where your DB is hung up on something so much so it takes several seconds to respond
is it possible to append information to a modal? Since I recall it from another function I need to pass a parameter
you could pass it in the custom id or if the info is more than you could store it and then recall it based on a value in the custom id
I could pass it on the customId but then when I handle it from interactionCreate it would not work
Why not? What are you passin?
Basically my info is a parameter that can be private or public, but when I handle the modal from interactionCreate I will trigger two different functions based on that previous parameter
I do have a TextInputBuilder component in my modal
that could be added to the custom id as a single charter then based on that execute the set function
Or you can store a Collection of "in progress" interactions keyed by a customID
but my interactionCreate handle is like this
if (interaction.customId === 'channelnamemodal'){
// Nome del canale appena inserito dall'utente con ruolo special
const customChannelName = interaction.fields?.getTextInputValue('specialrolechannelname');
console.log(customChannelName)
return await afterUserChoosePrivateOrPublicChannel(interaction, customChannelName, 'private');
}
maybe I can make something with .startsWith and then put my info at the end and take that
Ya you'll likely have to rework your event handling to allow dynamic customIDs
The simplest one is event-type-ID_HERE and then check a startsWith
exactly
Thank you boys, I owe you a beer
Just make sure you are handling situations where a collector receives the interaction instead of your interactionCreate listener
Isn't like the same thing? Is it that bad? What could go wrong
any chance display components work with role select menus (and if they do how would one do it 🙏)
Yes. You can add any select menu in an action row and put an action row in a container
still uses RoleSelectMenuBuilder?
Yes. You build them exactly like you would with the legacy components
perfect, thank you!
ContainerBuilder#addActionRowComponents() discord.js@14.22.1
Adds action row components to this container.
.addActionRowComponents(
new ActionRowBuilder()
.addComponents(
new RoleSelectMenuBuilder()
.setCustomId("270852ba293841a1ecf5c81f8599bd7f")
.setPlaceholder("Select Staff Roles")
.setMinValues(1)
.setMaxValues(5)
),
)```
doing it like this, i don't think i'm doing it correctly though since i'm getting a invalid form body error
Show the whole error and possibly the whole code
This is directly from the guide
.addActionRowComponents(
actionRow => actionRow
.setComponents(
new UserSelectMenuBuilder()
.setCustomId('exampleSelect')
.setPlaceholder('Select users'),
),
)
Popular Topics: Display Components - Container
read more
Hello, I found an issue with discord-api-types and I hope this is right place for it.
The channel type isn't correctly inferred for the PublicThread & PrivateThread channel types.
The parent_id should be existing in both of these channel types, but instead it has the values null and undefined to it as well.
What is the type of channel?
APIChannel from discord-api-types/v10
Yea, don’t use that for type narrowing
There’s a type that contains a union of all channels
Or I don’t think -types has this
D.js has the Channel type
But this is expected behavior because APIChannel is the base type of all channels, not a union of possible structures of all channel types
APIChannel is a union of all possible channel types. The problem lies within the APIPrivateThreadChannel & APIPublicThreadChannel, they are missing the parent_id property to be set to a Snowflake.
APIAnnouncementThreadChannel falls under this fault as well.
parent_id would prob have to be moved out of APIGuildChannel
precisely
I will submit a pr in a bit, after reading the guidelines of doing so.
i have project to build website called resume builder so any one have done before , that will be help full i want to submit within 1 day
so any help guys!
this channel is a support channel for discord.js v14
which channel should i ask this kind of help
I don’t think you should ask this in here at all, this server is specifically for discord.js (and discord bot development)
so for your issue/question you should join a server related to web development
Isn't it possible to send an ephemeral embed?
Yes it is
How can I do that then?
interaction.followUp({ embeds: [addEmbed], flags: MessageFlags.Ephemeral })
This simply send the embed (non-ephemeral)
Hi all, i am quite new to JavaScript as a language, moving from Golang and Python, im trying to use a Discord UserApp as a starter project to help myself learn and improve. Am i right in saying i need to be setting an InteractionContextType.BotDM and InteractionContextType.PrivateChannel to each of my commands to be able to see and use the commands within dms with another user?
documentation suggestion for @wise plaza:
Developing A User-Installable App - Choosing Supported Installation Contexts
read more
Thank you!
wait that’s the wrong one, my bad
ah lmao
Application Commands - Interaction Contexts
read more
so for DM with another user only the PRIVATE_CHANNEL one is needed
gotcha, thank you so much ill try it out now
Are you doing followUp after using deferReply ?
Yes
It sends the embed in de channel I want it to, simply not ephemeral
just to clarify, this helped massively, thanks so much again!
The defer needs to be ephemeral
yeah you need to tell Discord if the reply will be ephemeral or not, so using the flag on followUp() after deferReply() is basically ignored
members are always fetched? No right?
Not always
always better checking cache first, eventually fetch him
the fetch() method always checks the cache before sending a request to the API, unless you pass in the force: true option
so this is redundant
// Prima controlla se è in cache
const cachedMember = server.members.cache.get(userId);
if (cachedMember) return cachedMember;
// Se non in cache, fetch dal server
const fetchedMember = await server.members.fetch(userId);
return fetchedMember;
yeah, the cache might be outdated ofc
If you need the most up-to-date version of the member pass the force option for fetch
when the user you try to fetch interacts with the bot again the cache gets updated
question: since I need multiple times the guild, should I make something like
client.mainGuild = //fetch guild here
so I use my guild all the time without fetching it everytime
cool idea
all guilds should be cached once the CLIENT_READY event fires if you have the Guilds intent
got it ❤️
how can I check if the bot can send dm's to an user?
In other words if a user has dms closed
I'm not sure you can. Until you send a message. Looking at the docs for DM channel, I don't see anything that would test if a message could be sent successfully
I think you just have to handle the error for the message if it gets rejected
Got it
Another question: is it always better to fetch a guy as user or member? My bot works mainly in dm
then user
I mean, you should call the variable what it actually is
Depending on which one you're fetching
oh yeah if that was the question then I misunderstood
you should fetch the user object and not the guild member object
I am not familiar with Modal collectors, do I have to put the collector right before my modal code, or in my interactionCreate?
you should use interaction.awaitModalSubmit() right below the line of interaction.showModal() if you want to use collectors
BEcause right now I basicalyl handle it without collectors in my interactionCreate like this
if (interaction.isModalSubmit()){
console.log("Inserito il nome");
const customId = interaction.customId;
if (customId.startsWith('channelnamemodal')){
const privateOrPublicChannel = customId.slice(-2); //pu -> public, pr -> private
// Nome del canale appena inserito dall'utente con ruolo special
const customChannelName = interaction.fields?.getTextInputValue('specialrolechannelname');
return await afterUserChoosePrivateOrPublicChannel(interaction, customChannelName, privateOrPublicChannel);
}
}
is it bad practice?
not really, collectors are just temporary event listeners
Should be fine then, love you b3ssel ❤️
But If I basically want to put a timer on the modal I need to use a collector
yes, but since you have an event listener for the interactionCreate event as well, that modal submit interaction would make the listener execute the code inside it too
yeah I would need to use exclusively the collector side code and remove the interactionCode part
yeah
the bot will then ignore the code from the interactionCreate block since none of the if statements inside the if (interaction.isModalSubmit()) block satisfy
If I don't put a timer (so without collectors) it will wait for the modal forever. Is it actually bad for performance reasons?
if you don’t put a timer you shouldn’t use a collector at all but the main interactionCreate event listener instead
Yeah ofc I meant If I use only the interactionCreate and not a collector, is it bad for performance since it will wait forever for the modal input?
just 1 interactionCreate event listener for all incoming interaction events is the best you could do
so performance wise no not an issue, adding new event listeners for the same event is
but as collectors are meant to be temporary its fine to use them, just not without a timer set
Is there a function in DJS so I can make text look like this?
function wrapWithBacktick(text: string): string {
return `\`${text}\``;
}
Just put backticks?
Right I thought there was a function built in, sort of like quote(), blockQuote(), or codeBlock()
Oh I think I found it
Yeah it's called inlineCode..
how is sapphire getting the category of an auditlogevent "channeldelete"
I can't find it in the entry "parent_id"
"entry": {
"action": 12,
"actionType": "Delete",
"changes": [
{
"key": "name",
"old": "testests"
},
{
"key": "type",
"old": 0
},
{
"key": "permission_overwrites",
"old": [
{
"allow": "0",
"deny": "3146752",
"id": "1410388318457430216",
"type": 0
},
{
"allow": "1024",
"deny": "3147840",
"id": "1410388318557962417",
"type": 0
},
{
"allow": "1024",
"deny": "3147840",
"id": "1410388318570549269",
"type": 0
}
]
},
{
"key": "nsfw",
"old": false
},
{
"key": "rate_limit_per_user",
"old": 0
},
{
"key": "flags",
"old": 0
}
],
"createdTimestamp": 1758459417365,
"executor": "1045011641940574208",
"executorId": "1045011641940574208",
"extra": null,
"id": "1419306409090093108",
"reason": null,
"target": {
"flags": 0,
"id": "1419306395911721043",
"name": "testests",
"nsfw": false,
"permission_overwrites": [
{
"allow": "0",
"deny": "3146752",
"id": "1410388318457430216",
"type": 0
},
{
"allow": "1024",
"deny": "3147840",
"id": "1410388318557962417",
"type": 0
},
{
"allow": "1024",
"deny": "3147840",
"id": "1410388318570549269",
"type": 0
}
],
"rate_limit_per_user": 0,
"type": 0
},
"targetId": "1419306395911721043",
"targetType": "Channel"
}```
maybe they saved the category id somewhere else or they use the “channelDelete” event
and idk if im tweaking or if my code is
the category id is indeed not present on an audit log object
aaaaa
let me try the channeldelete event then holdon
well that worked thank u @dense jackal silly me
documentation suggestion for @crisp finch:
inlineCode discord.js@14.22.1
Wraps the content inside backticks, which formats it as inline code.

didnt even know that existed I just put it in `` lmao
When v15 gets released?
Why does it matter? All new features discord releases get added to v14 anyway atm
When does this error trigger?
Error [InteractionCollectorError]: Collector received no interactions before ending with reason: time
When you use awaitMessageComponent() or awaitModalSubmit() with time set but there is no interaction within that time and you don't catch that rejection
❤️
When i try to make a discord container it wants a thumbnail when i try not to add one it crashes
Sections require accessories. If you don't want an accessory, just use a text display instead
Got it that probably what i am doing wrong
guide suggestion for @silent mirage:
Popular Topics: Display Components
read more
Can I have a StringOption in my SlashCommand but that gives predefined options loaded dinamically?
SlashCommandStringOption#choices discord.js@14.22.1
The choices of this option.
Slash Commands: Advanced command creation - Choices
read more
i think this one is better
can I load these choices dinamically from db?
yes I think you can
but I am not too sure if the 3 second respond time applies on here too, someone else has to confirm that
oh wait im mixing stuff up
for dynamic choices you will need to use autocomplete
Slash Commands: Autocomplete
read more
this guide tells you how to implement
this one is for static choices
when I use this commands 'node index.js or nodemon' I get this err message
How do I solve this problem? (I'm in Turkey and Discord is banned in there. I'm connected to Discord with Cloudflarewarp in Linux) mention me
callback: (client, interaction) => {
const targetUserId = interaction.options.get('user').value;
const reason = interaction.options.get('reason')?.value || "No reason provided";
},
name: 'ban',
how do i change ?.value || "No reason provided"; to >
"No reason provided & banned by (user who ran cmd)_";
you can use the interaction.user and whatever properties you want on it to identify the user
um like reason that it shows:
No reason provided and banned by 1377384098196095140
well as i said you can use interaction.user properties and in this case it would be .id
ty
tag suggestion for @rough iris:
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.
permissionFlagsBits.ModerateMembers include which perms
client.on("messageDelete", async (message) => {
if (message.author?.bot || !message.guild) return;
console.log(`[Message Delete] Message deleted in guild ${message.guild.name} (${message.guild.id}) by ${message.author?.tag || "Unknown Author"}`);
});
when i delete a message this does not run at all
no erros nothing is logged like event is not being runned
Any idea why my autocomplete works but my parameter (on my main function) is null?
https://pastebin.com/jmbqfj4P
Sorry but I am losing my mind
was the message sent before the bot turned on, or do you have partials?
no i am deleting a old message
my client
const client = new FrostSentinelClient({
allowedMentions: { parse: ["users", "roles"], repliedUser: true },
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
});
each flag only refers to a single permission, but moderate members is "Timeout Members"
ty
could you be more specific?
which parameter is null?
have you checked your interaction handler to see what value is being passed to your function?
have you logged any values?
channelId is null.
Basically the command is /forcedeletechannel <chooseroom>
that parameter <chooseroom> is a channel name loaded dynamically from a db
the user has to choose a channel name from that dynamically list and the command needs to return that channel id
Damn I got it sheesh
what is "FrostSentinelClient"?
A class of my client
and how do you call super() on it
or well, how does the super() call looks like
assuming it extends Client
export default class FrostSentinelClient extends Client {
public commands: Collection<string, any>;
constructor(options: ClientOptions) {
const defaultIntents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.GuildPresences,
];
super({
...options,
intents: options.intents
? Array.isArray(options.intents)
? [...defaultIntents, ...options.intents]
: [...defaultIntents, options.intents]
: defaultIntents,
});
this.commands = new Collection<string, any>();
}
you'll need to pass the partials to your new then
Popular Topics: Partial Structures
read more
[MessageDelete Event] Triggered
[ERROR] September 21st 2025, 1:49:37 pm [MessageDelete.execute] Failed to fetch partial message: DiscordAPIError[10008]: Unknown Message
null
[INFO] September 21st 2025, 1:49:47 pm - [Heartbeat][frost_testing_bot] Received heartbeat from server
if (message.partial) {
const fetchedMessage = await message.fetch().catch((err) => {
logger.error(
`Failed to fetch partial message: ${err}`,
"MessageDelete.execute"
);
return null;
});
console.log(fetchedMessage);
return;
}
Well, yea, you can't fetch a message that no longer exists
Hmm i am trying to fetch it when i do message delete
And I am saying that you can't
check the warning
Oh so when message deletes i can not get the content deleted
Or the author that deleted it
if the message isn't cached, correct
discord doesn't sent that data, it's gone already
at least for the messageDelete event, that's true regardless of whether the message is cached or not
the only way to get who deleted a message is by getting audit logs
Do I need a discord.js for node.js
though they won't generate for self deletes, and I think deletes from bot's messages
that question doesn't make much sense, if you're just starting in node/javascript development you'll need to learn that first before trying to make a bot, check #resources for some resources to learn
So if i would want all that information i would have to cache and store all messages
"all that" including who deleted it?
Yes who deleted message content
Ok bit weird my sentence does make sense all I want do I need a discord.js gees man
like I said, that data isn't received on the messageDelete event
you'll need to check audit logs for that
so whether you have all messages or not in your cache, that's completely unrelated
Got it thank you so much
still sounds like you have no idea what discord.js or node.js is
you don't get "a discord.js"
again:
if you're just starting in node/javascript development you'll need to learn that first before trying to make a bot, check #resources for some resources to learn
What is the auditlog InviteUpdate useful for if you can't update invites 
why would we know
we didn't add it nor do we emit it on our own
Guys is it possible to make a bot that records me talking in a voice channel?
yes
the bot would need to be in the voice channel obv
Yes ofc which library do I need to take a look at
guide suggestion for @proper remnant:
Getting Started: Introduction
read more
StageInstanceCreate
StageInstanceUpdate
StageInstanceDelete
Does anyone know what these fire for? I literally can not find it i've tried making stage channels, events in a stage channel, googling it online AAAAAAA 
I don't believe those are events on Client. What are you trying to do?
working on adding support for all audit logs
slowly losing it fr
They might be old codes no longer used. I would refer to the Discord documentation
I first had rolecreate and roledelete in auditlog but those catched like half of the roles added for example if a bot joins it makes a default role it wouldn't catch that then I move it to like a client event and boom it works for all roles
aaa alr bet thx
Here's the link for all of the documented types
https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events
🔫
me when channelcreate 
Stage channels used to be more special when Discord made them discoverable. So it's possible they are now just using the channel update type instead of these stage specific ones but I don't know
Alright thx also do u perhaps have a list of like auditlog and guild events for example rolecreate works perfect as a guild event and as an auditlog event it only catches half of the roles 
I cant find any 
or im just really noobing rn (I probably am)
Using the audit log create event is not perfect. Discord will group similar audit logs together and the additional items to the audit log. Don't fire the event
aaaaaaaaaaaaa ill try putting everything in guild then what I can
hi is it somehow possible to fetch/search servers from discord discovery page?
what would be the use case? 🤔
like yk /server search: anime
and shows up search results
I don't believe server Discovery endpoints are made available to applications
ic
well i was just curious, thanks
yeah users can still search that themselves and get a nicer ui a bot can show anyways
https://discord.com/api/v9/discoverable-guilds/search?query=anime&offset=0&limit=12&with_counts=true this is the url used when using server discovery on looking on the network tab on browser
edit: for anyone wondering, its not available using bot auth tokens
hmmm
but surely authorization is thru users token so bot wont be able to fetch that ig
you can always try it out and see what happens
but its not documented at all, so d.js won't support it either -- you have to look on your own
plus since its not documented it can be changed at anytime
yes, it's a mirror of the actual audit log that you can access from server settings
not some magic event of everything that's happening
adding an app to a server only produces a log about adding an app to the server
that process might create a role, but that's not what has been done directly so there is no separate log for that
Thanks for explaining also ive moved most to client events instead of auditlog events except ofc like webhookcreate cuz those arent client events
Can i make questions abt @discordjs/opus here?
ty
are DMchannel and interaction.channel functionally the same?
One is a class, the other is something that has a chance of being an instance of that class
my bot with admin permissions cannot change the server owners nickname, it errors with rawError: { message: 'Missing Permissions', code: 50013 },. Is there something I can do?
- Bots cannot moderate (kick/ban/nickname/...) a target with a higher or equally high highest role or the guild owner.
- Bots cannot modify (edit/add/remove) roles that are higher or equally high compared to the bot's highest role.
- The
Administratorpermission does not skip these checks.
hi there, bit of a newbie - but I noticed this PR (https://github.com/discordjs/discord.js/pull/11096) how would I go about using UserSelectMenuBuilder in a Modal (if this is currently possible).
When I use this inside a ModalBuilder:
new ActionRowBuilder().addComponents(
new UserSelectMenuBuilder()
.setCustomId('team_members')
.setPlaceholder("Select up to 8 team members")
.setMinValues(1)
.setMaxValues(8)
),
I get:
DiscordAPIError[50035]: Invalid Form Body
data.components[1].components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (4,).
this is not possible yet
that’s why there’s a PR
and when they do come out would would need to use a LabelBuilder not a ActionRowBuilder
since the PR has been merged, when could I expect it to be available publicly?
watch #announcements for updates. It will be when a release happens
alright, tysm!
im trying to edit roles by doing await interaction.guild.roles.edit(role.role_id, { name: role.role_name, primaryColor: role.role_color })
everyting works as it should, except color. I provide a hexadecimal value for it in a string, ie. #e91e63 and it doesnt change. The request goes through with no errors regarding color and everything else changes as it should
documentation suggestion for @balmy kraken:
RoleEditOptions#colors discord.js@14.22.1
The colors of the role
The option is colors which takes an object
oh right
so dynamic slash command options via autocomplete actually work better than I thought… funny how the docs make it seem so rigid. curious if anyone has done a fully DB-driven autocomplete yet?
that's not really feasible unless you really optimize your db and connection
given you only have 3s to reply
I'm not sure how the docs make it seem rigid though
Ive done it pretty easily with a local db, though its definitely more efficient to use caching
whats the error in this?
where the warning was created)
Dank Syndicate Grinders#0636 is online on discordapp.
There was an error running this command: DiscordAPIError[10062]: Unknown interaction
There was an error running this command: DiscordAPIError[10062]: Unknown interaction
ANy ide awhy I get this error Value of field "type" must be one of (1,).?
its expecting an action row but you didn't provide one
tag suggestion for @chrome widget:
Common causes of DiscordAPIError[10062]: Unknown interaction:
- Initial response took more than 3 seconds ➞ defer the response *.
- Wrong interaction object inside a collector.
- Two processes handling the same command (the first consumes the interaction, so it won't be valid for the other instance)
* Note: you cannot defer modal or autocomplete value responses
I mean I just need a textDisplayComponent like this
const startRow = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('delete_confirm')
.setLabel('🚀 Avvio Eliminazione')
.setStyle(ButtonStyle.Primary)
.setDisabled(true)
);
what?
please elaborate 
Ye I meant like this wtf I've wrote an ActionRowBuilder
const mainContainer = new ContainerBuilder()
.setAccentColor(0x0099FF)
.addTextDisplayComponents(
textDisplay => textDisplay
.setContent('Procedi con la __creazione__ della tua stanza personalizzata!\n**Scegli** se renderla `privata` o `pubblica`!'),
)
MessageFlags#IsComponentsV2 discord.js@14.22.1
Allows you to create fully component-driven messages
You need to provide the IsComponentsV2 message flag if you want to send ComponentsV2
yeppa
Surprisingly, yes
Guild#edit() discord.js@14.22.1
Updates the guild with new information - e.g. a new name.
// Set the guild name
guild.edit({
name: 'Discord Guild',
})
.then(updated => console.log(`New guild name ${updated}`))
.catch(console.error);
You can provide features with an edited array of features excluding "COMMUNITY"
Hi! Still there is startMessage object present in the therad creation event or deprecated?
documentation suggestion for @halcyon vault:
ThreadChannel#fetchStarterMessage() discord.js@14.22.1
Fetches the message that started this thread, if any. The Promise will reject if the original message in a forum post is deleted or when the original message in the parent channel is deleted. If you just need the id of that message, use id instead.
this is what you should use, I'm not aware of a startMessage property
Does anyone know about MT4 and MT5?
What does that have to do with discord.js?
Is there any initial message can be sent on the thread chanel in the text channel as parent channel?
like initial post in the forum channel.
GuildTextThreadCreateOptions#startMessage discord.js@14.22.1
The message to start a thread from. If this is defined, then the type of thread gets inferred automatically and cannot be changed.
that?
or do you mean creating the thread directly with a new custom message
No, just discovered that startMessag object is the message in whihc thread should be started, like i do here in my message.
Yah, we do in th forum posts know. The same i asks.
Then no.
The first message in the thread will be the starter message
there is no such option in text channel?
correct
you mean startMessage?
Just a quick question, can we use select menu inside a modal?
Its not yet supported in discord.js
Thanks for the reply! That saves me a lot of minutes/hours trying to find out XD
When adding localization. If a localization is not supported in say a command description. it defaults to the value set in #setDescription() or am I confusing it.
Hi! Are the new modal components available in Discord JS v14?
that sounds accurate
permissionOverwrites.push({
id: staffRoleId,
allow: [
'ViewChannel',
'Connect',
'Speak',
'ManageRoles',
'MuteMembers',
'DeafenMembers',
'MoveMembers'
]
});
To disconnect a guy from the vocal chat the permission is Disconnect?
No, that is included in MoveMembers.
but like why
Because Discord decided that way?
I am going to make a guess the action is the same as moving a member to a different channel. think of it like a move from channel ➡️ null
are channels alwasy cached?
Yeah ofc just like would be handy to separate the two
@sturdy ravine
tyty
Guys is it necessary to try catch every single command or I can only try catch at interactionCreate when I get the interaction?
I also have db connections and stuff in my commands
You have to catch errors and promise rejections
You mean every single command? And what do you mean promise rejections?
I legit have no idea on how to prevent and Handle errores
Promise can either resolve or reject
Everything you do with discord returns a Promise
Like sending a message, returns Promise<Message>, but that can reject if you for example send too much text, or don't have permission to send in that channel
I do use async await
Yes, that's how you handle Promises
They can still reject though
How are interactions sent to a user-installed app handled in the context of sharding? As in, how is the shard that will handle those requests selected?
ddevs would be a better place to ask given it's an api question, not a djs one
for both modal main title an each field title, the chars limit is 45?
yup
Guys, when the builders@v2 coming out?
why?
that will be supported in v1 though
if it isn't already, I think the change was merged already
just not released
well, I saw pull requests for those categorized within builders v2 milestone
changes are usually made to main first and then backported to the current major
besides, you can't use builders v2 in djs v14
since it's a new major it's a breaking change, it isn't compatible
you'll only be able to use it when v15 releases
That's so. Alright.
at most you could use it but you'd need to build first and then pass it to djs
can't pass the builder
is it possible to use custom emojis in buttons
yes
Yes
YAY
Is there any way to make this text tinier?
-# is the smallest text you can post
-# is the smallest text you can post
Oh, ok thanks
hi! so whats the main difference between
ApplicationCommandOpionType.Mentionable
&
ApplicationCommandOptionType.User
Mentionable includes channels and roles
hmm ty
hey quick question: if I just use someTextChannel.messages.fetch({limit: 10}); does this fetch the last 10 messages sent, or 10 at random?
nvm I figured it out, it returns the last 10 sent
how can I get all users who authenticated with oauth? is that possible?
I'm trying to make them join to my guild, do I have to store something else before that?
this is unrelated to djs since djs doesn't support oauth, but
afaik you'd need to track who authenticates yourself and you'll need the guilds.join scope
out of curiousity: why doesn't d.js support oauth?
ok as I started typing I realized there's quite a few reasons to list out
tldr: the bot api and oauth are separate parts of the api, djs just handles bots
For those that manage large bot applications, what does your memory graph look like? Mine looks like this for 1d and it's just steadily creeping up. Curious if other d.js users see a similar thing (cache growth) or it's something specific to my app?
that’s quite understandable, thanks for telling!
that's relatively normal, as djs continuously caches data received from events over time
you can limit this with limited caches and sweepers
the actual memory used varies depending on intents/cache customization
guide suggestion for @ivory wasp:
Miscellaneous: Cache customization
read more
I suspected it was the cache growing over time. Hadn't seen this part of the docs, thanks!
Will it still take long to add the select menu to the modal? It's been 12 days and I really want to use it.
There is never ETAs. It'll be out when it's ready
How can I set the content of this TextDisplayComponent after being instantiated?
const componentText = new ContainerBuilder()
.setAccentColor(0xFF0000)
.addTextDisplayComponents(t =>
t.setContent(`🚫 **AVVISO STAFF | Canale vocale ${channel.name} e' stato eliminato**`)
)
like componentText.setContent("...)?
You can either replace the JSON by using container.components[index] or you could use container.spliceComponents() to replace the TextDisplay
are you building from a message or what is your use case?
async function createComponent(interaction, content) {
const temp = new ContainerBuilder()
.setAccentColor(0xFF0000)
.addTextDisplayComponents(t =>
t.setContent(content)
);
// Crea un ActionRow e aggiungi il ContainerBuilder al suo interno
const row = new ActionRowBuilder()
.addComponents(temp);
return await interaction.editReply({
components: [row], // Invia l'ActionRow, non il ContainerBuilder
flags: MessageFlags.Ephemeral || MessageFlags.IsComponentsV2
});
}
DiscordAPIError[50035]: Invalid Form Body components[0].components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (2, 3, 5, 6, 7, 8)
I am losing my mind