【问题标题】:Twitch discord.py botTwitch discord.py 机器人
【发布时间】:2021-05-03 04:00:47
【问题描述】:

您好,我正在尝试使用 discord.py 编写一个机器人,以便在我进入直播时通知我的不和谐服务器,但我不知道该怎么做。谁能帮帮我?

谢谢

@bot.event
async def on_voice_state_update(member, prev, cur):
    if prev.channel and cur.channel:  
         if prev.self_stream != cur.self_stream:
            print("User's self-stream updated!")

【问题讨论】:

  • stackoverflow.com/help/how-to-ask 对如何提问有很好的指导。你试过什么代码?让我们看看你想要什么。
  • discord.py 文档有你要找的东西discord.Member.activity
  • @PaulBrennan 这是我的代码,但它不起作用
  • @jjoy 我不明白我需要做什么,你能帮我吗
  • 你可以使用on_voice_state_update,而不是on_member_update

标签: python discord.py twitch


【解决方案1】:

这可能有效:

YourID = #Enter your id here

@bot.event
async def on_voice_state_update(member, prev, cur):
    if cur.self_stream and bool(cur.channel) and member.id == YourID:
        print ("User's self stream updated")

我希望这可能会有所帮助。

【讨论】:

  • 您究竟从哪里获得process_commands 中的message 变量?你为什么还要使用它?这不是on_message 事件
猜你喜欢
  • 2018-12-31
  • 1970-01-01
  • 2017-12-26
  • 1970-01-01
  • 2021-10-07
  • 2021-03-29
  • 2021-10-20
  • 2021-05-25
  • 1970-01-01
相关资源
最近更新 更多