[Python] Discord Py using on_voice_state_update

Discussão em 'Python' iniciado por Stack, Dezembro 14, 2024.

  1. Stack

    Stack Membro Participativo

    I am current trying to make a bot that joins VC when a certain person joins and then leaves VC when they leave.

    I want it so the bot is ONLY in VC when the specific user is in VC, and then the bot will instantly leave when said user disconnects.

    The problem im having is trying to figure out how to make the bot leave.

    @bot.event

    async def on_voice_state_update(member, before, after): targetID = bot.get_user(USERID)

    if after.channel is not None and member.id == targetID.id:
    await member.voice.channel.connect()


    This is what I use to make the bot join and that seems to work no problem, but no matter what I try, I cannot figure out how to make the bot leave once the same user leaves VC.

    Any help is appreciated, thank you.

    Any time i've been able to make the bot leave, it leaves the instant is joins, I know the reason for this but I just cant figure out how to prevent it, or do it another way to make the bot only leave when the user leaves.

    Continue reading...

Compartilhe esta Página