#Problem making an embedded message with discord bot
9 messages · Page 1 of 1 (latest)
C:\Users\Bryan\Desktop\WG Manager\node_modules\discord.js\src\structures\MessagePayload.js:201
embeds: this.options.embeds?.map(embed =>
^
TypeError: this.options.embeds?.map is not a function
at MessagePayload.resolveBody (C:\Users\Bryan\Desktop\WG Manager\node_modules\discord.js\src\structures\MessagePayload.js:201:36)
at ChatInputCommandInteraction.reply (C:\Users\Bryan\Desktop\WG Manager\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:109:56)
at Object.run (C:\Users\Bryan\Desktop\WG Manager\Commandes\unban.js:45:81)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
const Discord = require("discord.js")
module.exports = {
name: "unban",
description: "Unban un membre",
permission: Discord.PermissionFlagsBits.BanMembers,
dm: false,
category: "Modération",
options: [
{
type: "user",
name: "utilisateur",
description: "L'utilisateur à débannir",
required: true,
autocomplete: false
}, {
type: "string",
name: "raison",
description: "La raison du débannissement",
required: false,
autocomplete: false
}
],
async run(bot, message, args) {
try {
let user = args.getUser("utilisateur")
const ErreurUnban = new Discord.EmbedBuilder()
.setTitle("Erreur Unban")
.setDescription(`Pas d'utilisateur!`)
.setColor("#0909bd")
if(!user) return message.reply({embeds: ErreurUnban})
let reason = args.getString("raison")
if(!reason) reason = "Pas de raison fournie."
const ErreurUnban2 = new Discord.EmbedBuilder()
.setTitle("Erreur Unban")
.setDescription(`Cet utilisateur n'est pas banni !`)
.setColor("#0909bd")
if(!user) return message.reply({embeds: ErreurUnban})
if(!(await message.guild.bans.fetch()).get(user.id)) return message.reply({embeds: ErreurUnban2})
try {await user.send(`Tu as été unban par ${message.user.tag} pour la raison : \`${reason}\``)} catch (err) {}
await message.reply(`${message.user} a unban ${user.tag} pour la raison : \`${reason}\``)
await message.guild.members.unban(user, reason)
} catch (err) {
return message.reply("Pas d'utilisateur")
}
}
}
Here is everything , i think i did a little bit of mess in the code
embeds: needs to be an array of embeds, you pass a single embed. So wrap it in []
hey thanks ! so it means i have to wrap the embed code with [] ?
You need to pass an array as embeds property, yes
i dont really understand
What part? If you know enough JS I don’t know what was unclear so please tell me