diff options
| author | Rapptz <[email protected]> | 2016-07-02 23:38:59 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2016-07-02 23:39:29 -0400 |
| commit | 1500001b04ae49c1f3a0714c971a0fa6ef81e1bb (patch) | |
| tree | bd7d6b56fa611b0fa11252db3f5d6e79fc0dda07 /discord/ext | |
| parent | [commands] Do not lower-case the function name for default command names (diff) | |
| download | discord.py-1500001b04ae49c1f3a0714c971a0fa6ef81e1bb.tar.xz discord.py-1500001b04ae49c1f3a0714c971a0fa6ef81e1bb.zip | |
[commands] Fix error in converters in a private message context.
I was referencing a member function that did not actually exist. So I
ported it over to a free function that could be used.
Diffstat (limited to 'discord/ext')
| -rw-r--r-- | discord/ext/commands/converter.py | 14 | ||||
| -rw-r--r-- | discord/ext/commands/core.py | 8 |
2 files changed, 11 insertions, 11 deletions
diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index 4f34956b..214475f5 100644 --- a/discord/ext/commands/converter.py +++ b/discord/ext/commands/converter.py @@ -34,6 +34,14 @@ __all__ = [ 'Converter', 'MemberConverter', 'UserConverter', 'ChannelConverter', 'InviteConverter', 'RoleConverter', 'GameConverter', 'ColourConverter' ] +def _get_from_servers(bot, getter, argument): + result = None + for server in bot.servers: + result = getattr(server, getter)(argument) + if result: + return result + return result + class Converter: """The base class of custom converters that require the :class:`Context` to be passed to be useful. @@ -72,13 +80,13 @@ class MemberConverter(Converter): if server: result = server.get_member_named(self.argument) else: - result = self._get_from_servers(bot, 'get_member_named', self.argument) + result = _get_from_servers(bot, 'get_member_named', self.argument) else: user_id = match.group(1) if server: result = server.get_member(user_id) else: - result = self._get_from_servers(bot, 'get_member', user_id) + result = _get_from_servers(bot, 'get_member', user_id) if result is None: raise BadArgument('Member "{}" not found'.format(self.argument)) @@ -106,7 +114,7 @@ class ChannelConverter(Converter): if server: result = server.get_channel(channel_id) else: - result = self._get_from_servers(bot, 'get_channel', channel_id) + result = _get_from_servers(bot, 'get_channel', channel_id) if result is None: raise BadArgument('Channel "{}" not found.'.format(self.argument)) diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index 606f8e74..fff90ae6 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -158,14 +158,6 @@ class Command: finally: ctx.bot.dispatch('command_error', error, ctx) - def _get_from_servers(self, bot, getter, argument): - result = None - for server in bot.servers: - result = getattr(server, getter)(argument) - if result: - return result - return result - @asyncio.coroutine def do_conversion(self, ctx, converter, argument): if converter is bool: |