Skip to content
Advertisement

Am I using the on_guild_leave function correctly?

So I looked at many sources saying that on_guild_leave is how it is used, but I can’t get it to work. Here is my code:

@client.event
async def on_guild_join(guild): # noqa
    try:
        await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"{len(client.guilds)} Servers | !help"))
    except Exception as e:
        print(e)


@client.event
async def on_guild_leave(guild): # noqa
    try:
        await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"{len(client.guilds)} Servers | !help"))
    except Exception as e:
        print(e)

Can anyone seem to help?

on_guild_join works, but on_guild_leave doesn’t.

Advertisement

Answer

on_guild_leave doesn’t exist, use on_guild_remove instead. Docs for on_guild_remove

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement