I created an Administration cog a long time ago but I didn't limit it for administrators. I tried to limit it for admins but I was only able to limit the cog a single role. How do I make it that the cog is limited to people who have Admin powers?
Current Code:
async def cog_check(self, ctx):
admin = get(ctx.guild.roles, name="Admin")
return admin in ctx.author.roles
You can use discord.ext.commands.has_permissions() if you need that the person executing the command has a certain permission, otherwise you an also use permissions_for() that return a Permissions object and use the permission administrator
It would look like this
async def cog_check(self, ctx):
return ctx.channel.permissions_for(ctx.author).administrator
this coroutine will return True if and only if the member has the permission administrator (in one of his roles or if he was specified the permission in a channel)