How to use the discord.ext.commands.check function in discord

To help you get started, we’ve selected a few discord 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 Deivedux / Quote / cogs / OwnerOnly.py View on Github external
	@commands.check(is_owner)
	async def shutdown(self, ctx):
		await ctx.send(content = success_string + ' **Shutting down.**')
		DBService.commit()
		await self.bot.logout()
github nh-server / Kurisu / utils / checks.py View on Github external
def is_staff(role):
    async def predicate(ctx):
        if isinstance(ctx.channel, discord.abc.GuildChannel):
            return await check_staff(ctx, role) if not ctx.author == ctx.guild.owner else True
        else:
            return await check_staff(ctx, role)
    return commands.check(predicate)
github reswitched / robocop-ng / cogs / mod_note.py View on Github external
    @commands.check(check_if_staff)
    @commands.command(aliases=["addnoteid"])
    async def noteid(self, ctx, target: int, *, note: str = ""):
        """Adds a note to a user by userid, staff only."""
        userlog(target, ctx.author, note,
                "notes")
        await ctx.send(f"{target.mention}: noted!")
github dashwav / yin-bot / cogs / utils / checks.py View on Github external
def is_mod():
    async def pred(ctx):
        return await check_guild_permissions(ctx, {'manage_guild': True})

    return commands.check(pred)
github MagiChau / ZonBot / checks.py View on Github external
def can_manage_message():
    def predicate(ctx):
        try:
            return ctx.message.channel.permissions_for(ctx.message.author).manage_messages
        except:
            return False
    return commands.check(predicate)
github Rapptz / RoboDanny / cogs / tags.py View on Github external
def suggest_box():
    """Custom commands.guild_only with different error checking."""
    def pred(ctx):
        if ctx.guild is None:
            raise UnavailableTagCommand()
        return True
    return commands.check(pred)
github python-discord / bot / bot / decorators.py View on Github external
def with_role(*role_ids: int) -> Callable:
    """Returns True if the user has any one of the roles in role_ids."""
    async def predicate(ctx: Context) -> bool:
        """With role checker predicate."""
        return with_role_check(ctx, *role_ids)
    return commands.check(predicate)
github henry232323 / RPGBot / cogs / utils / checks.py View on Github external
def owner_or_permissions(**perms):
    def predicate(ctx):
        return role_or_permissions(ctx, lambda ctx: is_owner_check(ctx.message))

    return commands.check(predicate)
github Roxxers / roxbot / roxbot / cogs / voice.py View on Github external
def need_perms():
    def predicate(ctx):
        with db_session:
            settings = VoiceSingle.get(guild_id=ctx.guild.id)
        if settings.need_perms:
            return roxbot.utils.has_permissions_or_owner(ctx, manage_channels=True)
        else:
            return True
    return commands.check(predicate)