Answer the question
In order to leave comments, you need to log in
How to make access by id?
Tell me please. How can I implement access to a specific command by user id?
Thank you.
Answer the question
In order to leave comments, you need to log in
Here's an example from the documentation:
def check_if_it_is_me(ctx):
return ctx.message.author.id == 85309593344815104 #id человека
@bot.command()
@commands.check(check_if_it_is_me) #проверка от того ли человека пришла команда
async def only_for_me(ctx):
#делаете что-то
@bot.command()
@commands.has_any_role('Moder','admin', 492212595072434186)
async def command(ctx):
#и делаете что-то
It depends on how and which teams you want to split.
You can make two types of user. An administrator and a regular user, and accordingly make a condition, if the user is an administrator, allow him to use all commands, otherwise allow him to use a limited range of commands.
To do this, you need to save all administrators to yourself and, at each request for a command, see if the user can execute it. Roughly the same can be done with several groups of users.
I don’t know how to do this in DISCORD, I write bots on telegrams, but try to remake it under DISCORD!
Here is the code:
@bot.message_handler(commands=['admins'])
def admin(message):
if message.chat.id == 123456789: # Вместо 123456789 напиши свой ID, только не ставь кавычки!
bot.send_message(message.chat.id, 'Вы в Админ-Панели!')
else:
bot.send_message(message.chat.id, 'Нет ДОСТУПА Обратитесь к Администрации!')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question