![](/img/trans.png)
[英]How to insert multiple arguments into the discord bot command python
[英]Discord Python Command Arguments
我正在尝试创建一个命令,其中第二个参数是机器人实际执行的操作
,haha kick, !haha ban, !haha test
所以我有
bot = commands.Bot(command_prefix='!')
@bot.command()
async def haha(ctx, arg):
channel = bot.get_channel(591059696622895117)
try:
if (arg == "kick"):
#kick
elif (arg == "ban"):
#ban
except:
await channel.send("Error processing your request!")
pass
但是我在运行时遇到错误!haha
,因为它缺少 arguments,我缺少什么?
如果你的意思是 commands.errors.MissingRequiredArgument,它是一个特性,而不是一个错误。 您可以使用 command_error 事件来处理它。
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.errors.MissingRequiredArgument):
await ctx.send("Your command isn't right!\n Read the help")
else:
raise error
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.