예제 #1
0
async def help_command(ctx: commands.Context, *, command=None):
    """Справка по командам"""
    help_command = HelpCommand(ctx)
    if not command:
        paginator = Paginator(ctx)
        for cog in await help_command.get_cogs():
            info = await help_command.cog_help(cog)
            if info:
                paginator.pages.append(info)

        [
            x.set_footer(
                text=f'Страница {n+1}/{len(paginator.pages)}'
                f' • примечание: показаны только те команды, которые вы можете выполнить'
            ) for n, x in enumerate(paginator.pages)
        ]

        await paginator.start()

    else:
        cmd = ctx.bot.get_command(command)

        if not cmd:
            return await ctx.send(f'Неизвестная команда.')

        await ctx.send(embed=await help_command.command_help(cmd))
예제 #2
0
 async def _help(self, ctx, command: str = None):
     """Shows all commands"""
     prefix = (await self.bot.get_prefix(ctx.message))[0]
     if command:
         cmd = self.bot.get_command(
             command.lower()) or self.bot.get_cog(command)
         if not cmd:
             return await ctx.send(
                 f"Command or category '{command}' not found.")
         if isinstance(cmd, commands.Command):
             em = discord.Embed(color=0xff0000)
             em.title = cmd.name
             em.description = cmd.help or "No Description"
             em.description += "\nUsage: `{}{}`".format(
                 ctx.prefix, _command_signature(cmd))
             if cmd.aliases:
                 em.description += "\nAliases: `{}`".format(", ".join(
                     cmd.aliases))
             return await ctx.send(embed=em)
         cmds = self.bot.get_cog_commands(command)
         em = discord.Embed(color=0xff0000)
         em.description = cmd.__doc__ + "\n\n`" if cmd.__doc__ else "No Description\n\n`"
         em.set_footer(
             text=f"{prefix}help <cmd> for more info on a command.")
         for x in cmds:
             msg = f"{ctx.prefix}{x.signature} {x.short_doc}\n"
             em.description += msg
         em.description += "`"
         return await ctx.send(embed=em)
     else:
         cogs = self.bot.cogs.keys()
         pages = []
         for x in cogs:
             if x == "Owner" and ctx.author.id != 292690616285134850:
                 continue
             cmds = self.bot.get_cog_commands(x)
             cog = self.bot.get_cog(x)
             msg = cog.__class__.__name__ + "\n" + cog.__doc__ + "\n\n`" if cog.__doc__ else cog.__class__.__name__ + "\nNo Description\n\n`"
             for cmd in cmds:
                 if cmd.hidden:
                     continue
                 cmd_msg = f"{prefix}{_command_signature(cmd)} {cmd.short_doc}\n"
                 msg += cmd_msg
             msg += "`"
             pages.append(msg)
         em = discord.Embed(color=0xff0000)
         em.set_footer(
             text=f"{prefix}help <cmd> for more information on a command.")
         paginator = Paginator(ctx, pages=pages, page_count=True, embed=em)
         await paginator.run()
예제 #3
0
 async def urban(self, ctx, *, term: str):
     """Get a term from urban dictionary!"""
     if not ctx.channel.nsfw:
         return await ctx.send(
             f"Due to urban having some inappropriate words and discord does not allow NSFW outside of NSFW channels we have made urban to work in NSFW channels only."
         )
     try:
         resp = await (await self.bot.session.get(
             f"https://api.urbandictionary.com/v0/define?term={term}")
                       ).json()
         pages = []
         for x in resp["list"]:
             pages.append(
                 f"{x['definition']}\n\n*{x['example']}*\n\n**Votes**\n:thumbsup: {x['thumbs_up']} :thumbsdown: {x['thumbs_down']}"
             )
         paginator = Paginator(ctx, pages=pages, page_count=True)
         await paginator.run()
     except Exception as e:
         await ctx.send(f"Unknown term.")
예제 #4
0
    async def fnprofile(self, ctx, platform=None, username=None):
        '''Gets your Fortnite Profile using Tag'''
        authorID = str(ctx.author.id)
        if not platform or not username:
            if await self.get_info(authorID) == 'None':
                await ctx.send(
                    f'Please provide a tag or save your tag using `{ctx.prefix}fnsave platform username`'
                )
            information = await self.get_info(authorID)
            platform = information[0]
            username = information[1]

        embeds = []
        data = self.req(platform, username)

        hasSolos = True
        hasDuos = True
        hasSquads = True

        try:
            data['epicUserHandle']
        except Exception:
            await ctx.send(
                'Looks like that Player/Platform combination is wrong! Make sure your info is correct then try again'
            )

        try:
            data['stats']['p2']
        except Exception:
            hasSolos = False

        try:
            data['stats']['p10']
        except Exception:
            hasDuos = False

        try:
            data['stats']['p9']
        except Exception:
            hasSquads = False

        em = discord.Embed(color=utils.random_color())
        em.title = data['epicUserHandle']
        em.description = f'Overall Statistics'
        em.add_field(name='Platform', value=data['platformNameLong'])
        em.add_field(name=data['lifeTimeStats'][7]['key'],
                     value=data['lifeTimeStats'][7]['value'])
        em.add_field(name=data['lifeTimeStats'][8]['key'],
                     value=data['lifeTimeStats'][8]['value'])
        em.add_field(name=data['lifeTimeStats'][10]['key'],
                     value=data['lifeTimeStats'][10]['value'])
        em.add_field(name=data['lifeTimeStats'][11]['key'],
                     value=data['lifeTimeStats'][11]['value'])
        em.add_field(name=data['lifeTimeStats'][6]['key'],
                     value=data['lifeTimeStats'][6]['value'])
        em.add_field(name=data['lifeTimeStats'][1]['key'],
                     value=data['lifeTimeStats'][1]['value'])
        embeds.append(em)

        if hasSolos:
            em = discord.Embed(color=utils.random_color())
            em.title = data['epicUserHandle']
            em.description = f'Solo Statistics'
            em.add_field(name='Matches played',
                         value=data['stats']['p2']['matches']['value'])
            em.add_field(name='Wins',
                         value=data['stats']['p2']['top1']['value'])
            em.add_field(name='Win %',
                         value=data['stats']['p2']['winRatio']['value'])
            em.add_field(name='Score',
                         value=data['stats']['p2']['score']['value'])
            em.add_field(name='Kill/Deatch ratio',
                         value=data['stats']['p2']['kd']['value'])
            em.add_field(name='kills',
                         value=data['stats']['p2']['kills']['value'])
            em.add_field(name='Top 10',
                         value=data['stats']['p2']['top10']['value'])
            em.add_field(name='Top 5',
                         value=data['stats']['p2']['top5']['value'])
            embeds.append(em)

        if hasDuos:
            em = discord.Embed(color=utils.random_color())
            em.title = data['epicUserHandle']
            em.description = f'Duo Statistics'
            em.add_field(name='Matches played',
                         value=data['stats']['p10']['matches']['value'])
            em.add_field(name='Wins',
                         value=data['stats']['p10']['top1']['value'])
            em.add_field(name='Win %',
                         value=data['stats']['p10']['winRatio']['value'])
            em.add_field(name='Score',
                         value=data['stats']['p10']['score']['value'])
            em.add_field(name='Kill/Deatch ratio',
                         value=data['stats']['p10']['kd']['value'])
            em.add_field(name='kills',
                         value=data['stats']['p10']['kills']['value'])
            em.add_field(name='Top 10',
                         value=data['stats']['p10']['top10']['value'])
            em.add_field(name='Top 5',
                         value=data['stats']['p10']['top5']['value'])
            embeds.append(em)

        if hasSquads:
            em = discord.Embed(color=utils.random_color())
            em.title = data['epicUserHandle']
            em.description = f'Squad Statistics'
            em.add_field(name='Matches played',
                         value=data['stats']['p9']['matches']['value'])
            em.add_field(name='Wins',
                         value=data['stats']['p9']['top1']['value'])
            em.add_field(name='Win %',
                         value=data['stats']['p9']['winRatio']['value'])
            em.add_field(name='Score',
                         value=data['stats']['p9']['score']['value'])
            em.add_field(name='Kill/Deatch ratio',
                         value=data['stats']['p9']['kd']['value'])
            em.add_field(name='kills',
                         value=data['stats']['p9']['kills']['value'])
            em.add_field(name='Top 10',
                         value=data['stats']['p9']['top10']['value'])
            em.add_field(name='Top 5',
                         value=data['stats']['p9']['top5']['value'])
            embeds.append(em)

        p_session = Paginator(
            ctx,
            footer=
            f'PikaBot | info provided by TrackerNetwork (Kiling bugs one by one)',
            pages=embeds)
        await p_session.run()