我有一个在discord.py上构建的机器人,我想看看如何检测用户何时更改了状态(在线、空闲等),并在用户更改状态时在桌面上给我一个推送通知
以下是我迄今为止所做的工作:
@client.command()
async def status(ctx, user: discord.Member):
status = discord.Embed (
color = discord.Color.blue()
)
stat = user.status
toaster = ToastNotifier()
toaster.show_toast(f"Status for {user}", f"currently: {stat}", duration=10)
status.add_field(name=f"Status for {user}", value=f"currently: {stat}")
await ctx.send(embed=status)
我试着在其他帖子上查看如何检查变量何时更改,但到目前为止还没有看到任何成功。我在这篇文章中尝试了最重要的答案:How to check if a variable's value has changed并看到了奇怪的结果,无可否认,我不知道如何在我的代码中实现它,因为我的代码与这里显示的非常不同
有什么简单的方法可以做到这一点吗
使用on_member_update(before,after),它将在用户每次更改以下内容时运行
因为你对状态感兴趣
相关问题 更多 >
编程相关推荐