[英]Can I somehow make my bot send a message in a specific text channel when it goes offline?
I already have a function which allows the bot to send a message when it is online, but if the bot is offline I want it to send a message saying that it is now offline so that people can check the activity of the bot.我已经有一个 function 允许机器人在线时发送消息,但如果机器人离线,我希望它发送消息说它现在离线,以便人们可以检查机器人的活动。
No you cannot because there is no way for the program to know before the bot goes offline, unless you specifically make it go offline yourself, why can they not just check if the bot has an online/invisible status?不,你不能,因为在机器人下线之前程序无法知道,除非你专门让它 go 自己下线,为什么他们不能只检查机器人是否有在线/不可见状态?
Another option is to do a ping
command, if the bot responds, its online if not its offline:另一种选择是执行
ping
命令,如果机器人响应,则其在线(如果不是离线):
client.on("message", msg => {
if(msg.content === "!ping") {
return msg.reply("Online!");
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.