DiscordAPIError: Invalid Form Body

Hello, I am trying to make a discord bot say something to me when I do a certain cmd but it doesn’t work I’m able to get the bot online and everything but it just won’t send a response if you guys can help me I will appreciate it, I’ll copy and paste the code below. (without the discord bot token so i don’t get my bot taken :stuck_out_tongue:

const Discord = require(‘discord.js’);

const client = new Discord.Client({

allowedMentions: {

    parse: ['everyone', 'user',  'roles'],

    repliedUser: true

},

intents: [

    "GUILDS",

    "GUILD_MESSAGES",

    "GUILD_PRESENCES",

    "GUILD_MEMBERS",

    "GUILD_MESSAGE_REACTIONS",

],

})

client.on(‘ready’, () => {

console.log("i am ready to go")

})

client.on(“messageCreate”, async message => {

if(message.content === "!ping"){

    message.channel.send("Hello!");

}

if(message.content === "!your gay"){

    message.channel.send("wow that's not very nice!");

}

})

client.login(“blank for saftey”)

this is the error i get

C:\Users\Security\Desktop\afk dank memer\node_modules\discord.js\src\rest\RequestHandler.js:349
throw new DiscordAPIError(data, res.status, request);
^

DiscordAPIError: Invalid Form Body
allowed_mentions.parse[0]: Value must be one of (‘everyone’, ‘users’, ‘roles’).
at RequestHandler.execute (C:\Users\Security\Desktop\afk dank memer\node_modules\discord.js\src\rest\RequestHandler.js:349:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\Security\Desktop\afk dank memer\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
at async TextChannel.send (C:\Users\Security\Desktop\afk dank memer\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:172:15) {
method: ‘post’,
path: ‘/channels/905145117973839895/messages’,
code: 50035,
httpStatus: 400,
requestData: {
json: {
content: ‘Hello!’,
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: { parse: [ ‘everyone’, ‘user’, ‘roles’ ], replied_user: true },
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files:
}
}

It is most probably due to your use of strings in the intents array. They are flags not strings.

1 Like

oh okay thank you very much for this and sorry if I seem stupid I’m new to coding Discord bots and coding in general :laughing:

That is a common error that people make. Always a good idea to check the documentation.