How to use the cogs.utils.checks.admin_or_permissions function in Cogs

To help you get started, we’ve selected a few Cogs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CarlGroth / Carl-Bot / cogs / mod.py View on Github external
    @checks.admin_or_permissions(manage_server=True)
    async def plonk(self, ctx, user: discord.Member=None, command: str=None, subcommand: str = None):
        if user is None:
            return ctx.send("You need to mention a user to plonk")
        if command is None:
            #global PLONK
            a = self.c.execute(
                'SELECT plonked FROM userconfig WHERE (guild_id=? AND user_id=?)', (ctx.guild.id, user.id))
            a = a.fetchone()
            if a is not None:
                if a[0]:
                    #user is plonked
                    self.c.execute(
                        'UPDATE userconfig SET plonked=? WHERE (guild_id=? AND user_id=?)', (False, ctx.guild.id, user.id))
                    self.conn.commit()
                    return await ctx.send(f"**{user.name}** is no longer banned from using the bot in this server.")
                else:
github CarlGroth / Carl-Bot / cogs / mod.py View on Github external
    @checks.admin_or_permissions(manage_server=True)
    async def remove_word(self, ctx, *, word: str=None):
        if word is None:
            return await ctx.send("You need to specify a word to remove from the blacklist")
        slugified_word = self.do_slugify(word)
        if slugified_word not in self.blacklist[str(ctx.guild.id)]:
            return await ctx.send("You don't seem to be blacklisting that word")
        self.c.execute('''DELETE FROM blacklist WHERE (guild_id=? AND word=?)''',
                        (ctx.guild.id, slugified_word))
        self.conn.commit()
        self.blacklist[str(ctx.guild.id,)].remove(slugified_word)
        word = self.clean_string(word)
        await ctx.send(f'Removed "{word}" from the blacklist')
github TrustyJAID / Trusty-cogs-archive / star / star.py View on Github external
    @checks.admin_or_permissions(manage_channels=True)
    async def starboard(self, ctx):
        """Commands for managing the starboard"""
        if ctx.invoked_subcommand is None:
            await self.bot.send_cmd_help(ctx)
github aikaterna / aikaterna-cogs / autoeconomy / autoeconomy.py View on Github external
    @checks.admin_or_permissions(manage_server=True)
    @commands.group(pass_context=True)
    async def autoeconomy(self, ctx):
        """Configuration options for auto-registering Economy accounts."""
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
            return
github henry232323 / RPGBot / cogs / settings.py View on Github external
    @checks.admin_or_permissions()
    async def setprefix(self, ctx, value: str):
        """Set the server's custom prefix. The default prefix will continue to work.
        Example:
            rp!setprefix ! --> !setprefix rp!

        Requires Bot Moderator or Bot Admin"""
        self.bot.prefixes[str(ctx.guild.id)] = value
        await ctx.send(await _(ctx, "Updated server prefix"))
github dashwav / yin-bot / cogs / roles.py View on Github external
    @checks.admin_or_permissions(manage_roles=True)
    async def assignableroles(self, ctx):
        """Manage server's self-assignable roles."""
        if ctx.invoked_subcommand is None:
            message = ' \n'
            assignable_roles = []
            assignable_role_ids = await \
                self.bot.pg_utils.get_assignable_roles(ctx.guild.id)
            for role in ctx.guild.roles:
                if role.id in assignable_role_ids:
                    assignable_roles.append(role)
            for role in assignable_roles:
                message += f'{role.name}\n'
            local_embed = discord.Embed(
                title='Current self-assignable roles:',
                description=message,
                color=0x419400
github CarlGroth / Carl-Bot / cogs / meta.py View on Github external
    @checks.admin_or_permissions(manage_roles=True)
    async def botpermissions(self, ctx):
        """Shows the bot's permissions.

        This is a good way of checking if the bot has the permissions needed
        to execute the commands it wants to execute.

        To execute this command you must have Manage Roles permissions or
        have the Bot Admin role. You cannot use this in private messages.
        """
        channel = ctx.channel
        member = ctx.message.guild.me
        await self.say_permissions(ctx, member, channel)
github Cog-Creators / Red-DiscordBot / cogs / economy.py View on Github external
    @checks.admin_or_permissions(manage_server=True)
    async def economyset(self, ctx):
        """Changes economy module settings"""
        server = ctx.message.server
        settings = self.settings[server.id]
        if ctx.invoked_subcommand is None:
            msg = "```"
            for k, v in settings.items():
                msg += "{}: {}\n".format(k, v)
            msg += "```"
            await self.bot.send_cmd_help(ctx)
            await self.bot.say(msg)
github AznStevy / Maybe-Useful-Cogs / leveler / leveler.py View on Github external
    @checks.admin_or_permissions(manage_server=True)
    @lvladmin.command(name="private", pass_context=True, no_pm=True)
    async def lvlprivate(self, ctx, all:str=None):
        """Toggles if lvl alert is a private message to the user."""
        server = ctx.message.server
        # deals with ENABLED array, not disabled

        if "private_lvl_msg" not in self.settings.keys():
            self.settings["private_lvl_msg"] = []

        if all != None:
            if user.id == self.owner:
                if all == "disableall":
                    self.settings["private_lvl_msg"] = []
                    await self.bot.say("**Private level-up messages disabled for all servers.**")
                elif all == "enableall":
                    self.settings["private_lvl_msg"] = []
github Gr8z / Legend-Cogs / challenges / challenges.py View on Github external
    @checks.admin_or_permissions(manage_server=True)
    async def chalset(self, ctx):
        """Sets Challenges settings"""
        server = ctx.message.server
        self.add_defualt_settings(server)

        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)