discordjs / discord.js

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

embeds: this.options.embeds?.map(embed => new MessageEmbed(embed).toJSON() #6356

Closed NotTimIsReal closed 3 years ago

NotTimIsReal commented 3 years ago

Hello when I try to make my bot send embeds it sends the embed but the next embed doesn't get sent and I get this error,

home/ubuntu/bbarevamp/node_modules/discord.js/src/structures/MessagePayload.js:184
      embeds: this.options.embeds?.map(embed => new MessageEmbed(embed).toJSON()),
                                   ^

TypeError: this.options.embeds?.map is not a function
    at MessagePayload.resolveData (/home/ubuntu/bbarevamp/node_modules/discord.js/src/structures/MessagePayload.js:184:36)
    at TextChannel.send (/home/ubuntu/bbarevamp/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:167:61)
    at module.exports (/home/ubuntu/bbarevamp/events/guild/message.js:70:36)
    at Client.emit (node:events:377:35)
    at MessageCreateAction.handle (/home/ubuntu/bbarevamp/node_modules/discord.js/src/client/actions/MessageCreate.js:31:18)
    at Object.module.exports [as MESSAGE_CREATE] (/home/ubuntu/bbarevamp/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (/home/ubuntu/bbarevamp/node_modules/discord.js/src/client/websocket/WebSocketManager.js:345:31)
    at WebSocketShard.onPacket (/home/ubuntu/bbarevamp/node_modules/discord.js/src/client/websocket/WebSocketShard.js:443:22)
    at WebSocketShard.onMessage (/home/ubuntu/bbarevamp/node_modules/discord.js/src/client/websocket/WebSocketShard.js:300:10)
    at WebSocket.onMessage (/home/ubuntu/bbarevamp/node_modules/ws/lib/event-target.js:132:16)
    at WebSocket.emit (node:events:365:28)
    at Receiver.receiverOnMessage (/home/ubuntu/bbarevamp/node_modules/ws/lib/websocket.js:970:20)
    at Receiver.emit (node:events:365:28)
    at Receiver.dataMessage (/home/ubuntu/bbarevamp/node_modules/ws/lib/receiver.js:517:14)
    at Receiver.getData (/home/ubuntu/bbarevamp/node_modules/ws/lib/receiver.js:435:17)
    at Receiver.startLoop (/home/ubuntu/bbarevamp/node_modules/ws/lib/receiver.js:143:22)

I am using Discord.js V13 and Node 16.6.0.

Code:

https://pastebin.com/hzqww4Lg

The import from exports imports a function like this

function reply(content, mention, message){
    message.reply({ content:content, allowedMentions: { repliedUser: mention }})
  }
monbrey commented 3 years ago

Embeds are sent as an array: embeds: [embed1, embed2, ..., embed10]

The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue – you will get redirected there anyway.

NotTimIsReal commented 3 years ago

Embeds are sent as an array: embeds: [embed1, embed2, ..., embed10]

The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue – you will get redirected there anyway.

I have all my commands with embeds are sent like this

monbrey commented 3 years ago

The error comes from line 70 of /home/ubuntu/bbarevamp/events/guild/message.js:70:36 - on that line it seems you arent.

NotTimIsReal commented 3 years ago

That line is like message.channel.send(embeds:new Discord.MessageEmbed) is there a way I can keep it that way without entirely needing to make a new variable?

NotTimIsReal commented 3 years ago

if there isn't I will fix up my code and close the issue

monbrey commented 3 years ago

Just put it in an array. Issue should have been closed and taken to the server already.

NotTimIsReal commented 3 years ago

Thank you for the help anyways