MESSAGE_CONTENT_TYPE DIscord.js 嵌入
MESSAGE_CONTENT_TYPE DIscord.js embed
代码:
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')
}
},
}
错误:
RangeError [MESSAGE_CONTENT_TYPE]: 消息内容必须是非空字符串。
机器人应该在命令 !embed @tag JSON 中发送一个嵌入,但是当我发送 json 时,我收到一个错误。我的json:
{ "title": "嵌入", "description": "测试", "color": "0x00ff00" }
如果您使用的是 V13,这里是发送嵌入的方式
send({ content: 'Text', embeds: [embed] });
代码:
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')
}
},
}
错误: RangeError [MESSAGE_CONTENT_TYPE]: 消息内容必须是非空字符串。 机器人应该在命令 !embed @tag JSON 中发送一个嵌入,但是当我发送 json 时,我收到一个错误。我的json: { "title": "嵌入", "description": "测试", "color": "0x00ff00" }
如果您使用的是 V13,这里是发送嵌入的方式
send({ content: 'Text', embeds: [embed] });