Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

Arbitrarily ordered arguments for commands in

Project description


Provides support for arbitrarily ordered arguments in commands for the library.

param_converter = ArgumentConverter(
    turns = RequiredArgument(
        doc="The number of turns this quiz has.",
    images = OptionalArgument(
        doc="(Dis-)allow image questions.",
    voice_channel = OptionalArgument(

# The command below can be called by ...
# !quiz pokemon
# !quiz pokemon turns=12
# !quiz pokemon images=false turns=12

async def quiz(ctx, name:str, *, params:param_converter=param_converter.defaults()):
    await ctx.send("Turns: {0}".format(params['turns']))

async def quiz_error(ctx, error):
    if isinstance(error, InvalidArgumentValueError):
        await ctx.send(
            "Invalid argument value for parameter {0}".format(
    elif isinstance(error, UnknownArgumentError):
        await ctx.send(
            "Unknown argument {0}".format(


Simply drop the source file anywhere in your project. Installation via pip is not available at the moment.


Initialize an ArgumentConverter as in the example above, annotate a keyword-only function argument in your command with the instance and, optionally, set its default value by using the .defaults() method. Setting a default value can be omitted if you use required arguments (otherwise it will raise a MissingRequiredArgument exception).

Inside the command, you can access the arguments as a dict.

Project details

Release history Release notifications

This version
History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
discord_argparse-1.0.0-py3-none-any.whl (6.9 kB) Copy SHA256 hash SHA256 Wheel py3
discord_argparse-1.0.0.tar.gz (4.5 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page