discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.38k stars 3.97k forks source link

Sending an APIEmbed inside interaction with a description object #8317

Closed TheLegendarySpark closed 2 years ago

TheLegendarySpark commented 2 years ago

Which package is this bug report for?

discord.js

Issue description

  1. Run any kind of interaction, for instance, ChatInputCommandInteraction
  2. Inside the interaction runner, run this code
    interaction.reply({
    embeds: [
            new EmbedBuilder()
                .setDescription(`test embed. this works?`)
                .toJSON()
        ]
    })
  3. Error occurs
    DiscordAPIError[50035]: Invalid Form Body
    discordbot  | data.embeds[0].description[BASE_TYPE_REQUIRED]: This field is required
    discordbot  |     at SequentialHandler.runRequest (/usr/elixardiscord/node_modules/@discordjs/rest/dist/index.js:748:15)
    discordbot  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    discordbot  |     at async SequentialHandler.queueRequest (/usr/elixardiscord/node_modules/@discordjs/rest/dist/index.js:560:14)
    discordbot  |     at async REST.request (/usr/elixardiscord/node_modules/@discordjs/rest/dist/index.js:1000:22)
    discordbot  |     at async ChatInputCommandInteraction.reply (/usr/elixardiscord/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:110:5) {
    discordbot  |   rawError: {
    discordbot  |     code: 50035,
    discordbot  |     errors: {
    discordbot  |       data: { embeds: { '0': { description: [Object] } } }
    discordbot  |     },
    discordbot  |     message: 'Invalid Form Body'
    discordbot  |   },
    discordbot  |   code: 50035,
    discordbot  |   status: 400,
    discordbot  |   method: 'POST',
    discordbot  |   url: 'https://discord.com/api/v10/interactions/****/******/callback',
    discordbot  |   requestBody: {
    discordbot  |     files: [],
    discordbot  |     json: {
    discordbot  |       type: 4,
    discordbot  |       data: {
    discordbot  |         content: undefined,
    discordbot  |         tts: false,
    discordbot  |         nonce: undefined,
    discordbot  |         embeds: [ { data: [Object] } ],
    discordbot  |         components: undefined,
    discordbot  |         username: undefined,
    discordbot  |         avatar_url: undefined,
    discordbot  |         allowed_mentions: undefined,
    discordbot  |         flags: undefined,
    discordbot  |         message_reference: undefined,
    discordbot  |         attachments: undefined,
    discordbot  |         sticker_ids: undefined
    discordbot  |       }
    discordbot  |     }
    discordbot  |   }
    discordbot  | }

Code sample

No response

Package version

14.0.1

Node.js version

16.9+

Operating system

No response

Priority this issue should have

High (immediate attention needed)

Which partials do you have configured?

User, Channel, GuildMember, Message, Reaction, GuildScheduledEvent, ThreadMember

Which gateway intents are you subscribing to?

Guilds

I have tested this issue on a development release

No response

Jiralite commented 2 years ago

I cannot reproduce this through an interaction or sending a message in a channel on discord.js version 14.0.2.

image image