【发布时间】:2021-05-15 23:11:20
【问题描述】:
我一直试图让我的不和谐机器人通过命令创建多个角色。但这根本行不通。这是我到目前为止所做的:
@commands.command()
async def create_roles(self, ctx):
guild = self.client.get_guild(783547639944839178)
channel = self.client.get_channel(809683610058752010)
await guild.create_role(name="red", color=discord.Color.value('F51720'))
await guild.create_role(name="skyblue", color=discord.Colour.value('11A7BB'))
await guild.create_role(name="yellow", color=discord.Colour.value('F8D210'))
await channel.send("Done.")
当我运行这段代码时,我得到了这个错误:
Ignoring exception in command create_roles:
Traceback (most recent call last):
File "C:\Users\wave computer\PycharmProjects\pythonProject\venv\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\wave computer\PycharmProjects\pythonProject\cogs\roles.py", line 14, in create_roles
await guild.create_role(name="red", colour=discord.Colour.value('F51720'))
TypeError: 'member_descriptor' object is not callable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\wave computer\PycharmProjects\pythonProject\venv\lib\site-packages\discord\ext\commands\bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\wave computer\PycharmProjects\pythonProject\venv\lib\site-packages\discord\ext\commands\core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\wave computer\PycharmProjects\pythonProject\venv\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'member_descriptor' object is not callable
任何帮助将不胜感激!
【问题讨论】:
-
您能与我们分享您遇到的错误吗?或者至少是使用该命令的输出。
-
哦,谢谢你的提醒,我就是这么做的。
-
您的命令不起作用,因为您有错字。
guild.create_role的参数名称应为colour,而不是color。 -
即使将其更改为
colour,它也不起作用。帮忙? -
你仍然得到同样的错误?
标签: python discord.py