I have been trying to make my discord bot create multiple roles through a command. But it simply doesn't work. Here is what I have done so far:
@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.")
When I run this code I get this error:
Ignoring exception in command create_roles:
Traceback (most recent call last):
File "C:Userswave computerPycharmProjectspythonProjectvenvlibsite-packagesdiscordextcommandscore.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:Userswave computerPycharmProjectspythonProjectcogs
oles.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:Userswave computerPycharmProjectspythonProjectvenvlibsite-packagesdiscordextcommandsot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "C:Userswave computerPycharmProjectspythonProjectvenvlibsite-packagesdiscordextcommandscore.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:Userswave computerPycharmProjectspythonProjectvenvlibsite-packagesdiscordextcommandscore.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
Any help would be appreciated!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…