Answer the question
In order to leave comments, you need to log in
How to make commands in python discord bot available only to server admin?
it is necessary that some commands entered by a regular user of the server be inaccessible to him.
Answer the question
In order to leave comments, you need to log in
There are many options, even inside a function with command processing, even with a decorator. I think a decorator would be better. Discordpy has a special decorator for this, so you don't have to come up with your own.
@commands.has_guild_permissions(administrator=True)
from discord.ext import commands
@bot.command()
@commands.has_guild_permissions(administrator=True)
async def test(ctx):
ctx.send('hello world')
@test.error
async def test_error(ctx, error):
if isinstance(error, commands.errors.MissingPermissions):
await ctx.send('Недостаточно прав')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question