Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

MESSAGE_CONTENT_TYPE DIscord.js embed

code:

module.exports = {
    minArgs: 2,
    expectedArgs: '<Channel mention> <JSON>',
    callback: ({ message, args }) => {
        const targetChannel = message.mentions.channels.first()
        if (!targetChannel) {
            message.reply('Specify a channel to sent the embed in')
            return
        }

        args.shift()

        try {
          const json = JSON.parse(args.join(' '))
          const { text = '' } = json

          targetChannel.send(text, {
            embed: json,
            })
        } catch (error) {
            message.reply('Invalid JSON')  
        }
    },
}

error:
RangeError [MESSAGE_CONTENT_TYPE]: Message content must be a non-empty string.
The bot should send an embed at the command !embed @tag JSON, but when I send json, I get an error. My json:
{ "title": "Embed", "description": "Test", "color": "0x00ff00" }

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you are using V13 here is the way to send an embed

send({ content: 'Text', embeds:  });
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading