예제 #1
0
파일: fun.py 프로젝트: z03h/CyberTron5000-1
 async def pfpcycle(self, ctx):
     """if you're reading this it probably isnt your business"""
     pfps = [
         'http://tinyurl.com/y8ccnxm3',
         'https://images-ext-1.discordapp.net/external/6HjseNKji1C5wbK9Wb_jnIluzFWrCRW6xqhfboNtDDI/%3Fsize%3D1024/https/cdn.discordapp.com/avatars/350349365937700864/bbbff13a570231108b7afa383416b62a.png',
         'http://tinyurl.com/ycjuvusq',
         'https://cdn.discordapp.com/avatars/350349365937700864/f38bc11cf4360a9267a55962fcd71809.png?size=1024',
         'https://media.discordapp.net/attachments/381963689470984203/732283634190516304/coolweavile.png?width=962&height=962',
         'https://images-ext-1.discordapp.net/external/XVtT9nLyPYTWfNw4GSjvRMKibuKafi6_VCyVwSfW4C8/%3Fsize%3D1024/https/cdn.discordapp.com/avatars/350349365937700864/d027959b2a204f7587092a7a249e7377.png?width=962&height=962',
         'https://media.discordapp.net/attachments/735325249138065468/735681377785348156/image0.png',
         'https://media.discordapp.net/attachments/735325249138065468/735681378292596736/image1.png',
         'https://media.discordapp.net/attachments/735325249138065468/735681378867478528/image2.png',
         'https://media.discordapp.net/attachments/735325249138065468/735681379387441152/image3.png',
         'https://media.discordapp.net/attachments/735325249138065468/735682125239681074/image0.png'
         'http://i.some-random-api.ml/pokemon/weavile.png'
     ]
     embeds = [
         discord.Embed(colour=self.bot.colour).set_image(url=p)
         for p in pfps
     ]
     a = paginator.CatchAllMenu(paginator.EmbedSource(embeds))
     await a.start(ctx)
예제 #2
0
 async def send_group_help(self, group):
     """
     Help for a subcommand group.
     :param group:
     :return:
     """
     sc = []
     entries = await self.filter_commands(group.commands)
     embed = discord.Embed(title=self.get_command_signature(group), colour=self.context.bot.colour)
     for c in entries:
         sc.append(f"→ `{self.get_command_signature(c)}` {c.help or 'No help provided.'}")
     embed.description = f"{group.help}"
     if entries and len(entries) > 6:
         source = paginator.IndexedListSource(show_index=False, data=sc, embed=embed, per_page=6,
                                              title='Subcommands')
         menu = paginator.CatchAllMenu(source=source)
         menu.add_info_fields(self._help_dict)
         await menu.start(self.context)
     else:
         if sc:
             embed.add_field(name="Subcommands", value="\n".join(sc))
         await self.context.send(embed=embed)
예제 #3
0
 async def auditlog(self, ctx, limit: int = 20):
     try:
         actions = []
         async for x in ctx.guild.audit_logs(limit=limit):
             if not x.target:
                 target = ''
             else:
                 target = x.target
             actions.append(
                 f"{x.user.name} {lists.audit_actions[x.action]} {str(target)} ({humanize.naturaltime(__import__('datetime').datetime.utcnow() - x.created_at)})"
             )
         source = paginator.IndexedListSource(embed=discord.Embed(
             colour=self.bot.colour
         ).set_author(
             name=f"Last Audit Log Actions for {ctx.guild}",
             icon_url=
             "https://cdn.discordapp.com/emojis/446847139977625620.png?v=1"
         ),
                                              data=actions)
         menu = paginator.CatchAllMenu(source=source)
         await menu.start(ctx)
     except Exception as er:
         await ctx.send(f'{er.__class__.__name__}, {er}')
예제 #4
0
파일: fun.py 프로젝트: z03h/CyberTron5000-1
 async def todo(self, ctx):
     """Shows your current todo list"""
     items = []
     results = sorted((await self.get_all_todo(ctx.author.id)),
                      key=lambda x: x['time'])
     for each in results:
         time = dt.utcfromtimestamp(each['time'])
         since = nt(dt.utcnow() - time)
         if each['description']:
             desc_em = "❔"
         else:
             desc_em = ""
         items.append(
             f"[{each['todo']}]({each['message_url']}) (ID: {each['id']} | Created {since}) {desc_em}"
         )
     source = paginator.IndexedListSource(
         data=items,
         embed=discord.Embed(colour=self.bot.colour),
         title="Items (`❔` indicates that the todo has a description)",
         per_page=5)
     menu = paginator.CatchAllMenu(source=source)
     menu.add_info_fields(
         {"❔": "Indicates that the todo has a description"})
     await menu.start(ctx)
예제 #5
0
파일: fun.py 프로젝트: z03h/CyberTron5000-1
 async def horror(self, ctx, limit: int = 5):
     """spoopy"""
     posts = []
     async with self.bot.session.get(
             f"https://www.reddit.com/r/twosentencehorror/hot.json") as r:
         res = await r.json()
         for i in res['data']['children']:
             posts.append(i['data'])
         counter = 0
         embeds = []
         async with ctx.typing():
             for s in random.sample(posts, len(posts)):
                 text = cyberformat.shorten(
                     f"{s['title']}\n{s['selftext']}")
                 embeds.append(
                     discord.Embed(description=text[:2000],
                                   colour=self.bot.colour))
                 counter += 1
                 if counter == limit:
                     break
                 else:
                     continue
     p = paginator.CatchAllMenu(paginator.EmbedSource(embeds))
     await p.start(ctx)
예제 #6
0
    async def phelp(self, ctx, *, command=None):
        """
        If you don't like the regular help command

        """
        embeds = []
        use = self.bot.get_command(command) if command else None
        lcogs = [str(cog) for cog in self.bot.cogs]
        if not command:
            for name, obj in self.bot.cogs.items():
                embed = discord.Embed(title=f"{name} Commands",
                                      colour=self.bot.colour)
                cmds = []
                for cmd in obj.get_commands():
                    cmds.append(f"→ `{cmd.name} {cmd.signature}` | {cmd.help}")
                embed.description = '\n'.join(cmds)
                if cmds:
                    embeds.append(embed)
                else:
                    continue
            pages = paginator.CatchAllMenu(
                paginator.EmbedSource([
                    discord.Embed(
                        colour=self.bot.colour,
                        title=f'{self.bot.user.name} Help',
                        description=
                        f'Do `{ctx.prefix}help command/cog` for more info').
                    set_image(url=self.bot.user.avatar_url)
                ] + embeds))
            await pages.start(ctx)
        elif command in lcogs:
            embed = discord.Embed(colour=self.bot.colour,
                                  title=f'{command.capitalize()} Help')
            embed.description = '\n'.join([
                f"→ `{cmd.name} {cmd.signature}` | {cmd.help}"
                for cmd in self.bot.cogs[command].get_commands()
            ])
            await ctx.send(embed=embed)
        elif command and use:
            help_msg = use.help or "No help provided for this command"
            parent = use.full_parent_name
            if len(use.aliases) > 0:
                aliases = '|'.join(use.aliases)
                cmd_alias_format = f'{use.name}|{aliases}'
                if parent:
                    cmd_alias_format = f'{parent} {cmd_alias_format}'
                alias = cmd_alias_format
            else:
                alias = use.name if not parent else f'{parent} {use.name}'
            embed = discord.Embed(title=f"{alias} {use.signature}",
                                  description=help_msg,
                                  colour=self.bot.colour)
            if isinstance(use, commands.Group):
                embed = discord.Embed(title=f"{alias} {use.signature}",
                                      description=help_msg,
                                      colour=self.bot.colour)
                for sub_cmd in use.commands:
                    u = '\u200b'
                    embed.add_field(
                        name=
                        f"{use.name} {sub_cmd.name}{'|' if sub_cmd.aliases else u}{'| '.join(sub_cmd.aliases)} {sub_cmd.signature}",
                        value=f"{sub_cmd.help}",
                        inline=False)
                await ctx.send(embed=embed)
            else:
                await ctx.send(embed=embed)
        elif command not in lcogs or command and not use:
            await ctx.send("not found")