[英]Discord.js not sending embed message
I'm developing a discord bot with.js and I'm using minecraft-server-util.我正在使用.js 开发一个 discord 机器人,我正在使用 minecraft-server-util。 I believe there are several problems and you may correct me on them, but the main problem is that this code returns no embed or message with the status.我相信有几个问题,你可以纠正我,但主要问题是这段代码没有返回任何嵌入或带有状态的消息。
client.on('message', msg => {
const commandName = "javaserverstatus"
if (msg.content === prefix + commandName) {
const util = require('minecraft-server-util');
var serverinfo = null
util.status('play.hypixel.net') // port is default 25565
.then((response) => {
console.log(response);
serverinfo = response
})
.catch((error) => {
console.error(error);
const embed = new Discord.MessageEmbed()
.setTitle('Bot Command List')
.setColor(0xff0000)
.setDescription('IP:' + response.host);
msg.channel.send(embed);
});
}
});
It seems you just placed your embed in your error logger
and not in the .then(... )
statement.看来您只是将嵌入放在error logger
中,而不是放在.then(... )
语句中。 But with the minecraft-server-until
package, I don't know much about it, so if that wasn't the issue, here is the documentation on the package: https://www.npmjs.com/package/minecraft-server-util但是对于minecraft-server-until
package,我不太了解,所以如果这不是问题,这里是 package 上的文档: Z5E056C500A1C4B76A7110B50D服务器实用程序
Hope this helps you and have fun developing your Discord API!希望这对您有所帮助,并在开发您的 Discord API 时玩得开心!
client.on('message', message => {
if (message.content === `${prefix}javaserverstatus`) {
const util = require('minecraft-server-util');
var serverinfo = null
util.status('play.hypixel.net') // port is default 25565
.then((response) => {
console.log(response);
serverinfo = response;
const embed = new Discord.MessageEmbed()
.setTitle('Bot Command List')
.setColor(0xff0000)
.setDescription('IP:' + response.host);
message.channel.send(embed);
})
.catch((error) => {
console.error(error);
});
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.