예제 #1
0
파일: stats.py 프로젝트: NeStell/overbot
    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)
예제 #2
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)