aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorscragly <[email protected]>2018-11-02 21:56:23 +1000
committerRapptz <[email protected]>2018-11-24 22:51:17 -0500
commit53c7d940c91a7d1e21e2f94e4eaba70fe0a74912 (patch)
tree7a9b9e02b4bce659ae593de3068ad39ced211a45 /docs
parentGroup Advanced Converters and Inline Advanced Converters (diff)
downloaddiscord.py-53c7d940c91a7d1e21e2f94e4eaba70fe0a74912.tar.xz
discord.py-53c7d940c91a7d1e21e2f94e4eaba70fe0a74912.zip
Outline the logic of `bool` converters
As a `bool` converter is treated differently from other callable (basic) converters, the explanatory docs should outline that it is evaluated differently from a simple type cast, and what logic is used in determining how the content is evaluated.
Diffstat (limited to 'docs')
-rw-r--r--docs/ext/commands/commands.rst12
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/ext/commands/commands.rst b/docs/ext/commands/commands.rst
index cc591156..5b36fc06 100644
--- a/docs/ext/commands/commands.rst
+++ b/docs/ext/commands/commands.rst
@@ -221,6 +221,18 @@ This works with any callable, such as a function that would convert a string to
async def up(ctx, *, content: to_upper):
await ctx.send(content)
+bool
+^^^^^^
+
+Unlike the other basic converters, the :class:`bool` converter is treated slightly different. Instead of casting directly to the :class:`bool` type, which would result in any non-empty argument returning ``True``, it instead evaluates the argument as ``True`` or ``False`` based on it's given content:
+
+.. code-block:: python3
+
+ if lowered in ('yes', 'y', 'true', 't', '1', 'enable', 'on'):
+ return True
+ elif lowered in ('no', 'n', 'false', 'f', '0', 'disable', 'off'):
+ return False
+
.. _ext_commands_adv_converters:
Advanced Converters