Home > database >  Why am I getting an "invalid Form Body" error on my Discord.js welcome message?
Why am I getting an "invalid Form Body" error on my Discord.js welcome message?

Time:12-11

I tried to make a welcome message but I get an error. Does anyone know how to fix this error?

code:

const client = new Client({
    allowedMentions: { parse: ["users", "roles", "reaction"]},
    intents: [
        Intents.FLAGS.GUILDS,
        Intents.FLAGS.GUILD_MESSAGES,
        Intents.FLAGS.GUILD_MEMBERS,
        Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
        Intents.FLAGS.GUILD_WEBHOOKS,
        Intents.FLAGS.GUILD_VOICE_STATES,
        Intents.FLAGS.GUILD_INVITES,
        Intents.FLAGS.GUILD_BANS,
        Intents.FLAGS.GUILD_PRESENCES,
    ]
})

    client.on(`guildMemberAdd` , (member, guild) =>{

    const arten = [
       `Halli Hallo <@!${member.id}>, Willkommen auf dem Teckles.net Server <:T_:788703077184045076>`,
        `Willkommen <@!${member.id}>, wir hoffen du hast viel Spaß auf Teckles.net <:T_:788703077184045076>`,
        `<@!${member.id}> hat sich dazu entschieden eine Runde mit uns zu spielen <:T_:788703077184045076>`,
    ]
      
    const welcomemessage = `${arten[Math.floor(Math.random() * arten.length)]}`

    let roles = ['781625371682275360', `811351035209056307`, '811351288146821161', '811351128372936704', '828942314046357535']

    for (number = 0; number < roles.length; number  ) {

        let role = member.guild.roles.cache.find(r => r.id === roles[number])

        member.roles.add(role)

    }
    const channel = client.channels.cache.find(channel => channel.id === '916730472950792252')

    channel.send({ content: welcomemessage})
    
})

error:

DiscordAPIError: Invalid Form Body
allowed_mentions.parse[2]: Value must be one of ('roles', 'users', 'everyone').
    at RequestHandler.execute (F:\Programmieren\Teckles\node_modules\discord.js\src\rest\RequestHandler.js:298:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (F:\Programmieren\Teckles\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
    at async TextChannel.send (F:\Programmieren\Teckles\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:172:15) {
  method: 'post',
  path: '/channels/916730472950792252/messages',
  code: 50035,
  httpStatus: 400,
  requestData: {
    json: {
      content: 'Halli Hallo <@!777498801349853186>, Willkommen auf dem Teckles.net Server <:T_:788703077184045076>',
      tts: false,
      nonce: undefined,
      embeds: undefined,
      components: undefined,
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: {
        parse: [ 'users', 'roles', 'reaction' ],
        replied_user: undefined
      },
      flags: undefined,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined
    },
    files: []
  }
}

CodePudding user response:

MessageMentionTypes can only be roles, users or everyone. reaction is not compatible with MessageMentionTypes. Remove reaction from client.allowedMentions.parse.

  • Related