Discord bot stream notification setup help

Need Help Creating Stream Alert Bot

I want to build a Discord bot using discord.py that sends notifications to my server whenever I start streaming. I’m not sure about the best approach to detect when streaming begins.

I tried monitoring voice state changes but I’m having trouble with the logic. The bot should automatically post a message in a specific channel when my stream goes live.

Has anyone implemented something similar? What’s the most reliable way to track streaming status changes?

@client.event
async def on_voice_update(user, before, after):
    if before.channel and after.channel:
        if before.self_streaming != after.self_streaming:
            print("Streaming status changed!")

Any guidance would be really appreciated!

Had this exact issue a few months ago. Discord’s voice state method is pretty unreliable - it fires multiple events back-to-back sometimes. I fixed it by adding a cooldown to prevent duplicate notifications. Make sure you’re checking before.self_stream and after.self_stream like mentioned above. Store your last notification timestamp somewhere so you don’t spam users. One gotcha - your bot has to be in the same server or voice state events won’t trigger. If it’s still acting up, you could poll Discord’s API directly for streaming status, but that’s way more complicated and you’ll hit rate limits.

Voice state approach works, but you’ve got to handle None channels properly. I built something similar last year - checking before.self_stream vs after.self_stream (not self_streaming) was way more reliable. Your code’s gonna break when people join/leave voice channels because you’re not checking for None values first. Also filter for the specific user ID you want, or the bot will spam notifications for everyone streaming on your server. Pro tip: add a small delay before sending notifications. Discord loves firing multiple voice state updates when someone starts streaming.