Discord v2 components

Hello, I would like to know when the v2 components will be added to discord.js? And if there is currently an alternative to use them in JavaScript?
9 Replies
d.js toolkit
d.js toolkit4d ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
d.js docs
d.js docs4d ago
discord.js does not support features until they are officially documented. While there might be a way for these features to work, it can change at any time without any notice
&tokyo
&tokyoOP4d ago
ohh ok thank you for your response
&tokyo
&tokyoOP4d ago
But how? Is there unofficial documentation or something else, because I tried copying from https://discord.builders/ and I wasn't able to do it
discord.builders – Discord Embed Builder
Use new components in your Discord webhooks
Use new Discord components in messages for free and stylize your server however your want.
&tokyo
&tokyoOP4d ago
ah okk But actually, I know how to do it, but I still get the error: DiscordAPIError[50035]: Invalid Form Body components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,). with:
[
{
type: 17,
accent_color: 16711680,
spoiler: true,
components: [
{
type: 10,
content:
"Behind every alien, there's a confused emotional potato.",
},
{
type: 1,
components: [
{
type: 2,
style: 5,
label: 'Slow Goshawk',
emoji: null,
disabled: false,
url: 'https://google.com',
},
],
},
{
type: 14,
divider: true,
spacing: 1,
},
{
type: 10,
content:
'True wisdom comes from hugging a stranger during jealous times.',
},
{
type: 1,
components: [
{
type: 2,
style: 5,
label: 'Playful Starling',
emoji: null,
disabled: false,
url: 'https://google.com',
},
],
},
],
},
];
[
{
type: 17,
accent_color: 16711680,
spoiler: true,
components: [
{
type: 10,
content:
"Behind every alien, there's a confused emotional potato.",
},
{
type: 1,
components: [
{
type: 2,
style: 5,
label: 'Slow Goshawk',
emoji: null,
disabled: false,
url: 'https://google.com',
},
],
},
{
type: 14,
divider: true,
spacing: 1,
},
{
type: 10,
content:
'True wisdom comes from hugging a stranger during jealous times.',
},
{
type: 1,
components: [
{
type: 2,
style: 5,
label: 'Playful Starling',
emoji: null,
disabled: false,
url: 'https://google.com',
},
],
},
],
},
];
and:
import { REST, Routes } from 'discord.js';
import config from '../config';

const rest = new REST({ version: '10' }).setToken(config.clientToken);

export const sendJSONEmbed = async (
channelId: string,
components: Object,
content?: string,
) => {
try {
await rest.post(Routes.channelMessages(channelId), {
body: {
content: content ?? '',
components: components,
},
});
console.log('Message envoyé avec succès !');
} catch (error) {
console.error('Erreur lors de l\'envoi du message :', error);
}
};
import { REST, Routes } from 'discord.js';
import config from '../config';

const rest = new REST({ version: '10' }).setToken(config.clientToken);

export const sendJSONEmbed = async (
channelId: string,
components: Object,
content?: string,
) => {
try {
await rest.post(Routes.channelMessages(channelId), {
body: {
content: content ?? '',
components: components,
},
});
console.log('Message envoyé avec succès !');
} catch (error) {
console.error('Erreur lors de l\'envoi du message :', error);
}
};
is it: flags: 1 << 7 ? cause with it i get:
Erreur lors de l'envoi du message : DiscordAPIError[50035]: Invalid Form Body
components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
Erreur lors de l'envoi du message : DiscordAPIError[50035]: Invalid Form Body
components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,).
treble/luna
treble/luna4d ago
its 1 << 15
&tokyo
&tokyoOP4d ago
thank you!! it works And I just would like to know if its possible to put components like select menu in modals with the api? or others new things in modals that aren't documented yet
treble/luna
treble/luna4d ago
no
&tokyo
&tokyoOP4d ago
oh okk thank you for your responses!

Did you find this page helpful?