#djs-help-v14
78874 messages · Page 2 of 79
the docs isn't updated yet, they forgot to update those pages (I already made a PR for it but its not reviewed yet)
can you send the link
Hello! I want to get the user's response from a Modal. Their answers from TextInputBuilder.
Tho, I am unsure how to retrieve that. Could anyone help me?
handleAllApplicationTypes.js:
const modal = new ModalBuilder()
.setTitle("Staff Applications")
.setCustomId("staffApplicationsModal");
const actionRows = [];
for (let i = 0; i < applicationGuildData.staffQuestions.length && i < 5; i++) {
const question = applicationGuildData.staffQuestions[i];
const input = new TextInputBuilder()
.setCustomId(question.customId || `question_${i}`)
.setLabel(question.label?.slice(0, 45) || `Question ${i + 1}`)
.setStyle(TextInputStyle.Paragraph)
.setPlaceholder(question.label?.slice(0, 45) || `Question ${i + 1}`)
.setRequired(true);
const actionRow = new ActionRowBuilder().addComponents(input);
actionRows.push(actionRow);
}
modal.addComponents(...actionRows);
return await interaction.showModal(modal);
This is where i want to get their answers:
const {
ChannelType,
EmbedBuilder,
ChatInputCommandInteraction,
Client,
MessageFlags,
ModalBuilder,
TextInputBuilder,
TextInputStyle,
ActionRowBuilder
} = require("discord.js");
const applicationGuildSchema = require("../schemas/applicationGuildData");
const applicationSchema = require("../schemas/applicationData");
const getEmbedColorForGuild = require("../functions/getEmbedColorForGuild");
module.exports = {
customId: "staffApplicationsModal",
userPermissions: [],
botPermissions: [],
/**
* @param {Client} client
* @param {ChatInputCommandInteraction} interaction
*/
run: async (client, interaction) => {
const applicationGuildData = await applicationGuildSchema.findOne({ guildId });
if (!applicationGuildData) {
const embed = new EmbedBuilder()
.setDescription("No guild data found. Report this to an admin.")
.setColor(embedColor);
return await interaction.reply({
embeds: [embed],
flags: MessageFlags.Ephemeral
});
}
// ...
}
};
const { SlashCommandBuilder, ContainerBuilder, TextDisplayBuilder, SeparatorBuilder, SeparatorSpacingSize, MessageFlags, FileBuilder, AttachmentBuilder, ButtonBuilder, ButtonStyle, ActionRowBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('test')
.setDescription('random test cmd'),
async execute(interaction) {
const attachment = new AttachmentBuilder('./src/roblox/Quiz-Center.rbxl', { name: 'Quiz-Center.rbxl' });
const youtubeButton = new ButtonBuilder()
.setLabel('YouTube')
.setStyle(ButtonStyle.Link)
.setURL('https://youtube.com');
const row = new ActionRowBuilder().addComponents(youtubeButton)
const container = new ContainerBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder({
content: `hello.`
})
)
.addSeparatorComponents(
new SeparatorBuilder({
spacing: SeparatorSpacingSize.Large
})
)
.addTextDisplayComponents(
new TextDisplayBuilder({
content: `goodbye.`
})
)
.addFileComponents(
new FileBuilder({
file: {
url: `attachment://${attachment.name}`,
},
})
)
.addActionRowComponents(row);
interaction.reply({
flags: MessageFlags.IsComponentsV2,
components: [container],
files: [attachment]
});
}
}```
i figured out how to use these can u give me an example on how the section will look like if i have to use that?
guide suggestion for @somber berry:
Other Interactions: Modals - Extracting data from modal submissions
read more
No, it can only be added on the first editReply after a deferReply
Once there is content of any way you can’t change the componentsV2 flag
you want me to show you how the components in your code will look in discord?
why not just run your code and see?
no no just give me an example how ".addSectionComponents()" should be used cuz i cant figure it out thats all
Thanks @halcyon bison got it to work.
I just did the following:
const questions = [];
for (let i = 0; i < 5; i++) {
const questionResponse = interaction.fields.getTextInputValue(`question_${i}`);
if (questionResponse) {
questions.push({
customId: `question_${i}`,
label: questionResponse
});
}
}
testing it with /core, b3ssel was actually correct
you can edit messages normally and upgrade it to components v2, even if there is content in the message
though of course I would still wait to see reviews on their pr
so what about deferring with the flag?
it should be possible to use the MessageFlags.IsComponentsV2 when editing the reply after defer, but seems like they made a mistake in d.js
I mean you just pass a new SectionBuilder() much like you're doing with each of the other "addXComponents" methods you're calling
if you're encountering issues, care to share your code?
Huh, yeah, thanks for bringing that up
ohhh thanks
how to use ThumbnailBuilder?
thx
i did it like this
.addSectionComponents(
new SectionBuilder({
components: [
new TextDisplayBuilder({
content: "check the file next to this text!"
}),
new FileBuilder({
file: {
url: `attachment://${attachment.name}`,
},
})
],
type: ComponentType.Section
})
)```
clearly doing smth wrong here
I think first, do you actually want to use the builders, or do you just want to do raw objects?
builders
then you should use the builders' methods rather than passing the data to the constructor
this applies to all of the builders you're using
if you just wanted to use the objects you're passing to each constructor, you could just skip the builder all together
Hi all, if I want to apply a tag to a thread via my bot, how can I do this? Would I need to save the tag in my database? (the tags get created by the bot).
you can access a forum's tags from <ForumChannel>.availableTags
then, either when creating the thread with the appliedTags option or after the fact with <ThreadChannel>.setAppliedTags(), you can use <GuildForumTag>.id
so would I need to save the ID? also, can you get a tag by its name?
you don't need to save the id since you can always access it from <ForumChannel>.availableTags
and it's an array that you can use <Array>.find() on and check <GuildForumTag>.name
you can save it if you want to
has anybody already done this new message embed 'builder' to play around? 😄
I think I was able to erase the background of the embedded background when I wrote the component V2.
What should I do?
Thanks, also, do you know what the "moderated" field is used for?
components v2 and yes, it‘s the main topic of most users here atm
alr did that it made it all simpler now lol thanks
got a link?
documentation suggestion for @somber berry:
GuildForumTag#moderated discord.js@14.18.0
Whether this tag can only be added to or removed from threads by a member with the ManageThreads permission
Announcement channel
no I meant if somebody already made a website in which through UI one can already 'play' around with how this new feature would appear
that depends on what you want
are you asking how to erase the embed-style background?
or are you asking how to add it back?
probably not due to how recent they are, but that sounds more like a question for google
I wonder how to erase the embedded.
you can just use the components inside your container outside of a container
is there a djs guide to using components?
https://discord.builders/ (idk if this counts as promoting, but otherwise remove my message)
Hello, what do i need to add to send the V2 components? when i try to add the flag it gives me an type error.
With the current code i get this error:
iscordAPIError[50035]: Invalid Form Body
components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
not a d.js guide, but on the official discord docs there is somewhat of a guide (not a really good one tho)
you do need the flag, but the type error is an issue on our end
will be fixed eventually ™️
Ah, so just ts expect error for now on that flag?
withComponents: true -- does that work? I thought only way of adding the components v2 flag is by using flags: MessageFlags.IsComponentsV2
I mean, idk what it does but you need the flag anyways apparently
but it exists
yeah well maybe you're referring to the ?with_components=true query param
seems like it
but I think its not needed when using interaction#editReply(), flags: MessageFlags.IsComponentsV2 is
does the new componentv2 work with webhook
What's the difference between media gallery and file component?
Is media gallery the one where it shows images together in 2x2?
if you specify withComponents: true, yes
Is media gallery the one where it shows images together in 2x2?
this is correct
furthermore if you take note of the example in #announcements message, the file component accepts non-images as well, being much closer to an attachment container
const Container = new ContainerBuilder()
Container.addTextDisplayComponents(
new TextDisplayBuilder().setContent([
`# ${Client.Methods.Emojis.Red} [Roblox Release]・Windows ${Client.Methods.Emojis.Windows}`,
`## <t:${Math.floor(Date.now() / 1000)}:F>`,
].join('\n'))
)
Container.addSectionComponents(
new SectionBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder().setContent([
`- All Windows-based cheats have been neutralized.`
].join('\n'))
)
)
Container.addSeparatorComponents(separator => separator.setSpacing(SeparatorSpacingSize.Small))
Container.addSectionComponents(
new SectionBuilder()
.addTextDisplayComponents(
new TextDisplayBuilder().setContent(`\`\`\`version-a9a5d0b275a34ffb\`\`\``)
)
.setButtonAccessory(
new ButtonBuilder()
.setLabel('Install')
.setStyle(ButtonStyle.Link)
.setURL('https://rdd.latte.to/?channel=LIVE&binaryType=WindowsPlayer&version=version-a9a5d0b275a34ffb')
)
);
await Interaction.reply({ components: [Container], flags: MessageFlags.IsComponentsV2 })
any1 know why?
your first section doesn't have an accessory
if you didn't want to add an accessory, but rather just a text display, you'll want to skip the section all together (like you're doing with your first text display)
ah thanks
why does this not work?
const container = new ContainerBuilder()
.addMediaGalleryComponents(
new MediaGalleryBuilder()
.addItems(
new MediaGalleryItemBuilder()
.setURL('attachment://error.png')
)
)```
it gives Error sending webhook message: HTTPError: Internal Server Error
```js
await webhook.send({
components: [container],
flags: MessageFlags.IsComponentsV2,
files: [attachment],
});```
that sounds like an issue on their end
can ThumbnailBuilder accept an image attachment?
does the containers not work with webhooks?
are buttons the only supported accessory? or can i put menus
oh actually you are missing withComponents: true
it'd be a little funny if that's the reason they're encountering an internal server error
LOL it was that
using the attachment:// protocol, yes
there's also thumbnails, but those are the only two
which is to say, you cannot put a select menu
how did this guy do it though
that's not an accessory, it's just in an action row in the container
whats the max amount of cction rows i can put
https://discord.com/developers/docs/components/reference#container
this lists 10 as the limit of components (not just action rows)
Cant figure out where error came from
const container = new ContainerBuilder()
.setAccentColor(hex2rgb(member.displayHexColor))
.addSectionComponents([
new SectionBuilder()
.addTextDisplayComponents(new TextDisplayBuilder().setContent([
`test`,
`test`
].join("\n")))
])
return interaction.reply({ components: [container], flags })
Error: Received one or more errors
expected = class extends
given = undefined
validator = 's.instance(V)'
in future, please share the whole error
but in this case, section components require accessories
if you just wanted the text display without adding a button/thumbnail, use that directly and skip the section
got you, thanks
hi guys, do you know which URL is the latest one for adding a user to a guild having their access token after completing the OAuth2 flow?
i found a v8 api url but is v8 the latest one?
not d.js related, but https://discord.com/developers/docs/reference#api-versioning-api-versions
thank you!!!
could ask in #1081585952654360687 next time or in discord.gg/discord-developers
i posted here because i read You can use djs-help-v14 for questions you expect can be quickly solved.
Yes, about d.js
Your question does not involve d.js at all
you're right, i'll ask in the discord developers server next time
How to set thumbnail in new components
thumbnailbuilder
quick q. how are components structured? obviously embeds have author, title, description, images, footer, etc. but what about components? where is this documented in djs?
guide has yet to be made, for now you can look at the official discord docs and the d.js docs
fe4c22b7] Error in stats: CombinedError (2)
Received one or more errors
1 ExpectedValidationError > s.instance(V)
| Expected
|
| Expected:
| | [Function: ButtonBuilder]
|
| Received:
| | undefined
2 ExpectedValidationError > s.instance(V)
| Expected
|
| Expected:
| | [Function: ThumbnailBuilder]
|
| Received:
| | undefined
at _UnionValidator.handle (/workspaces/Zyren_V2/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1965:23)
at _UnionValidator.parse (/workspaces/Zyren_V2/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:90)
at SectionBuilder.toJSON (/workspaces/Zyren_V2/node_modules/@discordjs/builders/dist/index.js:2170:37)
at /workspaces/Zyren_V2/node_modules/@discordjs/builders/dist/index.js:1871:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (/workspaces/Zyren_V2/node_modules/@discordjs/builders/dist/index.js:1871:35)
at /workspaces/Zyren_V2/node_modules/discord.js/src/structures/MessagePayload.js:151:46
at Array.map (<anonymous>)
at MessagePayload.resolveBody (/workspaces/Zyren_V2/node_modules/discord.js/src/structures/MessagePayload.js:150:49)
at GuildMessageManager.edit (/workspaces/Zyren_V2/node_modules/discord.js/src/managers/MessageManager.js:186:8)
Why won't this work for instance
import { readFile } from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import {
AttachmentBuilder,
ButtonBuilder,
ButtonStyle,
ContainerBuilder,
FileBuilder,
MessageFlags,
SectionBuilder,
SeparatorSpacingSize,
TextDisplayBuilder, WebhookClient,
} from 'discord.js';
const self = await readFile(fileURLToPath(import.meta.url), 'utf8');
const container = new ContainerBuilder();
const text = new TextDisplayBuilder().setContent("Hello, this is the text display builder!")
container.addTextDisplayComponents(text)
const webhook = new WebhookClient({ url: 'webhook_url_here' });
await webhook.send({
components: [container],
withComponents: true,
});
Section needs to contain either thumbnail or button, yours doesn't. It only contains text component
missing IsComponentsV2 flag
this worked for me
const thumbnail = new ThumbnailBuilder().setURL(url)
const container = new ContainerBuilder()
.addSectionComponents(
new SectionBuilder()
.setThumbnailAccessory(thumbnail)
.addTextDisplayComponents(
new TextDisplayBuilder({content: `Text`})
)
)
)
where does that flag go exactly
how do I add color to the embed in components v2 again 
To the flags option
flags: MessageFlags.IsComponentsV2
now i get a "Cannot send an empty message" error
ContainerBuilder#setAccentColor
show full error
alright let me try it
What does your code looks like now?
import { readFile } from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import {
AttachmentBuilder,
ButtonBuilder,
ButtonStyle,
ContainerBuilder,
FileBuilder,
MessageFlags,
SectionBuilder,
SeparatorSpacingSize,
TextDisplayBuilder, WebhookClient,
} from 'discord.js';
const self = await readFile(fileURLToPath(import.meta.url), 'utf8');
const container = new ContainerBuilder();
const text = new TextDisplayBuilder().setContent("Hello, this is the text display builder!")
container.addTextDisplayComponents(text)
const webhook = new WebhookClient({ url: 'url' });
await webhook.send({
components: [container],
flags: MessageFlags.IsComponentsV2
});
You removed the withComponents option
oh
yeah it works now
ty
Idk why the new TextDisplay does not work I have updated to the news discord.js also
works ty
It looks to me that it worked, what did you expect?
is there going to be a page on the djs guide for new components or should i go off the docs only
Currently docs only.
I want it to look like this
That's inside a container. Yours is just plain text component
how would I do it then?
The message you sent has a file with the code used to send that message. You can look at it to know how it works for now
v10: APIContainerComponent
read more
If you want to use json, then you can follow this docs
Is there a way to get a message with a .then attached? I can't seem to get it to work
return it from the .then() callback
currently you return the result of console.log, which is void
how to set buttons in the bottom
put them in an actionrow like before
i mean in that new Embed type component 💀
I'm unsure how to do this 😅
like this
You put it where you want in the order you want. That's the whole point of components v2
#discord-dev-news
do I need to specify the componentv2 flag when sending to webhook
Yes. If it contains v2 components
with the withComponents thingy?
It's for non-bot owned webhooks, so that you can still use non-interactive components
ah
so only the flag is needed if my bot owns the webhook im tryna send to
Yes
its weird tho that for webhooks you need both withComponents: true AND the flags: MessageFlags.IsComponentsV2 flag
or did withComponents: true exist before components v2 when sending a webhook message through your bots webhook
for link buttons yes
This was the case before v2 components. For link buttons
ah alr
erm its an mts file?? thats not source code
Yea it is
Is this valid to create a discord client instance like that?
intents: new IntentsBitField(32767)
I basically want all the intents
its literally an audio file
tag suggestion for @unborn ridge:
We highly recommend only specifying the intents you actually need.
- Note, that
98303,32767or whatever other magic number you read that represents "all intents", gets outdated as soon as new intents are introduced. - The number will always represent the same set of intents, and will not include new ones. There is no magic "all intents" bit.
Blame your OS for believing so. It‘s typescript
lol if I open with cursor I get code nvm chat
yeah my bad sorry qjuh
But I'm going to need all the intents.. so I should just put all of the intents in array?
No you dont
Only use the ones you need
Intents increase memory usage
how to add multiple buttons in a section ?
Yeah but the problem is that I don't get any error if I forgot to use an intent for example "Direct Message", if I try to send a DM message it will just not work, with no error
You can’t. Multiple buttons next to each other go in an ActionRow. Only one can be next to a section as accessory
That’s wrong. Intents are for what you receive events for, not what your bot sends
And you should know what events you need and add intents when you need them
need like this
That’s an ActionRow
oh how can i add that to the container ?
Then I will try to track a dm message that my bot got and I won't understand why the event won't work.
Does is throw an error or a warning? Please add GatewayIntentBits.DirectMessages intent?
thanks
No. Because at that point you start to listen to an event. So you add the intent
Else your bot gets spammed with lots of data from discord it doesn’t need
Putting unnecessary strain on your connection, host and discord’s servers
How would I achieve this? I've tried a few things, but can't seem to get it work
return reply;
Ah, that was deceptively simple. Much appreciated!
https://sourceb.in/NvCZXfyOkH
Help me with this
[d554aba1] Error in stats: CombinedError (2)
Received one or more errors
1 ExpectedValidationError > s.instance(V)
| Expected
|
| Expected:
| | [Function: ButtonBuilder]
|
| Received:
| | undefined
2 ExpectedValidationError > s.instance(V)
| Expected
|
| Expected:
| | [Function: ThumbnailBuilder]
|
| Received:
| | undefined
at _UnionValidator.handle (/workspaces/Zyren_V2/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1965:23)
at _UnionValidator.parse (/workspaces/Zyren_V2/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:90)
at SectionBuilder.toJSON (/workspaces/Zyren_V2/node_modules/@discordjs/builders/dist/index.js:2170:37)
at /workspaces/Zyren_V2/node_modules/@discordjs/builders/dist/index.js:1871:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (/workspaces/Zyren_V2/node_modules/@discordjs/builders/dist/index.js:1871:35)
at /workspaces/Zyren_V2/node_modules/discord.js/src/structures/MessagePayload.js:151:46
at Array.map (<anonymous>)
at MessagePayload.resolveBody (/workspaces/Zyren_V2/node_modules/discord.js/src/structures/MessagePayload.js:150:49)
at GuildMessageManager.edit (/workspaces/Zyren_V2/node_modules/discord.js/src/managers/MessageManager.js:186:8)
How do I make messages ephemeral with flags on deferReply?
Same way you would do it for any other way of responding to the interaction
.
Patience?
ok
interaction.deferReply({flags:MessageFlags.Ephemeral})
is ContainerBuilder not being exported from @discordjs/builders normal? MediaGalleryBuilder, SectionBuilder and etc is being exported, just ContainerBuilder is not being exported (i am using it in a cf worker, so i can't use the main discord.js package or it throws errors due to node builtin packages missing)
For FileBuilder in setURL(), how would i go about using a buffer?
Files in embeds should be attached via the message option object and referenced in the embed:
const attachment = new AttachmentBuilder('./image.png', { name: 'image1.png' });
const embed = new EmbedBuilder()
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);
channel.send({
embeds: [embed],
files: [attachment]
});
same approach
but we're using components so
same approach
right
Wait question, a file can be a single image to display right or does that also need to be inside media gallery
how do i add thumbnail to components v2 
Thumbnail can only be added as an accessory to section component
const image = new AttachmentBuilder('./hive_leaderboard.png', { name: 'lb.png' })
const container = new ContainerBuilder()
container.addFileComponents(
new FileBuilder().setURL(`attachment://${image.name}`)
)
await channel.send({
components: [container],
files: [image],
flags: MessageFlags.IsComponentsV2,
})
```Is this not meant to render the image?
Is it intended that soundboard sounds are only cached after being fetched even though they are sent with the guild create event?
are you trying to render an image?
if so, i would use a MediaGalleryComponent
here's a little snippet code
const image = new MediaGalleryItemBuilder()
.setURL("https://purepng.com/public/uploads/large/purepng.com-sliced-wheat-breadfood-wheat-bread-wholemeal-bread-bread-sliced-bread-941524637683ilg8q.png") // this is an image of a bread
.setDescription("bread")
const mediaGallery = new MediaGalleryBuilder()
.setId(1)
.addItems([
image
])
const container = new ContainerBuilder()
// rest of your container thingies
.addMediaGalleryComponents([
mediaGallery
])
then you just send the container like you did with channel.send
Yeah, figured so
oh, my bad
No noo thank you very much, I thought i could use file builder for simgle image but i assumed its media gallery
ty for snippet, helps a ton bro 💙
you're welcome 👍
I assume the setId is used for ordering the sections is that right?
honestly, i don't know
maybe it is, but the thing that the documentation says is not very helpful
give me a second
yeah honestly idk what it does
Form the Discord docs it is an Optional identifier for component and no fixed uses
https://discord.com/developers/docs/components/reference#anatomy-of-a-component
mb i read the wrong thing
np, makes sense to use if your are looking to update one component in a container
Anybody knows why it throws this error below in console when trying to delete/edit a soundboard sound? The docs display a valid method for directly deleting/editing a SoundboardSound and VSC also recognizes it as valid method, but it doesn't seem to work when executing?
[ERROR] TypeError: sound.delete(...).then is not a function
Where's sounds coming from?
It's an array of provided sounds which should return valid SoundboardSound objects
<Guild>.soundboardSounds.fetch() returns a Collection, not an array
discord.js uses Collection, an extension of the JS native Map structure.
- Guide: learn more 🍪
oh now I see, it's supposed to fetch a single sound not all, sorry mb 😅 Thanks for helping
It'll fetch all if you don't specify an id, or the soundboard sound with that id if you do
Yeah, I forgot to provide str inside fetch()
can't i use that as like that?
mainContainer.addActionRowComponents(<StringSelectMenuBuilder()>);
any help ?
I've tried this with .setURL() but having some troubles with the image itself. Can you not use this with attachment://test.png for instance?
can you give more context in hat you want to do with your code
hey everyone,
i'm currently experiencing with components v2 and i'm having a little trouble experimenting with Sections
this is the code:
const section = new SectionBuilder()
.addTextDisplayComponents([
textDisplay
])
.setId(1)
const container = new ContainerBuilder()
/*.addTextDisplayComponents([
textDisplay
])*/
.addSectionComponents([
section
])
.setAccentColor(Colors.Red)
interaction.reply({
components: [container],
flags: [
MessageFlags.IsComponentsV2,
MessageFlags.Ephemeral
]
})
and this is the error i get: https://pastebin.com/zSQ9Qqwa
const attachment = new AttachmentBuilder('./lb.png', { name: 'lb.png' })
const image = new MediaGalleryItemBuilder()
.setURL(`attachment://${attachment.name}`)
const mediaGallery = new MediaGalleryBuilder()
.setId(1)
.addItems([
image
])
const container = new ContainerBuilder()
.addMediaGalleryComponents([
mediaGallery
])
await channel.send({
components: [container],
flags: MessageFlags.IsComponentsV2,
})
```This is what i have
i don't think so
the url in the method has to be a string
Hmm. How would I go about adding an image then?
But it is a string. That’s fine
components[0].components[0].items[0].media.url[UNFURLED_MEDIA_ITEM_REFERENCED_ATTACHMENT_NOT_FOUND]: The referenced attachment ("attachment://lb.png") was not found
that's what I get
oh, well i'm not experienced
You need to actually attach the attachment to the message though. Pass it in files:
that's the code of my stats command
and the error is given below
I had it before and got an error so i removed it, now i added it back and no error
programming at its finest 😔 where did that error go
why is the file in the announcement a video file? is it on docs instead?
It isn’t. Your OS just doesn’t know ts files are typescript
Which is funny in itself considering said OS and coding language are made by the same company
yea
The Micro----
o
Small And Soft
I think this is part of your issue. you are not using ActionRowBuilder<ButtonBuilder> when adding the buttons. your are trying to add the buttons directly
const createContainer = (activeTab) => {
return new ContainerBuilder()
.addSectionComponents(embeds[activeTab])
.addSeparatorComponents(separator => separator.setSpacing(SeparatorSpacingSize.Large))
.addActionRowComponents(
new ButtonBuilder()
.setCustomId('general')
.setLabel('General')
.setStyle(activeTab === 'general' ? ButtonStyle.Primary : ButtonStyle.Secondary)
.setDisabled(activeTab === 'general'),
new ButtonBuilder()
.setCustomId('system')
.setLabel('System')
.setStyle(activeTab === 'system' ? ButtonStyle.Primary : ButtonStyle.Secondary)
.setDisabled(activeTab === 'system'),
new ButtonBuilder()
.setCustomId('team')
.setLabel('Team')
.setStyle(activeTab === 'team' ? ButtonStyle.Primary : ButtonStyle.Secondary)
.setDisabled(activeTab === 'team')
);
};
oh thanks i will try
How can I trace what is causing the “Socket Error” problem?
to add some calcification
you are doing this
new ContainerBuilder().addActionRowComponents(new ButtonBuilder())
when you need this
new ContainerBuilder().addActionRowComponents(new ActionRowBuilder<ButtonBuilder>().addComponents(new ButtonBuilder()))
You have a misconception about what a section is
A section needs an accessory next to it. If you don‘t want one you don’t need a section and can put the textdisplay(s) directly instead
a network issue most likely
[474a714b] Error in stats: CombinedError (2)
Received one or more errors
1 ExpectedValidationError > s.instance(V)
| Expected
|
| Expected:
| | [Function: ButtonBuilder]
|
| Received:
| | undefined
2 ExpectedValidationError > s.instance(V)
| Expected
|
| Expected:
| | [Function: ThumbnailBuilder]
|
| Received:
| | undefined
at _UnionValidator.handle (/workspaces/Zyren_V2/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1965:23)
at _UnionValidator.parse (/workspaces/Zyren_V2/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:90)
at SectionBuilder.toJSON (/workspaces/Zyren_V2/node_modules/@discordjs/builders/dist/index.js:2170:37)
at /workspaces/Zyren_V2/node_modules/@discordjs/builders/dist/index.js:1871:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (/workspaces/Zyren_V2/node_modules/@discordjs/builders/dist/index.js:1871:35)
at /workspaces/Zyren_V2/node_modules/discord.js/src/structures/MessagePayload.js:151:46
at Array.map (<anonymous>)
at MessagePayload.resolveBody (/workspaces/Zyren_V2/node_modules/discord.js/src/structures/MessagePayload.js:150:49)
at GuildMessageManager.edit (/workspaces/Zyren_V2/node_modules/discord.js/src/managers/MessageManager.js:186:8)
👆
You don‘t add any accessory to your sections you create
oh ok
What value does Container.setAccentColor() take? It says number but what does that mean
the hex value of the color
RGB Color code
only rgb?
yes
I tried hex but that doesn't work, tried like Blue but that fails too
0xff0066 for example
Those are strings, not numbers
oh hex value
resolveColor discord.js@14.18.0
Resolves a ColorResolvable into a color number.
perfect, ty
Can also use that for convenience
yo btw i've heard a little bit about deno and bun
what are those?
different software, not djs related
Other runtimes than NodeJS. Can’t really recommend them for discord.js if you don’t have a good reason
oh ok
thanks
my bad man i didn't know
dw lol
thanks its working btw how to fix the pinging while replying issue
Hello, im not sure why this is happening
ExpectedConstraintError > s.array(T).lengthGreaterThanOrEqual()
Invalid Array length
Expected: expected.length >= 1
Code:
const container = new ContainerBuilder()
.setId(1).setAccentColor(0x0099ff)
.addTextDisplayComponents(component => component.setContent('Staff Management Panel').setId(2))
.addSeparatorComponents(component => component.setDivider(true).setId(3))
.addTextDisplayComponents(component => component.setContent('Select an action from the following:\n- Change Slowmode\n- Lock Channel\n- Unlock Channel\n- Ban Member\n- Quarantine Member').setId(4))
.addActionRowComponents(component => component.setId(5).addComponents(row));
await interaction.channel.send({ components: [container], flags: MessageFlags.IsComponentsV2 });
can I send content and the new embed together?
first it doesnt while showing loading embed but it does ping when it edits it does ping why ?
like your don't want it to ping you
yes i dont want to ping
ContainerBuilder#setAccentColor() doesn't accept hex strings?
add allowedMentions to your reply with users set to an empty array
interaction.reply({allowedMentions: {users:[]}})
Fetching a sound by id always seems to result in undefined, but when using fetching options it works. Is it supposed to behave like this? The docs display SoundboardSoundResolvable can be specified as single option 
Returns always undefined:
ctx.guild.soundboardSounds.fetch(id).catch(ctx.noop)
Returns the sound object:
ctx.guild.soundboardSounds.fetch({ soundboardSound: id }).catch(ctx.noop)
The id is a valid sound ID of the current guild
The same way as for non-components
You can control which entities receive notifications via the allowedMentions option. You can:
- Set a default on the client
- Set for a specific message
- Use the
repliedUserkey to disable in-line reply mentions
{ ..., allowedMentions: { parse: ["users", "roles"] } }
i have allowedMentions: {
parse: ["roles", "users", "everyone"],
repliedUser: false,
},
in extended client class
Well, you mention a user in there, so the parse user makes it ping
but its not my mention
what qjiuh said. replied user is for you are replying to a message. not went they are mentioned in the message
Can you show the code for that and/or expand the screenshot to show the part above that?
ok
Because it’s edited, so what was it before edit?
that is corect only the hex(0xff0066) number there is a helper function you can uses if you need
resolveColor
discord.js@14.18.0
Resolves a ColorResolvable into a color number.
ty
Yeah, there's a bug to do with that, will be fixed in 14.19.2
Hi, I was wondering if there is an easy way to detect when a server was joined. I want to update my servercount on top.gg when the bot gets added to a new server. I was looking through the Event enum but I cant seem to find one which clearly indicates it gets triggered when a server is joined. I could of course do it on any random event but that seems kind of inefficient
In <GuildChannel>.permissionOverwrites.cache what does <overwrite>.allow/deny.toArray() return? My editor can't infer the type for some reason and I can't seem to find it in the docs. Does it return a PermissionsString or something else?
Alright, thanks!
documentation suggestion for @tender spade:
(event) Client#guildCreate discord.js@14.18.0
Emitted whenever the client joins a guild.
An array of strings
PermissionsBitField#toArray() discord.js@14.18.0
Gets an Array of bitfield names based on the permissions available.
I was wondering what guild create did because it didnt make sense that the bot can detect whenever a guild is created, before even being in it. Thanks!
its was showing no ping before edited
Do containers have footers like embeds?
No, but you can use any kind of markdown you want
-# including these or timestamps
thumbnailbuilder?? why am i getting this error when i am not referencing any thumbnails?
https://pastebin.com/ARdVD1DY
forgot to add the code in the previous paste
https://pastebin.com/LivkHGLi
-# This looks like footer text, just a different color • <t:1048652791:R>
Oh that - #?
yes
Section must have either button or thumbnail as an accessory
so something like this? .setThumbnailAccessory(${interaction.client.user.dsiplayAvatarURL()})
More like .setThumbnailAccessory(thumbnail => thumbnail.setURL(…))
like this
const section2 = new SectionBuilder().addTextDisplayComponents(footerInformation)
.setThumbnailAccessory(thumbnail => thumbnail.setURL('url'));
What is a section?
can i not add multiple buttons in a SectionBuilder?
A Section is a top-level layout component that allows you to join text contextually with an accessory.
https://discord.com/developers/docs/components/reference#section
hmm, ok i miss-judged where it was going to go do i have to attach it to the first text box?
"top-level layout component"
section has aura
🥀
Use action rows if you need multiple buttons
how do i hoist it to be in the top section? also is it flexible so it can be on any of the 4 corners?
Is it a must to add an accessory to a section?
new SectionBuilder()
.addTextDisplayComponents(components)
.setThumbnailAccessory(
new ThumbnailBuilder().setURL(
"image_link",
),
)
yes
It displays in the order you put it. So put it first
Yes
Otherwise use text component simply not section if you just want text
well they should document it, I had to dig into the source code to figure it out, I have no idea what the error message whats to say
fyr this is the error message
error: Received one or more errors
errors: [
1161 | var CombinedPropertyError = _CombinedPropertyError;
1162 |
1163 | // src/lib/errors/ValidationError.ts
1164 | var _ValidationError = class _ValidationError extends BaseError {
1165 | constructor(validator, message, given) {
1166 | super(message);
^
error: Expected
validator: "s.instance(V)",
given: undefined,
expected: [class (anonymous)],
at new BaseError (1:23)
at new ValidationError (/home/harrow/shits/projects/discord-assistant/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1166:5)
at new ExpectedValidationError (/home/harrow/shits/projects/discord-assistant/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1487:5)
at handle (/home/harrow/shits/projects/discord-assistant/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1531:75)
at run (/home/harrow/shits/projects/discord-assistant/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:958:23)
at handle (/home/harrow/shits/projects/discord-assistant/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1960:32)
at parse (/home/harrow/shits/projects/discord-assistant/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:90)
at toJSON (/home/harrow/shits/projects/discord-assistant/node_modules/@discordjs/builders/dist/index.js:2170:37)
at map (1:11)
at <anonymous> (/home/harrow/shits/projects/discord-assistant/src/core/handle.ts:75:16)
This just got added yesterday and I would guess it was a rushed job. the error messages will improve with time
good things require good time
The problem is that no status page or any other app on this host returns the same error, only one
its nothing djs can do about though
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.
what am i doing wrong?
ExpectedConstraintError > s.array(T).lengthGreaterThanOrEqual()
Invalid Array length
Expected: expected.length >= 1
Received:
| []
const topImage = new SectionBuilder().setThumbnailAccessory(thumbnail => thumbnail.setURL(`${interaction.client.user.displayAvatarURL()}`));
const titleText = new TextDisplayBuilder().setContent(
[
'# Application Information',
].join('\n'),
);
container.addSectionComponents(topImage).addTextDisplayComponents(titleText);
Is it possible to send a message that doesn't get manipulated by discord as such? I have an in-game chat to discord link and don't want people's messages to be affected by markdown or other discord things like channel tags and pings if possible
can an embed be added in the container of componentsv2? also is it possible to add author and footer to it?
Now you are missing text component in section, you need to have atleast one accessory and 1 (text) component for section
you cant mix legacy components (content and embed) with components v2
You can have upto three text components in section
ah ok thanks
you cant add a footer but you could add a text section to the bottom using -#
-# makes small text
Do we have a guide on how to use components v2 in djs latest version?
not yet
u can check the mts file in the announcement, it show some thing who work
got it, ty
np
Everyone wanted it so badly 💀
Hello, how to defer a reply and then add components v2? can we edit the flags of a message? because we can't put IsComponentV2 in the flags of a deferred message.
you still need to reply to a deffered message right?
Can anyone tell how to use component V2 is there any guide or something.
yes, but when editing, I get the DiscordAPIError[50035]: Invalid Form Body components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
I'm trying to use .addFileComponents of ComponentsV2 but after setting the URL with .setURL it says that it wants an attachment instead of the link. I'm not sure how to solve this
is it possible to add normal buttons other than links using the sections? (in component v2)
Hm
you can add action rows
new ContainerBuilder().addActionRowComponents(ActionRow)
im curious is this a carousel? or is it a single image like embed?
hello,
i'm trying to make a container but i keep getting this error
https://pastebin.com/ujgsZyn3
here's the code: https://pastebin.com/aprM55eK
it can be multiple items but it is not a carousel(left most example) I think
https://discord.com/developers/docs/components/reference#media-gallery
a
can link buttons have custom emojis?
can i use select menus in new embeds?
yes
how
slap it in an action row as usual and add it to the components
yes to this as well
ty
I'm trying to use .addFileComponents of ComponentsV2 but after setting the URL with .setURL it says that it wants an attachment instead of the link. I'm not sure how to solve this
MultiplePossibilitiesConstraintError > s.string().url()
| Invalid protocol for file URL. Must be attachment:
|
| Expected any of the following:
| | - attachment:
Show the code
isnt the link to an image itself considered an attachment
And also full error, not just half
i assume they also removed color from new embed?
you can still set accent color
its only rgb?
ok thanks
Yes in Tuple form or hex value forms
ContainerBuilder.setAccentColor(color?: RGBTuple | number): ContainerBuilder
hex is string?
0xHEX
like 0x00ffff
without quotes
kk
currently no. their is a helper function resolveColor to help you covert
is it possible to somehow create different columns in components v2? like how we have fields inline in embed builder?
Argument of type 'ApplicationEmoji' is not assignable to parameter of type 'APIMessageComponentEmoji'.
Im trying to use ButtonBuilder#setEmoji()
no, only the section can achive text on the left and something else on the right (button/thumbnail)
how would one go about editing a container section button? Say I would like to edit a single button on the container, would I have to repass the entire container with the change i made or can i target said button?
NVM fixed, it wants the media option
I think the .from() method doesn't exist like you would with embeds
but this is all very new so there isn't a lot of research being done what fits the best
I think this is your solution. not tested
ButtonBuilder().setEmoji({id:applicationEmoji.id, name:applicationEmoji.name})
i cant add a button and thumbnail at the same time in a section?
const section = new SectionBuilder()
.addTextDisplayComponents(text)
.setButtonAccessory(button)
.setThumbnailAccessory(thumbnail);
yep all g. Repassing the entire component would be a pain imo so just hoping
I really hope they will somehow if that is possible with the new components, I mean they also did it with ActionRowBuilder, so I don't see why they cannot use it for components v2 too
you can uses the optional id property of the component to find and edit
you can't add both a button AND thumbnail at the same time as accessory afaik -- checked it: you indeed cannot
ty ty
so i'm making an Application Command and i'm trying to get a member's avatar URL
the member is got by doing interaction.options.getMember("user")
and the URL is attempted by doing member.avatarURL()
however, it keeps printing out null for some reason
does anyone know why?
How many containers can a message have
I think just 1
Is there a way to make an ephemeral component v2?
yes, just pass in both flags
I try to use array with 2 flags but dont working
After i show a error log
you need to bitwise or them
flags: MessageFlags.IsComponentsV2 | MessageFlags.Ephemeral
Ahh
Tkx bro
Does the member have a guild avatar?
GuildMember#displayAvatarURL() discord.js@14.18.0
A link to the member's guild avatar if they have one. Otherwise, a link to their displayAvatarURL will be returned.
Maybe you want this instead
does the default discord profile count
No, that'd be user avatar, yeah, you wanna use this instead
coolio
thanks
Up to 10, if you wanted
- Messages currently allow up to 10 top-level components and 30 total components
https://discord.com/developers/docs/components/reference#component-reference
cc @dense jackal
ah thanks
how do i turn reply off (the ping) editReply never used to do the orange ping colour (?)
ty
You can control which entities receive notifications via the allowedMentions option. You can:
- Set a default on the client
- Set for a specific message
- Use the
repliedUserkey to disable in-line reply mentions
{ ..., allowedMentions: { parse: ["users", "roles"] } }
@rigid crest ^
fyi allowedMentions are currently broken when sending components v2 messages
broken as, ignored
the team is working in a fix
oh that makes sense
I was like why isn't it working 😭
my IDE says its AllowedMentionsTypes: [AllowedMentionsTypes.User],
your IDE is wrong
the property is still called allowedMentions, what you can pass to parse is those values
or just their string mappings
users, roles, etc
so this would be what would work to stop the ping allowedMentions: { parse: ["repliedUser"] }?
is there a way to make only certain users selectable in select menus or still no
Messages Resource - Allowed Mentions Object
read more
no, it's "allowed" mentions, not forbidden mentions, it'd make it so only the repliedUser would be pinged
and not other users/roles/etc inside the message
when is this bot getting the latest docs version
how do i disable it? that is my goal (also since discord updated the colour of pings its not as nice on the eyes)
I believe it's already updated? pretty sure I saw someone here using it for cv2 docs
don't pass the repliedUser
not for me, e.g. if I use /docs query:ThumbnailBuilder nothing shows up
oh /docs, thought you meant /discorddocs
hi did you manage to figure this out? currently experiencing the same issue
no idea, it should be automatic
hm alr
are you using TypeScript or not?
you should put it in the editReply
that doesnt seem to work
yeah, add the flag in the editReply, not the deferReply
could you show your code?
yeah you get a TS error when using typescript -- reference: #djs-help-v14 message and #djs-help-v14 message
I'm on TS yeah; I assume this is an error or?
^^
this type is incorrect, add a // @ts-expect-error
wait, should an array be passed for flags or union
oh yeah that should include the cv2 flags as well
union
seems like a types bug, but it should work in runtime
but its known by the d.js dudes
👍 i'll ignore it for now
How is array working for me then
like i said, add a // @ts-expect-error before the line with the error
ehh I have no idea, flags need to be an integer combined as a bitfield
because flags can be an array
oh so both work?
yeah
ApplicationEmoji#name can be null?
looks like it can
Error: Expected a string primitive
at _StringValidator.handle (C:\Users\bs115\Desktop\truq djs rewrite\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2615:70)
at _StringValidator.parse (C:\Users\bs115\Desktop\truq djs rewrite\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:90)
at validateRequiredSelectMenuParameters (C:\Users\bs115\Desktop\truq djs rewrite\node_modules\@discordjs\builders\dist\index.js:545:21)
at StringSelectMenuBuilder.toJSON (C:\Users\bs115\Desktop\truq djs rewrite\node_modules\@discordjs\builders\dist\index.js:1180:5)
at C:\Users\bs115\Desktop\truq djs rewrite\node_modules\@discordjs\builders\dist\index.js:2302:64
at Array.map (<anonymous>)
at ActionRowBuilder.toJSON (C:\Users\bs115\Desktop\truq djs rewrite\node_modules\@discordjs\builders\dist\index.js:2302:35)
at C:\Users\bs115\Desktop\truq djs rewrite\node_modules\@discordjs\builders\dist\index.js:1871:64
at Array.map (<anonymous>)
at ContainerBuilder.toJSON (C:\Users\bs115\Desktop\truq djs rewrite\node_modules\@discordjs\builders\dist\index.js:1871:35) {validator: 's.string()', given: undefined, stack: 'Error: Expected a string primitive
at _St…@discordjs\\builders\\dist\\index.js:1871:35)', message: 'Expected a string primitive'}
``` whats this error about?
thats so weird
show your code
so ig it doesnt support more than one image? or if it does what did i do wrong
const mediaAttachment = new MediaGalleryBuilder({
items: [
{
description: "A Desktop Wallpaper",
media: {
url: 'https://t3.ftcdn.net/jpg/05/69/72/02/240_F_569720237_58rhoQoMjxyB0QCeXQK0OVUA0qNogTmq.jpg',
},
description: "A Desktop Wallpaper",
media: {
url: 'https://t3.ftcdn.net/jpg/05/69/72/02/240_F_569720237_58rhoQoMjxyB0QCeXQK0OVUA0qNogTmq.jpg',
},
description: "A Desktop Wallpaper",
media: {
url: 'https://t3.ftcdn.net/jpg/05/69/72/02/240_F_569720237_58rhoQoMjxyB0QCeXQK0OVUA0qNogTmq.jpg',
},
},
],
});
your string select doesn't have a customId
oops
could you try with different urls just in case?
so how do i get around this?
i still cannot actually understand, what does separator divide, sections? components?
components
inside a container ^^
its just a horizontal line you can put inside your container
i changed the second and third links and the image got set to the third link
const mediaAttachment = new MediaGalleryBuilder({
items: [
{
description: "A Desktop Wallpaper",
media: {
url: 'https://t3.ftcdn.net/jpg/05/69/72/02/240_F_569720237_58rhoQoMjxyB0QCeXQK0OVUA0qNogTmq.jpg',
},
description: "A Desktop Wallpaper",
media: {
url: 'https://t4.ftcdn.net/jpg/04/86/85/75/240_F_486857516_mq31R22FNaMxE3DTkWO73bAdaDxllmj8.jpg',
},
description: "A Desktop Wallpaper",
media: {
url: 'https://t4.ftcdn.net/jpg/04/19/10/29/240_F_419102935_z4wjydPrlF2a8glzyLg5F7Qve6y6IDm7.jpg',
},
},
],
});
container.addMediaGalleryComponents(mediaAttachment)
https://discord.com/developers/docs/change-log#whats-new
New Layout Components
- Section - Combine text with an accessory component for contextually linked elements
- Container - Create visually distinct groupings with a customizable accent color
- Separator - Add visual spacing and dividers between components
New Content Components
- Text Display - Add rich markdown-formatted text anywhere in your messages
- Thumbnail - An image used in a section
- Media Gallery - Present collections of images and videos in an organized grid
- File - Embed file attachments as part of your message layout
It is possible to build components v2 in object ?
wdym?
guys
why cant i add file, keep getting error:
const text = new TextDisplayBuilder().setContent(`Here is the transcript of the ticket`);
const mediaGallery = new MediaGalleryBuilder()
.setId(1)
.addItems([new MediaGalleryItemBuilder().setURL(image.url)]);
const file = new FileBuilder().setURL(htmlFile.url);
container.addTextDisplayComponents(text).addMediaGalleryComponents(mediaGallery).addFileComponents(file);
return await interaction.followUp({ components: [container], flags: MessageFlags.IsComponentsV2 });
which error
like
type: 1,
components: [ { type: 17 , components: [ ... ]}]
you dont need builders, you can write raw objects too yes
Ok thanks
does it divide text-buttons for example or only text-text
all of the above
it divides component-component
I'd recommend against using raw numbers though, you should at least use the enum
input.url
| MultiplePossibilitiesConstraintError > s.string().url()
| Invalid protocol for file URL. Must be attachment:
|
| Expected any of the following:
| | - attachment:
the file cant be a link i assume?
this is not how js works bro, you need different objects in the array, not all in one
Why, the result is the same
discord can change numbers at any point
Then, I change the numbers
try fetching the emoji
so items:{stuff}, items:{stuff?}
its already fetched
Hey, is it possible to add multiple buttons to a section with .setButtonAccessory()?
because you can't read what number is what type without needing to go to the docs
no 😭 items is an array, you put multiple objects in it
nope, more than 1 button requires you to use an action row
ah okay, thanks!
It's easy to remember
Then typegaurd. don't add the emoji if name is null. maybe
I doubt you can remember all the component types
including the cv2 ones
just use the enum, you don't require to lookup what number is which
and text showing the name of the component is in no way harder than a number
Everyone does what they want ^^
did you figure it out? if not imma help you in dms, it will be easier
yeah, that's why we're recommending you, not forcing it
you're free to do things harder for yourself if you'd like, but the point of this channel is to give help
what's your url?
just a string
just show how it begins
https
no it can't, only attachments
ok thanks
how do i get emoji from specific guild
Will https://discordjs.guide/popular-topics/embeds.html be updated for cv2? Or am i just looking in the wrong place for the info about it
sorted
its been a hot min since ive used that way
are there limits to how many sections can be added in components v2?
10 top level components and 30 components total
(and a section is a top-level component)
it can be, it can also be in a container
discord api docs needs another check to be more clear, that's fs
it doesn't make sense APIMessageComponentEmoji.animated? is already an optional parameter
Hello, I'm on v14.13.0 and I have an old bot I haven't really worked on in like a year. When I try to build it im getting this:
src/commands/Moderation/purge.ts:129:51 - error TS2339: Property 'send' does not exist on type 'DMChannel | PartialDMChannel | PartialGroupDMChannel | NewsChannel | StageChannel | TextChannel | PublicThreadChannel<...> | PrivateThreadChannel | VoiceChannel'.
Property 'send' does not exist on type 'PartialGroupDMChannel'.
129 const msg = await message.channel.send(toSend)
I'm aware of what it means, but why would I not be able to reply to a text message I got? message is of type Message. If there is a message there in the first place, then it's a channel where one can write no? Is there any "good" solution to check whether I can send a message or not?
documentation suggestion for @zinc wyvern:
BaseChannel#isSendable() discord.js@14.18.0
Indicates whether this channel is sendable.
There is something to transform builder into raw object ?
undefined is different then null
.toJSON()
Thank you, I'll use that. Any clue how a message is there in the first place if it's somewhere where it can't be sent? Just for understanding.
Oh my bad, I forgot the N at the end x)
user installed apps can receive interactions from group dms, and you can't send messages to them
I'm curious what you need it for
well then why wouldn't this work?
Ah I see, thanks
Components V2, I don't like builders
I dont think name is optional
because not-present is also not the same as undefined if you use exactOptionalProperties
then don't use builders? just raw data
I am not sure, what is the error
can someone link components v2 docs? I think im blind lol
so should i turn that off in my tsconfig
Yeah, but I need an example of the structure
that's your decision. I'm just explaining the why
but i don't understand why ApplicationEmoji's name can be null
Ahh thanks! i was looking in djs, but presume that will be launched at a later stage?
could also ! it, if you know it won't be null for you
tbh, neither do I
what does this mean?
and how can animated be null as well, either its animated or its not 😭
yeah we were suspecting that, applicationemoji probably shouldn't be typed as null as well
someone was probably thinking about reactions when they were implemented to djs
like message reactions?
yes
So emoji in message reaction will have no name?
that's what the docs suggest, yes, but then it'll be a ReactionEmoji
not an ApplicationEmoji
May be null
in SlashCommandBuilder().addUserOption() i can only use x => x... or object too?
so basically ApplicationEmoji is incorrectly typed?
that too, yes, or a builder
we're discussing that internally but that seems to be the most likely thing
a question i asked a while go but wasnt fully answered, can the thumbnail be flexible (left to right)
no
that's just an image?
thumbnail is always fixed size to the right
so what do you suggest I do now?
just type assert
Can we add videos to embeds now? I cant find any info on restrictions of filetypes in the docs
as string
or !
you can afaik
goated, now to figure out how
I hope its fixed soon though
how can i get the given option
What is Components v2 in v14?
Is it something to do with the way components are handled/will I need to change the way my bot sends messages/components or what does it introduce?
there should be a release soon
due to the allowedMentions bug
and the editReply flags bug
so this could be fixed in that as well?
maybe this fix can also be added there
does it need a github issue?
So what new stuff has been introduced? Things like Role Select Menus support in modals, etc yet?
i just made an issue but i realized a patch is already in a pull request bruh
oh no that hasn't been released
edited, mb
...no
please read it
is there a image limit? (like discords upload limit being 10?)
its the same for bots as it is for users
so 10 by default
So just new layout and content components were introduced?
yes
is there an overview of the djs functions/enums added to support components v2? And maybe how theyre used lol
That's the same as what I need tbh, I'm not entirely sure what benefit it has
you have an example of almost everything in the file in #announcements
Oh tonnes of benefits i just dont know how to use it yet. Maybe take 2 seconds to read the announcement, it shows the new potential
There was an announcement? 👀
if i could open that file that wouldve been my first stop, but windows refuses to show anything. Unknown codex
are there any d.js ts tutorials
just open it in vscode bruh
thats the discord docs, but not the djs implementation which i was looking for
why would you open a text file in a media player
Uncaught _ExpectedValidationError Error: Expected
at handle (file:///C:/Users/bs115/Desktop/truq%20djs%20rewrite/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1531:75)
at parse (file:///C:/Users/bs115/Desktop/truq%20djs%20rewrite/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:90)
at assertReturnOfBuilder (file:///C:/Users/bs115/Desktop/truq%20djs%20rewrite/node_modules/@discordjs/builders/dist/index.js:2461:53)
at _sharedAddOptionMethod (file:///C:/Users/bs115/Desktop/truq%20djs%20rewrite/node_modules/@discordjs/builders/dist/index.js:3263:5)
at addUserOption (file:///C:/Users/bs115/Desktop/truq%20djs%20rewrite/node_modules/@discordjs/builders/dist/index.js:3194:17)
at <anonymous> (file:///C:/Users/bs115/Desktop/truq%20djs%20rewrite/commands/ban.js:7:10)
at <anonymous> (node:internal/modules/cjs/loader:1562:14)
at <anonymous> (node:internal/modules/cjs/loader:1699:10)
at <anonymous> (node:internal/modules/cjs/loader:1313:32)
at <anonymous> (node:internal/modules/cjs/loader:1123:12)
at traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at <anonymous> (node:internal/modules/cjs/loader:1335:12)
at require (node:internal/modules/helpers:136:16)
at <anonymous> (file:///C:/Users/bs115/Desktop/truq%20djs%20rewrite/index.js:52:21)
at <anonymous> (node:internal/modules/cjs/loader:1562:14)
at <anonymous> (node:internal/modules/cjs/loader:1699:10)
at <anonymous> (node:internal/modules/cjs/loader:1313:32)
at <anonymous> (node:internal/modules/cjs/loader:1123:12)
at traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at executeUserEntryPoint (node:internal/modules/run_main:170:5)
at <anonymous> (node:internal/main/run_main_module:36:49)
follow the guide, there aren't that many changes you'll need
Well how was i supposed to know? Its a file format that ive never seen used in my 25 years here on earth
This used to give back something of type Message, but now it seems to give back something that pretty much only has client? It gives InteractionCallbackResponse.
repliedMessage = await interaction.channel?.send(content);
.ts is also a video format
wheres the guide
im usually in youtube and the docs
Home: Introduction - Before you begin...
read more
stands for module typescript, you also have mjs and cjs, etc
that will always return a Message
.reply will return that
that explains, who uses TS
(obviously joking)
i love this new forward feature
on addattachmentoption can i add a description? like the user clicks the file of choice then they can add a description for the alt text? i have been wondering about this for a while but never asked about it
can someone tell me whats wrong?
https://pastebin.com/sJ3bNqQj
yeah but he knows its a file containing code, why still opening it in a media player?
oh sorry, I sent the wrong thing then (originally).
Thank you
InteractionCallbackResponse#resource discord.js@14.18.0
The resource that was created by the interaction response
access its .message propertry
yo is it mandatory to set an accessory button in a section of a container ?
a button or thumbnail yes
damn
thank you
no this isnt mandatory, but you can add only one
i think you can just put just some text
if you're doing a section it is mandatory
thats what i did, but i am getting this error hold on
because otherwise the section would be useless
just use a text component directly
ah yes thats right my bad
Just to confirm, we cant set a color like we can with embeds? cv2 a whole new thing?
you can set an accent color, yes
so even if i set a text display it is still mandatory to set a button
in a container
or thumbnail
if you're wrapping the text display in a section, yes
the section requires an accessory
you can, but you cannot use hex codes and you need to use rgb instead in this format: [red, green, blue]
a thumbnail or a button
if you just use the text display directly you don't need to
sweet! So [int, int, int]?
yeah
i dont understand the error
Uncaught _ExpectedValidationError Error: Expected
at handle (file:///C:/Users/bs115/Desktop/truq%20djs%20rewrite/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1531:75)
at parse (file:///C:/Users/bs115/Desktop/truq%20djs%20rewrite/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:90)
at assertReturnOfBuilder (file:///C:/Users/bs115/Desktop/truq%20djs%20rewrite/node_modules/@discordjs/builders/dist/index.js:2461:53)
at _sharedAddOptionMethod (file:///C:/Users/bs115/Desktop/truq%20djs%20rewrite/node_modules/@discordjs/builders/dist/index.js:3263:5)
at addUserOption (file:///C:/Users/bs115/Desktop/truq%20djs%20rewrite/node_modules/@discordjs/builders/dist/index.js:3194:17)
at <anonymous> (file:///C:/Users/bs115/Desktop/truq%20djs%20rewrite/commands/ban.js:7:10)
at <anonymous> (node:internal/modules/cjs/loader:1562:14)
at <anonymous> (node:internal/modules/cjs/loader:1699:10)
at <anonymous> (node:internal/modules/cjs/loader:1313:32)
at <anonymous> (node:internal/modules/cjs/loader:1123:12)
at traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at <anonymous> (node:internal/modules/cjs/loader:1335:12)
at require (node:internal/modules/helpers:136:16)
at <anonymous> (file:///C:/Users/bs115/Desktop/truq%20djs%20rewrite/index.js:52:21)
at <anonymous> (node:internal/modules/cjs/loader:1562:14)
at <anonymous> (node:internal/modules/cjs/loader:1699:10)
at <anonymous> (node:internal/modules/cjs/loader:1313:32)
at <anonymous> (node:internal/modules/cjs/loader:1123:12)
at traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at executeUserEntryPoint (node:internal/modules/run_main:170:5)
at <anonymous> (node:internal/main/run_main_module:36:49)```
cheers mate
you forgot to return your actual option
you just passed a void
documentation suggestion for @radiant bough:
resolveColor discord.js@14.19.1
Resolves a ColorResolvable into a color number.
i didnt even pass anything
then there is your issue
how do i fix it
by passing in a user option
this?
addUserOption({
name: "member",
description: "Member to ban",
required: true,
})
How to make such a message?
the source code is literally attached
why are action rows not allowed to be in containers when the discord docs state that they are allowed to be?
pretty sure it takes a callback function
i cant understand what you mean, this code worked before but when i updated it stopped working
not too sure why you are using builders in the first place if you just pass in raw json
Where
but they are allowed
um, actionrow is the first member of the union
show the full code
oh weird
its in the docs but when i tried adding an ActionRowBuilder it errored
this?
did you type it with MessageActionRowComponent
BRO the TypeScript file in the message
XD
no
ya that is the issue use ActionRow<ButtonBuilder>
container.addActionRowComponents((row) => row.addComponents(
new ButtonBuilder()...
))
should work
but now im getting
DiscordAPIError[50035]: Invalid Form Body
data.components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
data.components[1][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
data.components[2][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
await i.reply({
components: [
new TextDisplayBuilder({ content: "Hello to <@" + (i.options.get("mention")?.value ?? i.user.id) + ">!" }),
new SeparatorBuilder(),
new ContainerBuilder()
.addActionRowComponents(p => p.addComponents(
new ButtonBuilder()
.setCustomId(`test-${i.options.get("mention")?.value ?? i.user.id}`)
.setLabel("Mention me")
.setStyle(ButtonStyle.Primary)
))
]
});
well well well
kinda looks messy
oh yea the flag
you need the IsComponentsV2
so do you know whats wrong?
didnt notice lol
also, you shoud use getString or whatever option type you have
idk, code looks correct, maybe someone else knows
well ok
do i use multiple buttons like this
.setButtonAccessory(button1, button2)
or
.setButtonAccessory(button1)
.setButtonAccessory(button2)
you can only have one button in an accessory
you need to use an action row
(which would go in a separate component, not as an accessory)
looks like that specific builder method doesn't support raw data, only a builder or a generator
sorry, IDk why I thought an action row could be an accessory
alternatively two sections each with one button, if you want them below each other
np, just clearing that up for them
addUserOption?
yes
ah thats sad
i want them next to each other. how would i do that?
is it possible to adjust the size of an image inside an image gallery in containers?
I'm switching from an embed to a container and the image when used in the old embeds is smaller than it is when used as an image gallery in a container and its way too big for my liking
@tardy sable
why are you doing this half-builder-half-json in the first place?
thanks
it isn't
Channels are always cached when the Guilds intent is specified, correct?
idk why i didnt change all of them at once, i wanted all json cuz it looks cleaner
yes (apart from archived threads and dmChannels)
Got it. Thanks
how about if im building the image myself using attachment builder / napi-rs/canvas?
attachment builder doesn't let you modify the size
and I don't think a smaller image would show as being smaller, pretty sure it'll still be big
just guessing though
what i use then instead of setButtonAccessory
nothing inside that section
you're done in that section
add another component, an action row, to the container
like this?
container.addSectionComponents(actionrow);
I haven't used discord.js and typescript in a while. I have a bot with many lines of code and I don't want to edit in the .isSendable call to each and every interaction.channel use. I have an "interaction manager", where I would like to just ignore any interaction that has a channel that's not sendable. Does anyone know how I can then make a type that specifies that?
For Message, I found this:
OmitPartialGroupDMChannel<Message>
though I don't know how to get it (probably will just check and then manually do as).
Is there something similar for interactions?
no, an action row isn't a section
discord invite links are not previewed when sent via components v2? (ie, outside the container)
try it and see
im actually fucking dumb, what does DiscordAPIError[10002]: Unknown Application mean?
is your bot user-installable or just guild-based?
just guild based
that's why I don't really care about those interactions, I would gladly just discard them
doesn't preview but I am so confused on why though... aren't content outside container work as a normal message? 
ChatInputCommandInteraction#inCachedGuild() discord.js@14.19.1
Indicates whether this interaction is received from a cached guild.
im confused. i use container.addComponents(actionrow); then?
🤷 ask discord
we don't have control over that
that should do the trick then (and use the <"cached"> generic on the parameters of your command files)
no, addActionRowComponents
since they're action row components
Alright, thank you
^
ok thanks
because discord invites render as embeds. which don't exist if flag IsComponentsV2 is present
please first read the docs if you're wondering what methods every object has, instead of guessing
ContainerBuilder discord.js@14.19.1
A builder that creates API-compatible JSON data for a container.
and no, there can't be any content outside of components. text outside of a container is still a component, just no boxed background
applicationId wrong usually. show the full error for more insight
question, if you @ someone within a component will it still have the effect of mentioning them
it does
yes
Oh thanks, not really had a chance to test it out (should defo remove slowmode for donors ;) )
tag suggestion for @weary swallow:
You can control which entities receive notifications via the allowedMentions option. You can:
- Set a default on the client
- Set for a specific message
- Use the
repliedUserkey to disable in-line reply mentions
{ ..., allowedMentions: { parse: ["users", "roles"] } }
DiscordAPIError[10002]: Unknown Application
at handleErrors (C:\Users\Uzivatel\Desktop\Langs\js\discord.js\node_modules\@discordjs\rest\dist\index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async SequentialHandler.runRequest (C:\Users\Uzivatel\Desktop\Langs\js\discord.js\node_modules\@discordjs\rest\dist\index.js:1128:23)
at async SequentialHandler.queueRequest (C:\Users\Uzivatel\Desktop\Langs\js\discord.js\node_modules\@discordjs\rest\dist\index.js:959:14)
at async _REST.request (C:\Users\Uzivatel\Desktop\Langs\js\discord.js\node_modules\@discordjs\rest\dist\index.js:1272:22)
at async C:\Users\Uzivatel\Desktop\Langs\js\discord.js\main.cjs:71:9 {
requestBody: { files: undefined, json: [ [Object], [Object] ] },
rawError: { message: 'Unknown Application', code: 10002 },
code: 10002,
status: 404,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/1364333179397341294/guilds/1206958734958399488/commands'
}
in case you want to not mention, it's currently broken but it'll be fixed
I think it is an OAuth error. your applications needs to be added with the bot scope
it has been used before and it has all scopes and im using all intentions just to not have to cope with ts
meanwhile i think that 1206958734958399488 is the bot and 1364333179397341294 is the guild
-# i lied, i KNOW that that's the case 
await channel.send({
components: [container],
flags: MessageFlags.IsComponentsV2,
});```
is it possible to add, `content: 'eg message'` to this?
no
He did literally just answer your question here
components v2 means no content and no embeds
got it, all of this is kinda confusing at first. ty
But while it's not user-installable, it still supports DM commands (like, you DM the bot user). That will make it stop working right?
(and no poll, no stickers, no attachments outside of those used in a component)
im struggling to keep the message component and disable button after click without removing the entire message component or do i need to add the button inside the suggestion component to start the thread? (or will it still erase all of the info)
if (interaction.customId === 'comment_button') {
try {
const disabledButton = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setStyle(ButtonStyle.Danger)
.setLabel('Use thread to continue comments')
.setCustomId('comment_button')
.setEmoji('📒')
.setDisabled(true)
);
const modal = new ModalBuilder()
.setCustomId('commentResponse')
.setTitle('Leave a comment');
const commentText = new TextInputBuilder()
.setCustomId('comment-text')
.setLabel('Your comment')
.setPlaceholder('Enter your comment here...')
.setStyle(TextInputStyle.Paragraph)
.setRequired(true);
const textGiven = new ActionRowBuilder().addComponents(commentText);
modal.addComponents(textGiven);
await interaction.showModal(modal);
const message = interaction.message;
setTimeout(async () => {
const suggestionContainer = message.components[0]; //without this being here and in the edit below it just disables the button and removes the suggestionContainer
await message.edit({ components: [suggestionContainer, disabledButton] });
}, 2000);
//rest is just thread creating
with the added message.components, i get this error
return { ...this.data, media: this.media.toJSON() };
^
TypeError: this.media.toJSON is not a function
at ThumbnailComponent.toJSON, at SectionComponent.toJSON,at Array.map (<anonymous>), at ContainerComponent.toJSON,Array.map (<anonymous>), at MessagePayload.resolveBody, at GuildMessageManager.edit,at Message.edit,
i even knew that that was to case yesterday, and you still haven't accepted that? #djs-help-v14 message
impressive
i have no idea what this means, i tried enabling some scope thing in the dev portal and the issue still persists
Guys, what is image class is used for container?
Okay found it: APIMediaGalleryComponent
are you actually reading what souji is telling you
-# tfw ignored 2 days in a row 
and with a "I have no idea" 
im gonna try to switch them ok
works lol
sorry guys for being the biggest retarded piece of shit in this server
switching them is an understandable mistake, but please just don't ignore the one trying to help you
please refrain from using slurs, even when describing yourself
its a slur??
Does anyone know why im getting
{bot path}\node_modules\@sapphire\shapeshift\src\validators\UnionValidator.ts:9
export class UnionValidator<T> extends BaseValidator<T> {
^
CombinedError: Received one or more errors```
with
`[class ThumbnailBuilder extends ComponentBuilder]` and `[class ButtonBuilder extends ComponentBuilder]`
look it up, not djs related at this point
i tried editing the example component v2 thing in #announcements and it gave me this error when running my command
a section needs an accessory
I thought ChatInputCommandInteraction<undefined> indicated ChatInputCommandInteraction for DMs?
For educational and learning purpose, is this correct for Media Gallery on ComponentsV2:
const mediaGallery = new MediaGalleryBuilder();
const image = new MediaGalleryItemBuilder().setURL(some_url);
mediaGallery.addItems(image);
i had the error converted to human readable and this is what it broke it down to,
a media property that is not compatible with Discord.js's toJSON method is the image(s) not correctly saving? i just wanna avoid loosing the suggestion component message when someone uses the comment button to start a thread
yes
thats.... stupid
this.interactionMap[name](interaction);
^
TypeError: this.interactionMap[name] is not a function
``` i think its getting to the point where im bad at js
so why is APIInteractionData still there
how do i check if specific choice was selected
no. just don't put stuff in a section if you don't want an accessory
thats fair 😭
why would you call the method on it at all? there are no members in DMs
Coming back to this, normal buttons with customids can be used even when sending message via a webhook right? (components v2)
define specific choice
if the webhook is made by your bot, yes
i mean run code if Info module was selected for example
got it thanks for help guys, yall are awesome
selected in what
i try to make this and return error
the flag goes in the editReply, not the defer
because you don't use components in the defer
slash command option choices
its just like you would get a regular option
getString(...) and compare it against the choices
also typescript will complain here as well but it's a bug, it'll be fixed in next update, it still works in runtime though
(or getNumber/getInteger)
oh and it returns value i provided?
yes
I'm trying to run npm but it's giving this error
but in defer i set ephemeral, in the edit i need to update the flags like this?
not djs related, the error literally points you to a link
no, you defer with Ephemeral, and editReply with IsComponentsV2
yes
Is withComponents only for webhooks? And other messages and interaction responses just need to include Flags.IsComponentsV2?
yes
webhooks need both (for components v2), but yes
Gotcha. Thanks!
dont work this, only if i use flags: MessageFlags.Ephemeral in the defer and after in editreply flags: MessageFlags.Ephemeral | MessageFlags.IsComponentsV2
(sorry my english
hmm my bad then, no idea why it's like that
I tried to run it in another terminal and it works, only in powershell it doesn't, I ran it in CMD and it worked
this mode work 100%
that doesnt make it any more related to djs
any pointers, im still confused, i tried without including a uploaded image, it was going fine till i pressed the submit button for my comment and it crashed with the same error about media, is the displayavatarURL a cause now?
^
TypeError: this.media.toJSON is not a function```
so shouldn't it just be GuildMember | null
definitely not. if anything it should be never. But definitely not that
Does anyone by any chance know why I'm getting this?
src/buttons/tickets/createticket.ts:69:45 - error TS2769: No overload matches this call.
Overload 1 of 3, '(modal: APIModalInteractionResponseCallbackData | ModalComponentData | JSONEncodable<APIModalInteractionResponseCallbackData>, options?: ShowModalOptions | undefined): Promise<...>', gave the following error.
Argument of type 'ModalBuilder' is not assignable to parameter of type 'APIModalInteractionResponseCallbackData | ModalComponentData | JSONEncodable<APIModalInteractionResponseCallbackData>'.
Overload 2 of 3, '(modal: APIModalInteractionResponseCallbackData | ModalComponentData | JSONEncodable<APIModalInteractionResponseCallbackData>, options?: ShowModalOptions | undefined): Promise<...>', gave the following error.
Argument of type 'ModalBuilder' is not assignable to parameter of type 'APIModalInteractionResponseCallbackData | ModalComponentData | JSONEncodable<APIModalInteractionResponseCallbackData>'.
69 await interaction.showModal(modal)
modal is of type ModalBuilder:
const modal = new ModalBuilder()
modal.setCustomId("ticketpanel"+input)
modal.setTitle(panelData.questionsTitle || "Ticket Questions")
/** create `rows` component */
modal.addComponents(rows)
try {
await interaction.showModal(modal)
} catch (e) {
/** handle error */
}
wdym, I did use cached and undefined
for the slash command character limit, are only the lengths of the values of the names, descriptions, options(names, descriptions, choices), subcommand groups(names, descriptions), and subcommands(names, descriptions, options(names, descriptions, choices)) counted towards the character limit? or do the lengths of the keys also count towards the limit? Do the lengths of other parts of slash commands like contexts, defaultMemberPermissions, etc count against the character limit too? I'm confused what it means by "combined name, description, and value properties" in the documentation
so...
.setThumbnailAccessory(thumbnail => thumbnail.setURL(${interaction.user.displayAvatarURL()})); -> thumbnail breaks if you try to start a thread with the component data using the application it throws TypeError: this.media.toJSON is not a function
let mediaAttachment;
if (mediaItems.length > 0) {
mediaAttachment = new MediaGalleryBuilder({
items: mediaItems,
});
suggestionContainer.addMediaGalleryComponents(mediaAttachment);
}
```-> MediaGalleryBuilder breaks if you try to start a thread with the component data using the application it throws `TypeError: this.media.toJSON is not a function`
how can i start a thread if both forms of image media will crash the application? (when without any image media im able to start a thread via button and modal perfectly fine)
that is a combination that makes no sense though...
sounds like a question for ddevs #useful-servers, personally it sounds like the choices values count, but then it mentions choices again, so it's kinda confusing
glad I'm not the only one confused by its wording lol. I'll take a look there. Thanks
that definitely seems like a bug
<UnfurledMediaItem>.toJSON() entirely doesn't exist, yet both media-holding components' toJSON methods attempt to call it
for now you'll probably want to actually recreate each builder by calling the builder methods instead of passing the data to the contructor
(also it isn't specific to creating threads, but rather any reuse of existing component data for those components)
so like embed building "x.setImage"?
all of the builders use methods like that, not just embeds
if you've been passing objects to each builders' constructor for everything, I'm unsure why you're even using the builders at all
this is what i had for the thumbnail when it was constantly throwing the error with the tread after commenting it out it was fine
const topImage = new SectionBuilder()
.addTextDisplayComponents(titleText)
.setThumbnailAccessory(thumbnail => thumbnail.setURL(`${interaction.user.displayAvatarURL()}`));
suggestionContainer.addSectionComponents(topImage)
ive got a new error:
DiscordAPIError[50035]: Invalid Form Body
data.components[0][BASE_TYPE_REQUIRED]: This field is required
at handleErrors (C:\Users\bs115\Desktop\truq djs rewrite\node_modules\@discordjs\rest\dist\index.js:748:13)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async BurstHandler.runRequest (C:\Users\bs115\Desktop\truq djs rewrite\node_modules\@discordjs\rest\dist\index.js:852:23)
at async _REST.request (C:\Users\bs115\Desktop\truq djs rewrite\node_modules\@discordjs\rest\dist\index.js:1293:22)
at async ChatInputCommandInteraction.reply (C:\Users\bs115\Desktop\truq djs rewrite\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:194:22)
at async Object.execute (C:\Users\bs115\Desktop\truq djs rewrite\commands\modules.js:64:3)
at async Client.<anonymous> (C:\Users\bs115\Desktop\truq djs rewrite\index.js:73:3) {requestBody: {…}, rawError: {…}, code: 50035, status: 400, method: 'POST', …}
yes I understand that
I'm talking about this new MediaGalleryBuilder({ items: mediaItems, })
if you use the builder methods, add a new item, and set the url directly without reusing the component data, you should be fine
im doing it this way they go on the post correctly but crashes when a thread is attempted to be made with the button
const mediaItems = [];
if (image1Attachment) {
mediaItems.push({
description: `File uploaded by: ${interaction.user.username ?? interaction.user.displayName}`,
media: {
url: image1Attachment.url,
},
});
}
if (image2Attachment) {
mediaItems.push({
description: `File uploaded by: ${interaction.user.username ?? interaction.user.displayName}`,
media: {
url: image2Attachment.url,
},
});
}
if (image3Attachment) {
mediaItems.push({
description: `File uploaded by: ${interaction.user.username ?? interaction.user.displayName}`,
media: {
url: image3Attachment.url,
},
});
}
if (image4Attachment) {
mediaItems.push({
description: `File uploaded by: ${interaction.user.username ?? interaction.user.displayName}`,
media: {
url: image4Attachment.url,
},
});
}
let mediaAttachment;
if (mediaItems.length > 0) {
mediaAttachment = new MediaGalleryBuilder({
items: mediaItems,
});
suggestionContainer.addMediaGalleryComponents(mediaAttachment);
}
oh I had assumed you were doing a different silly thing, since frankly, this is also a little silly
again, at this point, I'm not sure why you're using the builder at all
but returning to the issue at hand
again, the issue stems from reusing the component data
in your original message, it'd be this line await message.edit({ components: [suggestionContainer, disabledButton] });
you'll need to recreate the component manually
Are there any guides or examples for the recent update on components v2?
can I not use client.rest to register my slash commands?
im getting Expected token to be set for this request, but none was present
no guide yet, but the announcement #announcements message came with a code example
not before you logged in
im getting the error after login...
and the whole reason for using rest for it is to have a separate script, not run it every time your bot starts
show your code and error
but if you really insist on doing it with your client you can just use client.application.commands.set() instead of raw rest
here's logs, code will be available in a minute
Loading all commands
Command loaded: counter
Command loaded: ping
Logged in as deniz.blue#1664 !
Command loaded: counter
Error while publishing commands Error: Expected token to be set for this request, but none was present
at _REST.resolveRequest (C:\Users\dennis\source\Repos\TheAlan404\seawork\node_modules\.pnpm\@discordjs+rest@2.5.0\node_modules\@discordjs\rest\src\lib\REST.ts:313:11)
that's missing most of the error stacktrace. especially the interesting part
dev.ts -> publish.ts
exporting your client is a bad idea
rest of stacktrace
at _REST.queueRequest (C:\Users\dennis\source\Repos\TheAlan404\seawork\node_modules\.pnpm\@discordjs+rest@2.5.0\node_modules\@discordjs\rest\src\lib\REST.ts:255:44)
at _REST.request (C:\Users\dennis\source\Repos\TheAlan404\seawork\node_modules\.pnpm\@discordjs+rest@2.5.0\node_modules\@discordjs\rest\src\lib\REST.ts:210:31)
at _REST.put (C:\Users\dennis\source\Repos\TheAlan404\seawork\node_modules\.pnpm\@discordjs+rest@2.5.0\node_modules\@discordjs\rest\src\lib\REST.ts:191:15)
at publishCommands (C:\Users\dennis\source\Repos\TheAlan404\seawork\framework\commands\publish\publish.ts:17:27)
at devPublishCommands (C:\Users\dennis\source\Repos\TheAlan404\seawork\framework\commands\publish\dev.ts:30:15)
at Store.<anonymous> (C:\Users\dennis\source\Repos\TheAlan404\seawork\framework\commands\publish\dev.ts:9:5)
at Store.emit (node:events:519:35)
at addCommand (C:\Users\dennis\source\Repos\TheAlan404\seawork\framework\commands\store\store.ts:26:18)
b\REST.ts:191:15)
at publishCommands (C:\Users\dennis\source\Repos\TheAlan404\seawork\framework\commands\publish\publish.ts:17:27)
at devPublishCommands (C:\Users\dennis\source\Repos\TheAlan404\seawork\framework\commands\publish\dev.ts:30:15)
at Store.<anonymous> (C:\Users\dennis\source\Repos\TheAlan404\seawork\framework\commands\publish\dev.ts:9:5)
at Store.emit (node:events:519:35)
at addCommand (C:\Users\dennis\source\Repos\TheAlan404\seawork\framework\commands\store\store.ts:26:18)
at Store.emit (node:events:519:35)
at addCommand (C:\Users\dennis\source\Repos\TheAlan404\seawork\framework\commands\store\store.ts:26:18)
at <anonymous> (C:\Users\dennis\source\Repos\TheAlan404\seawork\framework\commands\store\load.ts:27:19)
had to be something similar to the embeds author in the container :(
and as qjuh said, the whole reason REST is used is because its meant to be a separate file
is it?
yes
- you dont need to redeploy your commands every time you start your bot
hmm okay
its some HMR stuff
it does some cache and checks to not re-deploy if it hasnt changed anyway
I can't tell if you're asking or just lamenting, but if you're asking the answer is unfortunately no
Hi! For some reason my bot emojis don't work with components v2, was that support removed and do I need to use app emojis now? Or did I make a mistake somewhere
wdym by dont work
like they don't display
im lamenting
then please take it elsewhere
this channel is for if you need help
unfortunately
okay nevermind, they don't seem to work at all so that's my mistake lol
it looks like you redeploy with every single command added to your store. not once when you have all your commands loaded
so it should definitely not be done that way but as a separate thing you do once when things changed
Well it's just doesn't contain raw guild from the union
(async () => await commands.syncCommands())();
^
TypeError: client.on(...) is not a function
``` whar
Code:
new ContainerBuilder()
.addSectionComponents([
new TextDisplayBuilder().setContent(
[
`### ${emojis.globe} Original Message`,
message.content,
].join("\n")
),
new ThumbnailBuilder().setURL(emojiURL),
])
Error:
ExpectedConstraintError > s.array(T).lengthGreaterThanOrEqual()
Invalid Array length
Expected: expected.length >= 1
Received:
| []
Isn't this how we use section component?
sounds like you're missing a semicolon after a <Client>.on() call
but having Non-Guild-Interactions and CachedGuildInteractions on the same type without RawGuild still doesn't seem like a useful idea to me. you'd still have to discern them, which is when you'd call inCachedGuild() typeguard. and thus excluding the raw guild was useless
ffs, why is it so random to wherever i should put my semi colons
no, addSectionComponents expects to receive a section component
you'll want to add the text display and thumbnail to that section component
@shadow pier
Oh, I thought it accepts without component lol
for good practice you should put them at the end of every statement. use a linter/formatter to help you with that
to elaborate, since whitespace is ignored, your code reads like this client.on(...)(async () => ...)(); without the semicolon in between
yea im already fixing it lol
gonna scrap the auto deploy for now and stick to script
ty
When Using Component V2, How Can I Make the Embed Behind It Transparent?
@rose eagle
What is the max character that a container/message(4000+) can have?
All containers have different limit of chars like embeds or it is still applied as "message"
so what's the issue?
just dont use "ContainerBuilder()"
the sum of them can't exceed the 4000
Oh thank you, I finally solved it
so it 2 containers in a message still can't exceed 4000 char?
yes
f
can we bypass that with embeds?
How I can disable buttons in container?
interaction.message.components.forEach(row => row.components.forEach(component => {
if (component.data.type === ComponentType.Section && component.accessory.type === ComponentType.Button) {
component.accessory.data.disabled = true
}
if (component.data.type === ComponentType.ActionRow) {
component.components.forEach(component => {
component.data.disabled = true
})
}
}))
await interaction.update({ components: interaction.message.components })
TypeError: this.media.toJSON is not a function
Wait, how did you organize them in a container without container?
When I transferred, I put the section in the Components.
you wrote each of them in components: [...] ?
oh so it is all inside a section
Components: [Section1, Section2]
thanks
well your error is caused by a bug (to be fixed here), but I also wouldn't recommend modifying the existing component data
use the builders or recreate the objects
how can i create a handler for interaction commands?
guide suggestion for @agile nest:
Creating Your Bot: Command handling
read more
this is for buttons too?
I mean not if you just copy paste it, but you can use similar logic for components, yes
all interactions are received by the same event, and therefore you can delegate work to command/component handling from there
guide suggestion for @agile nest:
Message Components: Component interactions - The Client#interactionCreate event
read more
oh i see isButton(), but im supposed to put this code in every single file i create?
ohhh its isChatInputCommand
not if you only have one interactionCreate listener
which you only should have one
OH i finally get it
interactionCreate just executes the button code
do i just put same code for button handler
like in slash command
again, you can use similar logic, but components don't have names
and it really depends on how you've implemented the button interaction handler
thats what im trying to do right now and i dont know how
if you're having trouble
- reading files in a directory
- storing those in some data structure (likely a
Collection) - and calling the appropriate function upon receiving an interaction with a matching
<ButtonInteraction>.customId
that sounds like you should share what you have so far in #1081585952654360687
Did they remove timestamps (the one from embeds) with components v2?
the new components aren't actually embeds, so I wouldn't say they removed timestamps
ok, rephrase: they didn't implement timestamps into this new stuff they want you to use?
i think i found what i need, but maybe you have guide for making button responses?
correct, but you're also free to use a unix timestamp in a text display at the bottom of a container
else if (commandName === 'shop') {
const embed = new EmbedBuilder()
.setTitle('🛍️ Hogwarts Shop')
.setColor('Purple')
.setFooter({ text: '⚡ Buttons expire in 2 minutes.' })
.setDescription('Select a category below to browse magical items!');
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId('wands')
.setLabel('Wands')
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId('animals')
.setLabel('Animals')
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId('artifacts')
.setLabel('Artifacts')
.setStyle(ButtonStyle.Primary)
);
await interaction.deferReply({ ephemeral: false });
await interaction.editReply({
embeds: [embed],
components: [row]
});
const shopMessage = await interaction.fetchReply(); // <== here define shopMessage only once
setTimeout(async () => {
try {
const disabledRow = new ActionRowBuilder().addComponents(
row.components.map(button =>
ButtonBuilder.from(button).setDisabled(true)
)
);
await shopMessage.edit({
embeds: [embed],
components: [disabledRow]
});
console.log('Buttons disabled after 2 minutes.');
} catch (error) {
console.error('Failed to disable buttons:', error);
}
}, 120_000);
}
scroll up on the previously linked guide
why are the buttons not disabled after 2 minutes ( i have used gpt in between for correcting it)
Riight.. Thanks 👍🏿
the one you sent is button response handler, not response itself no?
that's why you should scroll up to the Responding to component interactions section
If a user doesn't have read permission for a channel, could he still stand Component Interactions? Like: Do I have to double check for permissions, or can component interactions only be send if the message with the components is visible for the user. Sorry for that horrible phrasing lol.
tag suggestion for @slate light:
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
interactions are designed such that the bot doesn't even need to be a user in the server, so they don't rely on permissions at all
if you receive an interaction, you can respond to it
though of course further actions such as <Interaction>.channel.send() will rely on permissions
module.exports = {
async execute(interaction) {
if (!interaction.component.customId == "modules_buttons_disable") return;
interaction.reply("bye")
}
}
``` is that good enough to work
have you tried it?
That's not really what I mean. What I mean is, if a user with no permission to a channel can send interactions to the bot, even though they have no access to the message containing the component. I am unsure if there is a way a user can just send an api request containing the custom id, to bypass it.
oh, no they shouldn't be able to
users can get access to customIds on messages they can see though, so don't store secrets there
after trying it : it doesn't enter the timeout section
in new components builder i can put 2 texts next to each other? similar to embedFields (inline)?
No, but is it correct
they tried to tell you to first try it
awesome, thank you.
.
nope
:/
also we don't have control over what components discord has
We are not Discord, just some nerds who develop Discord bots!
- /report appeals and age updates
- /howtoreport reports (harassment/hacking/spam/abuse)
- /support anything Discord related
- /billing payment/nitro
- /feedback feedback/feature requests
something i wanted to avoid, but as its stored in the message i can just grab the values and rebuild it? i have been overcomplicating this in my head and its annoyed me 
Anyone know what this error means and where it could be coming from?
DiscordAPIError[50035]: Invalid Form Body components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
if you're trying to use components v2 you need to send IsComponentsV2 message flag as well
Ohh
that's what I was telling you to do, yes
at least until the fix goes through
anyone please?
i just need to know where the code is stuck it should go inside timeout
is there a way i can use editReply and put a content value while using the IsComponentV2 MessageFlag?
no, you can't use content and v2 components
shucks
just put a TextDisplay as top level component. Behaves the same
thats up to you to figure out
place console logs to see where it stops
just a question, shouldnt this be already assumed?
or is it to prevent problems with embeds or older code?
Well i know, but i cant understand how do i get "current" button in the handler he sent me, in slash command one its const command = interaction.client... how in buttons?
it is for backwards compatibility. as you can't pass content, embeds, poll or stickers when using that flag
python experience does not help me here
so it will eventually be removed right?
in next updates
just think of adding ; in js as the same way as adding correct indentation in python
you should do it
so blah blah message.components[0].find(x)? ive not done this method for a while
"eventually" maybe. But API v6 was also meant to eventually be discontinued and still is around

my ; is mapped badly, its on the top right of the keyboard, which makes it hard to access
The IS_COMPONENTS_V2 is part of the feature and will exist forever after release.
from discord
and you might not always want to use components v2
if it were a full replacement then it could make sense to eventually assume it
but it isn't