async def convert(self, ctx, argument): tag = self.resolve_tag(argument) if not tag: raise utils.InvalidTag('Invalid cr-tag passed.') else: return tag
async def convert(self, ctx, argument): # Try to convert it to a member. try: user = await super().convert(ctx, argument) except commands.BadArgument: pass else: return user # Not a user so its a tag. tag = self.resolve_tag(argument) if not tag: raise utils.InvalidTag('Invalid bs-tag passed.') else: return tag
async def save(self, ctx, tag, index: str='0'): """Saves a Clash of Clans tag to your discord profile.""" tag = self.conv.resolve_tag(ctx, tag) if not tag: raise utils.InvalidTag('Invalid cr-tag passed') await ctx.save_tag(tag, 'clashofclans', index=index.replace('-', '')) try: default_game = self.bot.default_game[ctx.guild.id] except AttributeError: default_game = self.bot.default_game[ctx.channel.id] cmd_name = 'profile' if default_game == self.__class__.__name__ else f'{self.alias}profile' if index == '0': prompt = _('Check your stats with `{}{}`!').format(ctx.prefix, cmd_name) else: prompt = _('Check your stats with `{}{} -{}`!').format(ctx.prefix, cmd_name, index) await ctx.send('Successfully saved tag. ' + prompt)
async def convert(self, ctx, argument): # Try to convert it to a member. try: arg_split = argument.split(' -') user = await super().convert(ctx, arg_split[0]) except commands.BadArgument: pass else: try: return (user, int(arg_split[1])) except IndexError: return (user, 0) except ValueError: pass # Not a user so its a tag. tag = self.resolve_tag(ctx, argument) if not tag: raise utils.InvalidTag(_('Invalid cr-tag passed.')) else: return tag