简体   繁体   English

我可以让我的机器人在离线时在特定的文本频道中发送消息吗?

[英]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.

相关问题 如何让我的 discord 机器人仅在用户开始输入特定频道时发送消息? - How can I make my discord bot only send a message if a user starts typing in a specific channel? (Discord.js) 我想在机器人离线之前在频道上发送一条消息 - (Discord.js) I wanna send a message on channel before the bot goes offline 如何让我的机器人在特定频道中发送消息,然后在一段时间后将其删除 - How do I make my bot send a message in a specific channel then delete it after a period of time 使不和谐机器人发送消息特定通道 - make discord bot to send message specific channel 如何让我的机器人向另一个频道发送消息? - How can I get my bot to send a message to another channel? 当特定用户玩特定游戏时,如何让我的不和谐机器人发送消息? - How do I make my discord bot send a message when a specific user plays a specific game? 我希望我的不和谐机器人向用户提供的文本房间发送随机消息 [按频道 ID 或频道名称] - I want my discord bot to send a random message to a text room given by user [by channel id or channel name] Discord.js bot 无法将消息发送到特定通道 - Discord.js bot can't send message to specific channel 如何找到机器人在特定频道中发送的消息? [discord.js] - How can I find a message send in a specific Channel from the bot? [discord.js] 如何让我的 discord 机器人回复包含特定字母/字符的消息? - How can I make my discord bot reply to a message when it contains a specific letter/character?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM