“ on_server_role_update” TypeError缺少参数

时间:2018-08-30 12:56:32

标签: typeerror discord.py

所以...我不知道该说些什么,我显然会很快

代码:

@bot.event
async def on_server_role_update(role, before, after):
print("[" + (colored("{}".format(role.server), 'blue')) + "] " + (colored("Role Updated: {0} >> {1}".format(before, after), 'yellow')))

错误:

TypeError: on_server_role_update() missing 1 positional argument: 'after'

你看到了吗?我有论点,但显示错误!

1 个答案:

答案 0 :(得分:0)

on_server_role_update应该有两个自变量:Role beforeRole after。您为什么认为还有第三个role参数?

@bot.event
async def on_server_role_update(before, after):
    server_blue = colored(str(before.server), 'blue')
    msg = "Role Updated: {0} >> {1}".format(before, after)
    color_msg = colored(msg, 'yellow')
    print("[{}] {}".format(server_blue, color_msg))