on god
on god

Reputation: 1

Discord.py doesn't update on member remove

I am making a discord bot that changes a voice channels' name when a user joins or leaves to the amount of members on the server. My issue is that when a user leaves, it doesn't update. Any help is appreciated.

@bot.event
async def on_raw_member_remove(member):
    channel = discord.utils.get(member.guild.channels, id=973603264639668248)
    await channel.edit(name=f'Member Count: {member.guild.member_count}')

Upvotes: 0

Views: 278

Answers (2)

Dominik
Dominik

Reputation: 3592

The right event for this would be on_member_remove.

You can also get the channel in a much easier way and edit it.

See a possible new code:

@bot.event
async def on_member_remove(member: discord.Member):
    channel = bot.get_channel(Channel_ID_here)
    await channel.edit(name=f"Member Count: {len(member.guild.members)}")

Upvotes: 2

throwingbat348
throwingbat348

Reputation: 1

The reason it doesn't work is because you are using on_raw_member_remove You should be using on_member_leave as the member is not getting removed.

Upvotes: -1

Related Questions