我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用discord.ext.commands.TooManyArguments()。
def on_command_error(self, ctx, err): if isinstance(err, errors.PermissionDenied): await ctx.send('BAKA! You do not have my permission!') elif isinstance(err, errors.MissingPermissions): await ctx.send('BAKA! I require these permissions: %s' % ', '.join(err.args)) elif isinstance(err, commands.NoPrivateMessage): await ctx.send('BAKA! This command does not work in private messages!') elif isinstance(err, commands.BadArgument): str_err = str(err) if not str_err.endswith(('.', '!')): str_err += '.' await ctx.send('BAKA! %s' % str_err) elif isinstance(err, commands.MissingRequiredArgument): await ctx.send('BAKA! Missing required argument: `%s`' % err.args[0].partition(' ')[0]) elif isinstance(err, commands.TooManyArguments): await ctx.send('BAKA! Too many arguments!') elif isinstance(err, commands.CommandNotFound): pass else: await ctx.send('```\n%s\n```' % ''.join(traceback.format_exception_only(type(err), err)).strip()) if isinstance(ctx.channel, discord.TextChannel): log.error('Error in command <{0}> ({1.name!r}({1.id}) {2}({2.id}) {3}({3.id}) {4!r})'.format(ctx.command, ctx.guild, ctx.channel, ctx.author, ctx.message.content)) else: log.error('Error in command <{0}> (DM {1}({1.id}) {2!r})'.format(ctx.command, ctx.channel.recipient, ctx.message.content)) log.error(''.join(traceback.format_exception(type(err), err, err.__traceback__)))
def prefix_error(self, ctx, error): if isinstance(error, commands.TooManyArguments): await ctx.send("Nya~~! Too many! Go slower or put it in quotes!") else: original = getattr(error, 'original', None) if original: await ctx.send(original)
def tag_make_error(self, error, ctx): if type(error) is commands.TooManyArguments: await self.bot.say('Please call just {0.prefix}tag make'.format(ctx))
def prefix_add_error(self, ctx, error): if isinstance(error, commands.TooManyArguments): await ctx.send("You've given too many prefixes. Either quote it or only do it one by one.")
def tag_make_error(self, ctx, error): if isinstance(error, commands.TooManyArguments): await self.bot.say(f'Please call just {ctx.prefix}tag make')