简体   繁体   中英

RangeError [MESSAGE_CONTENT_TYPE]: Message content must be a non-empty string. (discord.js v13)

So I am basically making a command that fetches a website and sends a message. But I get this error: RangeError [MESSAGE_CONTENT_TYPE]: Message content must be a non-empty string. and i followed axios and discord.js v13 docs.

Any help?

const Discord = require('discord.js')
const { MessageEmbed } = require('discord.js')
var webshot = require('node-webshot');
const axios = require('axios')
module.exports = {
    name: "status",
    description: "",
    async execute(message, args, client) {
         
        let argfor = args.slice(` `)
        if(!argfor) { 
            message.channel.send("No username input") 
        } else {
        message.channel.send("Waiting for response from swordbattle.io")
        let res = await axios.get('http://swordbattle.io/api/serverinfo');

        let data = res.data;
        message.channel.send({ content: data})
      }
    
    }
}

Help from jabaa

Had to serialize it.

const { MessageEmbed } = require('discord.js')
var webshot = require('node-webshot');
const axios = require('axios')
module.exports = {
    name: "status",
    description: "",
    async execute(message, args, client) {
         
        let argfor = args.slice(` `)
        if(!argfor) { 
            message.channel.send("No username input") 
        } else {
        message.channel.send("Waiting for response from swordbattle.io")
        let res = await axios.get('http://swordbattle.io/api/serverinfo');

        let data = res.data;
        const lma = JSON.stringify({ content: data})
        message.channel.send({ content: lma})
      }
    
    }
}```

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM