会员更新前后

时间:2020-07-22 23:13:54

标签: python discord.py

除了前头像和后头像之外,其他所有东西都很好用,它们只是不发送。没有错误,什么也没有。

async def on_member_update(before, after):
    guild = after.guild
    guild_id = after.guild.id
    cursor.execute('SELECT channel_id FROM logchannel WHERE guild_id = %s',
                   (guild_id,))
    result1 = cursor.fetchone()
    if result1 is not None:
        channel_id = result1[0]
        channel = discord.utils.get(guild.channels, id=channel_id)
        if  before.display_name != after.display_name:
            await channel.send(f"Nickname of {before.name} changed from {before.display_name} to {after.display_name}")

        if before.activity != after.activity:
            await channel.send(f"{after.name}'s activity changed from {before.activity.name} to {after.activity.name}")

        if before.avatar_url != after.avatar_url:
            await channel.send(f"{after.name}'s avatar has changed from {before.avatar_url} to {after.avatar_url}")```

1 个答案:

答案 0 :(得分:0)

on_member_update不会被要求进行头像更改。而是on_user_update是。这是因为如果该漫游器与另一个用户共享多个公会,我们只希望获得一个事件。