M
M
MrPipka2021-01-27 08:20:15
Python
MrPipka, 2021-01-27 08:20:15

How to make it so that if a person does not have rights to the command, then he writes that you do not have rights to this?

I'm new to programming, I'm trying to create a bot, I've almost finished it, but in order to put it on some kind of monitoring, it needs to say about an error that there are no rights. I've searched all over the internet, but I can't find the answer anywhere. Help.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Developer, 2021-01-27
@samodum

Learn if, newbie

V
Vladislav Lyskov, 2021-01-27
@Vlatqa

permission = True

if(permission != True):
    print('нет прав')

do not thank

M
MinTnt, 2021-01-27
@MinTnt

Well, there are a couple of options:
1) You can create a list with an ID to whom this command is allowed. And then check whether the ID of the person who entered the command is in the list. I don’t know the discord API commands well, so an approximate view for such a check:

Acces_to_cmd = [273747, 2848, ...]
If message.author.id in Acces_to_cmd:

2) Or you can check by user roles to access cmd (if there is one, it continues to perform the task):
If role in user.roles:

K
Kendric Folkin, 2021-01-27
@kendric

def check()
    permission = 1
    if permission == "1":
        return(1)
    else:
       return(0)

def test():
   if check() == "1":
       a = input()
       print(a)
    else:
        print("Недостаточно прав")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question