A
A
Andrew2021-09-01 23:28:53
Python
Andrew, 2021-09-01 23:28:53

How to prevent strangers from entering a command?

I have a code that waits for a message with a certain value (this is not very important)

But while the bot is waiting for a message, anyone else can interrupt it and enter its value

here is the code

async def Book2():
        now = datetime.datetime.now()

        def NumOfBook(m):
            if m.content == '1':
                return m.content == '1'

            elif m.content == '2':
                return m.content == '2' 

            elif m.content == '3':
                return m.content == '3' 

            elif m.content == '4':
                return m.content == '4' 

        msg_book = await bot.wait_for('message', check=NumOfBook)


How do I do a command user validation?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question