【发布时间】:2021-04-04 05:47:12
【问题描述】:
现在我有一个事件可以跟踪某个机器人何时下线。 (我托管两个机器人)这是我目前的代码,我没有设法获得任何输出或任何回溯。有什么我想念的吗? (我已经开启了意图!)
@commands.Cog.listener()
async def on_member_update(self, before, after):
if before.id == 777361919211732993:
if after.status == discord.Status.offline:
channel = self.bot.get_channel(792485617954586634)
timestamp = datetime.now()
embed = discord.Embed(title = "⚠️ PortalBot is offline!", description = "Recorded Downtime (start): " + str(timestamp.strftime("%H:%M:%S")) , color = 0xf03224)
embed.add_field(name = "Restart Link", value = "-")
await channel.send(embed = embed)
任何提示或建议都会有所帮助!
【问题讨论】:
-
乍一看,您的代码在我看来还不错。或者在你定义它之后尝试添加
print(channel),看看它是否无法访问它? -
id是bot id?
标签: python discord.py