简体   繁体   English

RangeError [MESSAGE_CONTENT_TYPE]: 消息内容必须是非空字符串。 (discord.js v13)

[英]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.但我收到此错误: RangeError [MESSAGE_CONTENT_TYPE]: Message content must be a non-empty string. and i followed axios and discord.js v13 docs.我遵循了 axios 和 discord.js v13 文档。

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来自 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})
      }
    
    }
}```

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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