-1

Hello I'm trying to code a bot with discord.py to notify my discord server when I'm in stream, but I don't know how to do it. Can anyone help me?

Thanks

@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!")
Fireye
  • 5
  • 4
Dipo3
  • 33
  • 5
  • https://stackoverflow.com/help/how-to-ask has a great guide on how to ask questions. What code have you tried? Let us see what you want. – Paul Brennan Jan 29 '21 at 08:30
  • the discord.py documentation has what you're looking for [discord.Member.activity](https://discordpy.readthedocs.io/en/latest/api.html?highlight=member#discord.Member.activities) – jjoy Jan 29 '21 at 08:33
  • @PaulBrennan this is my code but It dont work – Dipo3 Jan 29 '21 at 08:48
  • @jjoy I don't understand what I have to do with that can you help me – Dipo3 Jan 29 '21 at 08:49
  • Instead of using `on_voice_state_update`, you can use [`on_member_update`](https://discordpy.readthedocs.io/en/latest/api.html?highlight=on_member#discord.on_member_update). – MrSpaar Jan 29 '21 at 08:56

1 Answers1

0

This might work:

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")

I hope this may be of help.

jjoy
  • 162
  • 1
  • 10
  • From where are you exactly getting the `message` variable in `process_commands`? And why are you even using it? It's not the `on_message` event – Łukasz Kwieciński Jan 29 '21 at 13:32