{ "info": { "author": "lukeciel", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "discord_argparse\n================\n\nProvides support for arbitrarily ordered arguments in commands for the\n[discord.py](https://github.com/Rapptz/discord.py/) library.\n\n```python\nparam_converter = ArgumentConverter(\n turns = RequiredArgument(\n int, # follows the rules of a converter in discord.py\n doc=\"The number of turns this quiz has.\",\n default=10\n ),\n images = OptionalArgument(\n bool,\n doc=\"(Dis-)allow image questions.\",\n default=True\n ),\n voice_channel = OptionalArgument(\n discord.VoiceChannel\n )\n)\n\n\n@bot.command()\nasync def quiz(ctx, name:str, *, params:param_converter=param_converter.defaults()):\n await ctx.send(\"Turns: {0}\".format(params['turns']))\n\n\n@quiz.error\nasync def quiz_error(ctx, error):\n if isinstance(error, InvalidArgumentValueError):\n await ctx.send(\n \"Invalid argument value for parameter {0}\".format(error.name)\n )\n elif isinstance(error, UnknownArgumentError):\n await ctx.send(\n \"Unknown argument {0}\".format(error.name)\n )\n```\n\nOn your discord server, the commands can be invoked like this:\n\n```\n!quiz pokemon\n \u2192 will raise a MissingRequiredArgument exception\n\n!quiz pokemon turns=2\n \u2192 args[\"images\"] will be True\n\n!quiz pokemon turns=2 images=false\n```\n\n\nInstallation\n------------\n\nInstallation is available via pip:\n\n```\npip install discord_argparse\n```\n\n\nDocumentation\n-------------\n\nInitialize an `ArgumentConverter` as in the example above, annotate a\nkeyword-only function argument in your command with the instance and,\noptionally, set its default value by using the `.defaults()` method. Setting a\ndefault value can be omitted if you use required arguments (otherwise it will\nraise a `MissingRequiredArgument` exception).\n\nInside the command, you can access the arguments as a dict.\n\n\nCustom help formatter\n---------------------\n\nBy using a custom help formatter, you can send a list of all arguments to the\nusers of your bot. An example output, after sending `!help quiz` to the bot,\nmight look like this:\n\n```\n!quiz \n\nStarts a quiz.\nThis command will start a quiz.\n\nExample usage: !quiz pokemon turns=12 images=false\n\nArguments:\n turns The number of questions this quiz has.\n images (Dis-)allow image questions.\n voice_channel\n```\n\nTo make use of the argument list, create a custom [help\ncommand](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.HelpCommand)\nand override the `send_command_help` function like this:\n\n```python\nasync def send_command_help(self, command):\n self.add_command_formatting(command)\n for name, param in command.clean_params.items():\n if isinstance(param.annotation, da.ArgumentConverter):\n arguments = param.annotation.arguments\n if not arguments:\n continue\n self.paginator.add_line(\"Arguments:\")\n max_size = max(len(name) for name in arguments)\n\n for name, argument in arguments.items():\n entry = \"{0}{1:<{width}} {2}\".format(self.indent * \" \", name, argument.doc, width=max_size)\n self.paginator.add_line(self.shorten_text(entry))\n self.paginator.close_page()\n await self.send_pages()\n```\n\nYou might also want to set the `usage` parameter of the `command()` function\ndecorator to display a better usage string, especially when using the\n`ArgumentConvert.defaults()` method.\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/lukeciel/discord-argparse", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "discord-argparse", "package_url": "https://pypi.org/project/discord-argparse/", "platform": "", "project_url": "https://pypi.org/project/discord-argparse/", "project_urls": { "Homepage": "https://github.com/lukeciel/discord-argparse" }, "release_url": "https://pypi.org/project/discord-argparse/1.0.1/", "requires_dist": [ "discord.py (>=1.0.0)" ], "requires_python": "", "summary": "Arbitrarily ordered arguments for commands in discord.py", "version": "1.0.1" }, "last_serial": 5302205, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "8fb749ff83a0dc2e95b6903cf9e3c16a", "sha256": "c8df95126c8718f3bbacd3be40fbb1492152f0a65986b1826e23dec5d95df1bc" }, "downloads": -1, "filename": "discord_argparse-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "8fb749ff83a0dc2e95b6903cf9e3c16a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6936, "upload_time": "2019-05-09T08:14:27", "url": "https://files.pythonhosted.org/packages/2f/49/8be1adb1e33f8fdff3f6f931e2a46997e2552d93ada30e54a4cede657642/discord_argparse-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0d993b5922f980ebdd539e8083a0808d", "sha256": "77bd569cea0b4d557cd5251db30eb4251e2892d7b61cebed0a750846216d1da4" }, "downloads": -1, "filename": "discord_argparse-1.0.0.tar.gz", "has_sig": false, "md5_digest": "0d993b5922f980ebdd539e8083a0808d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4461, "upload_time": "2019-05-09T08:14:29", "url": "https://files.pythonhosted.org/packages/86/25/387ea7f005d05cccf7c99375f62d82b70e8589b394fa8bdb66f9ccdd8e44/discord_argparse-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "39e240e40633c4716bbcbfd7bb14c56b", "sha256": "0bc4dfd47cf0048dad40525a623abb979fee506bbe0513071d0d82663183f849" }, "downloads": -1, "filename": "discord_argparse-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "39e240e40633c4716bbcbfd7bb14c56b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7568, "upload_time": "2019-05-22T11:11:36", "url": "https://files.pythonhosted.org/packages/0a/7f/a4346334c33414fd2a9b15d9d990c3f2407f9af9d9c68baad9d6207b1ae8/discord_argparse-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d0614fa6c5f9000e5a5559f3b5710697", "sha256": "ced9f9deb55c0ea779626f2a0b1ac7c64b0f38af140596dc98f959b4a511acc4" }, "downloads": -1, "filename": "discord_argparse-1.0.1.tar.gz", "has_sig": false, "md5_digest": "d0614fa6c5f9000e5a5559f3b5710697", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5271, "upload_time": "2019-05-22T11:11:38", "url": "https://files.pythonhosted.org/packages/e0/ae/d786448edf6849c9bfe7bbab93109b2a83b37b61d644618099fa664591a5/discord_argparse-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "39e240e40633c4716bbcbfd7bb14c56b", "sha256": "0bc4dfd47cf0048dad40525a623abb979fee506bbe0513071d0d82663183f849" }, "downloads": -1, "filename": "discord_argparse-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "39e240e40633c4716bbcbfd7bb14c56b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7568, "upload_time": "2019-05-22T11:11:36", "url": "https://files.pythonhosted.org/packages/0a/7f/a4346334c33414fd2a9b15d9d990c3f2407f9af9d9c68baad9d6207b1ae8/discord_argparse-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d0614fa6c5f9000e5a5559f3b5710697", "sha256": "ced9f9deb55c0ea779626f2a0b1ac7c64b0f38af140596dc98f959b4a511acc4" }, "downloads": -1, "filename": "discord_argparse-1.0.1.tar.gz", "has_sig": false, "md5_digest": "d0614fa6c5f9000e5a5559f3b5710697", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5271, "upload_time": "2019-05-22T11:11:38", "url": "https://files.pythonhosted.org/packages/e0/ae/d786448edf6849c9bfe7bbab93109b2a83b37b61d644618099fa664591a5/discord_argparse-1.0.1.tar.gz" } ] }