aboutsummaryrefslogtreecommitdiff
path: root/discord/ext
diff options
context:
space:
mode:
authorRapptz <[email protected]>2016-01-12 01:00:16 -0500
committerRapptz <[email protected]>2016-01-12 01:06:53 -0500
commitc29f0ea544927186ce64f26e63c3e96dbfaea295 (patch)
tree64484bf4e6b3afdbf31e1e0f12b94ae263a9e887 /discord/ext
parent[commands] Support invoking the help command with a cog name. (diff)
downloaddiscord.py-c29f0ea544927186ce64f26e63c3e96dbfaea295.tar.xz
discord.py-c29f0ea544927186ce64f26e63c3e96dbfaea295.zip
[commands] Fix keyword-only case to actually do conversion.
Diffstat (limited to 'discord/ext')
-rw-r--r--discord/ext/commands/core.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py
index 5817ec77..846b33c4 100644
--- a/discord/ext/commands/core.py
+++ b/discord/ext/commands/core.py
@@ -186,19 +186,22 @@ class Command:
except:
raise BadArgument('Invite is invalid')
- def transform(self, ctx, param):
- required = param.default is param.empty
+ def _get_converter(self, param):
converter = param.annotation
- view = ctx.view
-
if converter is param.empty:
- if not required:
+ if param.default is not param.empty:
converter = str if param.default is None else type(param.default)
else:
converter = str
elif not inspect.isclass(type(converter)):
raise discord.ClientException('Function annotation must be a type')
+ return converter
+
+ def transform(self, ctx, param):
+ required = param.default is param.empty
+ converter = self._get_converter(param)
+ view = ctx.view
view.skip_ws()
if view.eof:
@@ -265,7 +268,9 @@ class Command:
args.append(self.transform(ctx, param))
elif param.kind == param.KEYWORD_ONLY:
# kwarg only param denotes "consume rest" semantics
- kwargs[name] = view.read_rest()
+ converter = self._get_converter(param)
+ argument = view.read_rest()
+ kwargs[name] = self.do_conversion(ctx.bot, ctx.message, converter, argument)
break
elif param.kind == param.VAR_POSITIONAL:
while not view.eof: