简体   繁体   中英

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.

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?

Another option is to do a ping command, if the bot responds, its online if not its offline:

client.on("message", msg => {
   if(msg.content === "!ping") {
     return msg.reply("Online!");
   }
});

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