コード例 #1
0
    async def redirect_list(self, ctx):
        try:
            async with self.bot.db.acquire() as con:
                overrides = await con.fetch(
                    f"SELECT * FROM redirects WHERE guild_id={ctx.guild.id} AND type='override'"
                )
                rglobal = await con.fetch(
                    f"SELECT * FROM redirects WHERE guild_id={ctx.guild.id} AND type='all'"
                )
        except Exception:
            raise customerrors.RedirectSearchError()

        or_count = [
            f"`{ovr['command']}` ⟶ <#{ovr['channel_id']}> [*set by <@{ovr['author_id']}>*]"
            for ovr in overrides
        ] if overrides else ["No overriding redirects exist"]
        rg_count = f"{len(rglobal)} commands are globally redirected" if rglobal else "No global redirects exist"

        pag = EmbedPaginator(ctx,
                             entries=or_count,
                             per_page=10,
                             show_entry_count=False)
        pag.embed.title = "Command Redirects"
        pag.embed.set_footer(text=rg_count)
        return await pag.paginate()
コード例 #2
0
 async def guild(self, ctx):
     entries = [
         f"{guild.name}" for guild in await self.get_premium_guilds()
     ]
     pag = EmbedPaginator(ctx,
                          entries=entries,
                          per_page=10,
                          show_entry_count=True)
     pag.embed.title = "MarwynnBot Premium Servers"
     return await pag.paginate()
コード例 #3
0
ファイル: info.py プロジェクト: ReinaSakuraba/YouTubeBot
    async def changelog(self, ctx):
        """Shows recent changes made to the bot."""

        changes, _ = await self.get_recent_changes()

        try:
            paginator = EmbedPaginator(ctx, entries=changes.split('\n'))
            paginator.embed.title = 'Change Log'
            paginator.embed.color = 0xFF0000
            await paginator.paginate()
        except Exception as e:
            await ctx.send(e)
コード例 #4
0
 async def user(self, ctx, source: str = "guild"):
     op = source if source == "guild" else "global"
     entries = [
         f"{user.mention} - {user.name}"
         for user in await self.get_premium_users(ctx.guild, op)
     ]
     pag = EmbedPaginator(ctx,
                          entries=entries,
                          per_page=10,
                          show_entry_count=True)
     pag.embed.title = f"MarwynnBot Premium Users in {ctx.guild.name}" if op == "guild" else "MarwynnBot Premium Users"
     return await pag.paginate()
コード例 #5
0
ファイル: todo.py プロジェクト: marwynnsomridhivej/marwynnbot
 async def todo_list(self, ctx, *, flag: str = None):
     if not flag in ["active", "done", "complete"]:
         entries = await self.get_todos(ctx, list=True, detailed=True)
         title = f"All Todos Created"
     elif flag == "active":
         entries = await self.get_todos(ctx, req_active=True, list=True, detailed=True)
         title = "Your Active Todos"
     elif flag in ["done", "complete", "completed", "finished"]:
         title = "Your Completed Todos"
         entries = await self.get_todos(ctx, req_complete=True, list=True, detailed=True)
     pag = EmbedPaginator(ctx, entries=entries, per_page=10, show_entry_count=True)
     pag.embed.title = title
     return await pag.paginate()
コード例 #6
0
 async def lock_list(self, ctx, *, flag: str = "all"):
     if flag not in ['all', 'lock', 'unlock']:
         flag == 'all'
     entries = await self.get_locks(ctx, flag)
     if not entries:
         embed = discord.Embed(
             title="No Locks Set",
             description=
             f"{ctx.author.mention}, this server does not have any {flag + 'ed' if flag != 'all' else 'locked'} channels",
             color=discord.Color.dark_red())
         return await ctx.channel.send(embed=embed)
     else:
         pag = EmbedPaginator(ctx,
                              entries=entries,
                              per_page=10,
                              show_entry_count=True)
         pag.embed.title = f"{flag.title() if flag != 'all' else 'All Locked'} Channels"
         return await pag.paginate()
コード例 #7
0
 async def leaderboard(self, ctx):
     entries = await self._get_leaderboard(ctx.guild)
     embed = discord.Embed(title=f"Leaderboard for {ctx.guild.name}",
                           color=discord.Color.blue())
     embed.set_thumbnail(url=ctx.guild.icon_url)
     embed.set_footer(
         text=f"Current as of {datetime.now().strftime('%m/%d/%Y %H:%M:%S')}"
     )
     description = (
         f"Here is the leaderboard for {ctx.guild.name}. "
         "Climb the leaderboard by simply talking in the enabled channels!\n\n"
     )
     pag = EmbedPaginator(ctx,
                          entries=entries,
                          per_page=10,
                          show_entry_count=False,
                          embed=embed,
                          description=description)
     return await pag.paginate()
コード例 #8
0
 async def counter(self, ctx, name=None, mode='server'):
     if name == "server" or name == "global":
         mode = name
         name = None
     if not name:
         async with self.bot.db.acquire() as con:
             if mode == 'server':
                 result = await con.fetch(f"SELECT * FROM guild_counters WHERE guild_id={ctx.guild.id} "
                                          "ORDER BY command ASC")
                 title = f"Counters for {ctx.guild.name}"
                 entries = [
                     f"***{item['command']}:*** *used {item['amount']} "
                     f"{'times' if item['amount'] != 1 else 'time'}*"
                     for item in result]
             else:
                 result = await con.fetch(f"SELECT * from global_counters ORDER BY command ASC")
                 title = "Global Counters"
                 entries = [
                     f"***{record['command'].lower()}:*** *used {record['amount'] if record['amount'] else '0'} "
                     f"{'times' if record['amount'] != 1 else 'time'}*"
                     for record in result]
         pag = EmbedPaginator(ctx, entries=entries, per_page=20, show_entry_count=True)
         pag.embed.title = title
         return await pag.paginate()
     else:
         command = self.bot.get_command(name)
         async with self.bot.db.acquire() as con:
             if mode == "global":
                 amount = await con.fetchval(f"SELECT amount from global_counters WHERE "
                                             f"command=$tag${command.name.lower()}$tag$")
                 title = f"Global Counter for {command.name.title()}"
             else:
                 amount = await con.fetchval(f"SELECT amount FROM guild_counters WHERE "
                                             f"command=$tag${command.name.lower()}$tag$")
                 title = f"Server Counter for {command.name.title()}"
         description = (f"***{command.name}:*** *used {amount if amount else '0'} "
                        f"{'times' if amount != 1 else 'time'}*")
         embed = discord.Embed(title=title, description=description, color=discord.Color.blue())
         return await ctx.channel.send(embed=embed)
コード例 #9
0
ファイル: core.py プロジェクト: mcgregory/Rotmg-Discord-Bot
    async def help(self, ctx, *, opt: str = None):
        if opt:
            cog = self.client.get_cog(opt.capitalize())
            if not cog:
                command = self.client.get_command(opt.lower())
                if not command:
                    return await ctx.send(
                        embed=discord.Embed(description=f"That command/cog does not exist. Use `{ctx.prefix}help` to see all the commands.",
                                            color=discord.Color.red(), ))

                embed = discord.Embed(title=command.name, description=command.description, colour=discord.Color.blue())
                usage = "\n".join([ctx.prefix + x.strip() for x in command.usage.split("\n")])
                embed.add_field(name="Usage", value=f"```{usage}```", inline=False)
                if len(command.aliases) > 1:
                    embed.add_field(name="Aliases", value=f"`{'`, `'.join(command.aliases)}`")
                elif len(command.aliases) > 0:
                    embed.add_field(name="Alias", value=f"`{command.aliases[0]}`")
                return await ctx.send(embed=embed)
            cog_commands = cog.get_commands()
            embed = discord.Embed(title=opt.capitalize(), description=f"{cog.description}\n\n`<>` Indicates a required argument.\n"
                                                                      "`[]` Indicates an optional argument.\n", color=discord.Color.blue(), )
            embed.set_author(name=f"{self.client.user.name} Help Menu", icon_url=self.client.user.avatar_url)
            embed.set_thumbnail(url=self.client.user.avatar_url)
            embed.set_footer(
                text=f"Use {ctx.prefix}help <command> for more information on a command.")
            for cmd in cog_commands:
                if cmd.hidden is False:
                    name = ctx.prefix + cmd.usage
                    if len(cmd.aliases) > 1:
                        name += f" | Aliases – `{'`, `'.join([ctx.prefix + a for a in cmd.aliases])}`"
                    elif len(cmd.aliases) > 0:
                        name += f" | Alias – {ctx.prefix + cmd.aliases[0]}"
                    embed.add_field(name=name, value=cmd.description, inline=False)
            return await ctx.send(embed=embed)

        all_pages = []
        page = discord.Embed(title=f"{self.client.user.name} Help Menu",
            description="Thank you for using Ooga-Booga! Please direct message `Darkmatter#7321` if you find bugs or have suggestions!",
            color=discord.Color.blue(), )
        page.set_thumbnail(url=self.client.user.avatar_url)
        page.set_footer(text="Use the reactions to flip pages.")
        all_pages.append(page)
        page = discord.Embed(title=f"{self.client.user.name} Help Menu", colour=discord.Color.blue())
        page.set_thumbnail(url=self.client.user.avatar_url)
        page.set_footer(text="Use the reactions to flip pages.")
        page.add_field(name="About Ooga-Booga",
            value="This bot was built to as a way to give back to the ROTMG community by facilitating more organized raids and allowing "
                  "server owners to create new and exciting raiding discords for the community!", inline=False, )
        page.add_field(name="Getting Started",
            value=f"For a full list of commands, see `{ctx.prefix}help`. Browse through the various commands to get comfortable with using "
                  "them, and as always if you have questions or need help – DM `Darkmatter#7321`!", inline=False, )
        all_pages.append(page)
        for _, cog_name in enumerate(sorted(self.client.cogs)):
            if cog_name in ["Owner", "Admin"]:
                continue
            cog = self.client.get_cog(cog_name)
            cog_commands = cog.get_commands()
            if len(cog_commands) == 0:
                continue
            page = discord.Embed(title=cog_name, description=f"{cog.description}\n\n`<>` Indicates a required argument.\n"
                                                             "`[]` Indicates an optional argument.\n",
                color=discord.Color.blue(), )
            page.set_author(name=f"{self.client.user.name} Help Menu", icon_url=self.client.user.avatar_url)
            page.set_thumbnail(url=self.client.user.avatar_url)
            page.set_footer(text=f"Use the reactions to flip pages | Use {ctx.prefix}help <command> for more information on a command.")
            for cmd in cog_commands:
                if cmd.hidden is False:
                    name = ctx.prefix + cmd.usage
                    if len(cmd.aliases) > 1:
                        name += f" | Aliases – `{'`, `'.join([ctx.prefix + a for a in cmd.aliases])}`"
                    elif len(cmd.aliases) > 0:
                        name += f" | Alias – `{ctx.prefix+cmd.aliases[0]}`"
                    page.add_field(name=name, value=cmd.description, inline=False)
            all_pages.append(page)
        paginator = EmbedPaginator(self.client, ctx, all_pages)
        await paginator.paginate()
コード例 #10
0
 async def serverlink_list(self, ctx):
     entries = [f"<#{entry['channel_id']}>" for entry in await self.get_serverlink_channels(ctx)]
     pag = EmbedPaginator(ctx, entries=entries, per_page=20, show_entry_count=False)
     pag.embed.title = "Registered ServerLink Channels"
     return await pag.paginate()
コード例 #11
0
 async def serverlink_listings(self, ctx):
     entries = await self.get_public_channels()
     pag = EmbedPaginator(ctx, entries=entries, per_page=10, show_entry_count=True, show_index=False)
     pag.embed.title = "Public ServerLink Channels"
     return await pag.paginate()