increase efficiency of name/uuid filtering in mcprofile
@@ -290,7 +290,7 @@ class Minecraft(commands.Cog):
@commands.command(name='mcprofile', aliases=['minecraftprofile', 'nametouuid', 'uuidtoname', 'mcp'])
@commands.cooldown(1, 4, commands.BucketType.user)
async def minecraft_profile(self, ctx, player):
- if 17 > len(player) > 1 and all([(name_c.lower() in 'abcdefghijklmnopqrstuvwxyz1234567890_') for name_c in player]): # player is a username
+ if 17 > len(player) > 1 and player.lower().strip('abcdefghijklmnopqrstuvwxyz1234567890_') == '':
with ctx.typing():
res = await self.ses.get(f'https://api.mojang.com/users/profiles/minecraft/{player}')
@@ -303,7 +303,7 @@ class Minecraft(commands.Cog):
jj = await res.json()
uuid = jj['id']
- elif len(player) in (32, 36,) and all([(uuid_c.lower() in 'abcdefghijklmnopqrstuvwxyz1234567890-') for uuid_c in player]): # player is a uuid
+ elif len(player) in (32, 36,) and player.lower().strip('abcdefghijklmnopqrstuvwxyz1234567890-') == '': # player is a uuid
uuid = player.replace('-', '')
else:
await self.bot.send(ctx, ctx.l.minecraft.invalid_player)
