角色更新后,不会调用函数调用on_guild_role_update

时间:2019-08-21 19:43:09

标签: python discord

我的机器人当前位于3台服务器中,并且从未在任何地方调用过函数on_guild_role_update。该漫游器确实具有管理员权限,因此它应该可以查看所有受到限制的内容。我在@bot.event函数之前有一个on_ready装饰器,在它之后和on_guild_role_update之前有一个装饰器。 看起来像这样:

@bot.event
async def on_ready():
    #on_ready code

@bot.event
async def on_guild_role_update(before, after):
    print("1") #Included this just to see If the function even executes. It doesn't
    if before.name != after.name:
        embed = discord.Embed(title="Role " + before.name + " renamed to " + after.name + ".")
        embed.set_author(name="Role update")
        await bot.message.send(bot.get_channel(str(channelid)), embed=embed)

我丢失了某些东西还是不再起作用了?我检查了文档,但除了this外,没有发现任何相关内容。

1 个答案:

答案 0 :(得分:0)

您使用的是旧版本的discord.py。您可以通过运行获取最新信息

python -m pip install -U discord.py

使用运行机器人的python解释器。 1.0版引入了一些重大更改,因此您必须使用migration guide将代码更改为新接口。