Skip to content

on_voice_state_update event: when bot changing the channel, it notifies about the bot leaving the channel #3106

@denisnumb

Description

@denisnumb

Summary

on_voice_state_update fires twice when the bot moves between voice channels

Reproduction Steps

  1. The bot connects to voice channel voice 1
  2. I manually move it to another voice channel voice 2
  3. Then I manually move it back to voice 1

Minimal Reproducible Code

@bot.event
async def on_voice_state_update(member: discord.Member, before: discord.VoiceState, after: discord.VoiceState):
    if before.channel and after.channel and before.channel != after.channel:
        print(f"{member.nick} entered another channel")
        return

    if before.channel and after.channel is None:
        print(f"{member.nick} has left the voice channel")

Expected Results

Bot entered another channel
Bot entered another channel

Actual Results

Bot entered another channel
Bot entered another channel
Bot has left the voice channel

Intents

All

System Information

- Python v3.10.10-final
- py-cord v2.7.1-final
- aiohttp v3.10.8
- system info: Windows 10 10.0.26200

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

The issue only occurs when interacting with a bot. If you move a regular user, everything works correctly.

Metadata

Metadata

Labels

unconfirmed bugA bug report that needs triagingvoiceRelated to the voice chat feature

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions