#๐Ÿ”’ manual admin disconnect event with discord.py

4 messages ยท Page 1 of 1 (latest)

lavish gull
#

i made a tts bot that joins the voice chat. i create an object with some logic when using a slash command, and then i delete it and create a new one when using an unfollow command, or when disconnecting the bot manually.
im using on_voice_state_update for the disconnect part, like this:

@client.event
async def on_voice_state_update(member: discord.Member, before: discord.VoiceState, after: discord.VoiceState):
    if before.channel == after.channel:
        return

    if member == client.user:
        # the bot was disconnected, reset everything
        if after.channel is None:
            readers[member.guild] = GuildReader(member.guild)

    # more stuff...

the thing is, apparently, discord reconnects all users every two hours or so, for some reason, and then that gets called, the object gets recreated, and the tts no longer works.
so, is there a way to detect when the bot was disconnected manually, specifically because of an admin disconnect? like with the right click menu, so i dont recreate the object in any other case

opal jettyBOT
#

@lavish gull

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

opal jettyBOT
#

@lavish gull

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.