Browse Source

[commands] Strip arguments before searching for special cases.

pull/95/head
Rapptz 9 years ago
parent
commit
50c83b5a3c
  1. 7
      discord/ext/commands/core.py

7
discord/ext/commands/core.py

@ -121,6 +121,7 @@ class Command:
discord.utils.create_task(injected(error, ctx), loop=ctx.bot.loop) discord.utils.create_task(injected(error, ctx), loop=ctx.bot.loop)
def _receive_item(self, message, argument, regex, receiver, generator): def _receive_item(self, message, argument, regex, receiver, generator):
argument = argument.strip()
match = re.match(regex, argument) match = re.match(regex, argument)
result = None result = None
private = message.channel.is_private private = message.channel.is_private
@ -165,15 +166,15 @@ class Command:
if message.channel.is_private: if message.channel.is_private:
raise NoPrivateMessage() raise NoPrivateMessage()
role = discord.utils.get(message.server.roles, name=argument) role = discord.utils.get(message.server.roles, name=argument.strip())
if role is None: if role is None:
raise BadArgument('Role not found') raise BadArgument('Role not found')
return role return role
elif converter is discord.Game: elif converter is discord.Game:
return discord.Game(name=argument) return discord.Game(name=argument.strip())
elif converter is discord.Invite: elif converter is discord.Invite:
try: try:
return bot.get_invite(argument) return bot.get_invite(argument.strip())
except: except:
raise BadArgument('Invite is invalid') raise BadArgument('Invite is invalid')

Loading…
Cancel
Save