Beispiel #1
0
    async def roles_list_role_grants(self, ctx, user: discord.Member = None):
        await ctx.message.delete()

        if user is None:
            user = ctx.message.author
        else:
            my_staff_rank = perms.get_staff_rank(ctx.message.author)
            their_staff_rank = perms.get_staff_rank(user)

            if their_staff_rank > my_staff_rank:
                await ctx.send(embed=interface.error_message(
                    "Access Denied",
                    "You cannot check the access of someone of a higher staff rank."
                ))
                return

        giveable_role_ids = dict()

        for role in user.roles:
            role_ids = db.get_grantable_roles(role)
            if role_ids:
                giveable_role_ids[role.name] = role_ids

        if giveable_role_ids:
            giveable_roles = OrderedDict()

            for rname, rids in giveable_role_ids.items():
                giveable_roles[rname] = list(
                    set([ctx.author.guild.get_role(rid).name for rid in rids]))
                giveable_roles[rname].sort()

            rolelist = ""

            for granter, granted in reversed(giveable_roles.items()):
                rolelist += f"{granter} grants:\n"

                for rname in granted:
                    rolelist += f":white_small_square: {rname}\n"

                rolelist += "\n"

            rolelist = rolelist.strip()

            await ctx.send(embed=interface.normal_message(
                "Role Grant List",
                f"**{user}** can give or take the following roles:\n\n{rolelist}",
                f"User ID: {user.id}",
            ))
        else:
            await ctx.send(embed=interface.normal_message(
                "Role Grant List",
                f"**{user}** cannot give or take any roles.",
                f"User ID: {user.id}"))
Beispiel #2
0
 async def admin_ping(self, ctx):
     """
     Test WebSocket protocol (Discord API) latency.
     """
     await ctx.message.delete()
     await ctx.send(
         embed=interface.normal_message(
             "Ping", f"WebSocket protocol latency: {round(self.bot.latency * 1000, 3)} ms"
         )
     )
Beispiel #3
0
    async def admin_list_commands(self, ctx, user: discord.Member = None):
        """
        List the commands that you have access to.

        Alternatively, list the commands that someone else has access to.
        """
        await ctx.message.delete()

        if user is None:
            user = ctx.message.author
        else:
            my_staff_rank = perms.get_staff_rank(ctx.message.author)
            their_staff_rank = perms.get_staff_rank(user)

            if their_staff_rank > my_staff_rank:
                await ctx.send(
                    embed=interface.error_message(
                        "Error", "You cannot check the access of someone of a higher staff rank."
                    )
                )
                return

        granted_cmds = OrderedDict()

        for role in user.roles:
            role_cmds = db.get_command_priv_cmds(role)

            if not role_cmds:
                continue

            granted_cmds[role.name] = role_cmds
            granted_cmds[role.name].sort()

        if not granted_cmds:
            await ctx.send(
                embed=interface.normal_message(
                    "Command Access", f"**{user}** cannot use any commands.", f"User ID: {user.id}"
                )
            )

            return

        cmdlist = ""

        for rname, cmds in reversed(granted_cmds.items()):
            cmdlist += f"{rname} grants:\n"
            
            for cmd in cmds:
                cmdlist += f":white_small_square: {cmd}   "

            cmdlist += "\n"

        cmdlist = cmdlist.strip()
    
        await ctx.send(
            embed=interface.normal_message(
                "Command Access",
                f"**{user}** can use the following commands:\n\n{cmdlist}",
                f"User ID: {user.id}",
            )
        )        
Beispiel #4
0
 async def roles_match_role(self, ctx, *, args):
     await ctx.send(embed=interface.normal_message(
         "Role Lookup",
         f"Matching Role: {utils.get_role_by_name(ctx, args)}"))
Beispiel #5
0
 async def cms_list_cogs(self, ctx):
     cog_list = "\n".join(self.bot.extensions)
     await ctx.send(embed=interface.normal_message("Cog Management System", f"Currently loaded cogs:\n{cog_list}"))
     await ctx.message.delete()