【发布时间】:2018-07-10 04:25:22
【问题描述】:
这是我正在尝试使用的代码的 sn-p(我已经在代码开头定义了 rgb[]):
@client.command(pass_context=True,description="Linusifies a role")
client.command(pass_context=True,description="Linusifies a role")
@has_permissions(administrator = True)
async def rgb(ctx, role : discord.Role):
if role in rgb:
msg = "{}'s rgb is turned off :disappointed_relieved:"
rgb.remove(role)
await client.send_message(ctx.message.channel, msg)
else:
msg = "{}'s rgb has been turned on :christmas_tree:".format(role)
rgb.append(role)
await client.send_message(ctx.message.channel, msg)
这是当我尝试在服务器中执行 #rgb @role 时吐出的错误:
Traceback (most recent call last):
File "/home/python/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 50, in wrapped
ret = yield from coro(*args, **kwargs)
File "<stdin>", line 4, in rgb
TypeError: argument of type 'Command' is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/python/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 846, in process_commands
yield from command.invoke(ctx)
File "/home/python/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 374, in invoke
yield from injected(*ctx.args, **ctx.kwargs)
File "/home/python/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: argument of type 'Command' is not iterable
【问题讨论】:
-
您不能将
rgb既作为列表名称又作为函数名称。
标签: python python-3.x discord discord.py