I have a Discord bot and there is a problem with the command named privacy policy in this bot, I asked a lot of people and they said they don't know.
Node.js version: 16.13.2 Discord.js version: 13.6.0
MAİN
client.commands = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
COMMAND
module.exports = {
name: 'gizlilik',
description: 'gizlilik politikası',
execute(message, args) {
const Discord = require("discord.js")
const gizlilik = new Discord.MessageEmbed()
.setTitle("Hextro Gizlilik Politikası")
.setDescription("Gizlilik Politikasına aşağıdaki butondan ulaşabilirsiniz.")
.setColor("RANDOM")
const buton = new Discord.MessageButton()
.setLabel("Politika")
.setStyle("url")
.setURL("https://github.com/Husum0/Hextro-Gizlilik-Politikasi/blob/main/gizlilik.md");
let row = new Discord.MessageActionRow()
.addComponents(buton)
message.channel.send({ content: 'Pong!', embeds: [gizlilik], components: [row] });
},
};
ERROR
Unhandled promise rejection: DiscordAPIError: Invalid Form Body components[0].components[0].style: This field is required at RequestHandler.execute (C:\Users\Administrator\Desktop\hexiye\node_modules\discord.js\src\rest\RequestHandler.js:350:13) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async RequestHandler.push (C:\Users\Administrator\Desktop\hexiye\node_modules\discord.js\src\rest\RequestHandler.js:51:14) at async TextChannel.send (C:\Users\Administrator\Desktop\hexiye\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:175:15) { method: 'post', path: '/channels/931267478292680769/messages', code: 50035, httpStatus: 400, requestData: { json: { content: 'Pong!', tts: false, nonce: undefined, embeds: [Array], components: [Array], username: undefined, avatar_url: undefined, allowed_mentions: undefined, flags: undefined, message_reference: undefined, attachments: undefined, sticker_ids: undefined }, files: [] } }
url is not a valid style to set your embed to, instead, it should be LINK - see discord.js documentation here.
your command should end up looking like this:
module.exports = {
name: 'gizlilik',
description: 'gizlilik politikası',
execute(message, args) {
const Discord = require('discord.js');
const gizlilik = new Discord.MessageEmbed()
.setTitle('Hextro Gizlilik Politikası')
.setDescription('Gizlilik Politikasına aşağıdaki butondan ulaşabilirsiniz.')
.setColor('RANDOM');
const buton = new Discord.MessageButton()
.setLabel('Politika')
.setStyle('LINK')
.setURL('https://github.com/Husum0/Hextro-Gizlilik-Politikasi/blob/main/gizlilik.md');
let row = new Discord.MessageActionRow().addComponents(buton);
message.channel.send({ content: 'Pong!', embeds: [gizlilik], components: [row] });
}
};
For when it says you have invalid for of body ,,, all that means is to update your app Go to you appstore look for discord and update the app!