Exemple #1
0
    async def rating(self, ctx, platform: Platform, *, username):
        """Returns player ranks.

        `<platform>` - The platform of the player to get ranks for.
        `<username>` - The username of the player to get ranks for.

        Platforms
        - pc (bnet)
        - playstation (ps, psn, play)
        - xbox (xbl)
        - nintendo-switch (nsw, switch)

        Username formatting
        - pc: BattleTag (format: name#0000)
        - playstation: Online ID
        - xbox: Gamertag
        - nintendo-switch: Nintendo Switch ID (format: name-code)

        BattleTag example: Timmy#22340
        Nintendo Switch ID example: name-7alf327e36d5d1d8f507e765u5a2ech7
        """
        try:
            message = await ctx.send(embed=self.bot.loading_embed())
            data = await Request(platform=platform, username=username).get()
        except RequestError as e:
            await self.bot.cleanup(message)
            return await ctx.send(e)

        profile = Player(data, platform=platform, username=username)
        if profile.is_private:
            embed = profile.private()
        else:
            embed = await profile.get_ratings(ctx)
        await message.edit(embed=embed)
Exemple #2
0
    async def hero(
        self,
        ctx,
        hero: Hero,
        platform: Platform,
        *,
        username,
    ):
        """Returns player both quick play and competitive statistics for a given hero.

        `<hero>` - The name of the hero you want to see stats for.
        `<platform>` - The platform of the player to get stats for.
        `<username>` - The username of the player to get stats for.

        Platforms
        - pc (bnet)
        - playstation (ps, psn, play)
        - xbox (xbl)
        - nintendo-switch (nsw, switch)

        Username formatting
        - pc: BattleTag (format: name#0000)
        - playstation: Online ID
        - xbox: Gamertag
        - nintendo-switch: Nintendo Switch ID (format: name-code)

        BattleTag example: Timmy#22340
        Nintendo Switch ID example: name-7alf327e36d5d1d8f507e765u5a2ech7
        """
        try:
            message = await ctx.send(embed=self.bot.loading_embed())
            data = await Request(platform=platform, username=username).get()
        except RequestError as e:
            await self.bot.cleanup(message)
            return await ctx.send(e)

        profile = Player(data, platform=platform, username=username)
        if profile.is_private:
            embed = profile.private()
        else:
            try:
                embed = profile.get_hero(ctx, hero)
            except PlayerException as e:
                await self.bot.cleanup(message)
                return await ctx.send(e)

        await self.bot.cleanup(message)
        await self.bot.paginator.Paginator(pages=embed).start(ctx)
Exemple #3
0
    async def hero(
        self, ctx, hero: Hero, index: Index = None, member: discord.Member = None
    ):
        """Shows a member's Overwatch both quick play and competitive statistics for a given hero.

        `<hero>` - The name of the hero you want to see stats for.
        `[index]` - The profile's index you want to see the ranks for.
        `[member]` - The mention or the ID of a Discord member of the current server.

        If no index is given then the profile used will be the main one.
        If no member is given then the statistics returned will be yours.

        If you want to see a member's stats, you must enter both the index and the member.
        """
        async with ctx.typing():
            member = member or ctx.author

            try:
                _, platform, username = await self.get_profile(member, index=index)
            except MemberHasNoProfile as e:
                return await ctx.send(e)
            except IndexError:
                return await ctx.send(
                    f'Invalid index. Use "{ctx.prefix}help profile hero" for more info.'
                )

            try:
                data = await Request(platform=platform, username=username).get()
            except RequestError as e:
                return await ctx.send(e)

            profile = Player(data, platform=platform, username=username)
            if profile.is_private:
                embed = profile.private()
            else:
                try:
                    embed = profile.get_hero(ctx, hero)
                except NoHeroStatistics as e:
                    return await ctx.send(e)
            await self.bot.paginator.Paginator(pages=embed).start(ctx)
Exemple #4
0
    async def rating(self, ctx, index: Index = None, member: discord.Member = None):
        """Shows a member's Overwatch ranks.

        `[index]` - The profile's index you want to see the ranks for.
        `[member]` - The mention or the ID of a Discord member of the current server.

        If no index is given then the profile used will be the main one.
        If no member is given then the ranks returned will be yours.

        If you want to see a member's stats, you must enter both the index and the member.
        """
        async with ctx.typing():
            member = member or ctx.author

            try:
                id, platform, username = await self.get_profile(member, index=index)
            except MemberHasNoProfile as e:
                return await ctx.send(e)
            except IndexError:
                return await ctx.send(
                    f'Invalid index. Use "{ctx.prefix}help profile rating" for more info.'
                )

            try:
                data = await Request(platform=platform, username=username).get()
            except RequestError as e:
                return await ctx.send(e)

            profile = Player(data, platform=platform, username=username)
            if profile.is_private:
                embed = profile.private()
            else:
                embed = await profile.get_ratings(ctx, save=True, profile_id=id)
                # if the index is None that means it's the main profile
                if not index and member.id == ctx.author.id:
                    await self.update_nickname_sr(ctx.author, profile=profile)
            await self.bot.paginator.Paginator(pages=embed).start(ctx)