A
A
Artem Shirkalin2021-07-23 11:13:45
Python
Artem Shirkalin, 2021-07-23 11:13:45

How to make a timer in the mute command?

How to make a mut command timer like this
!mute @test 13m test

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-07-23
@Vindicar

Take and do. What exactly is the question? What exactly doesn't work?
Dumb frontal option - use a simple call chain

# выдать мьют
await asyncio.sleep(время) # подождать
# снять мьют
in the !mute command handler. But the problem is that if the bot is restarted while waiting, it will forget about this timer - and the user will remain muted. In addition, it will be problematic to manage the list of muted ones.
The second thought is that in the !mute handler we issue a mute, calculate the time when it needs to be removed, and write the user, the server, the time of removal and the reason to the database.
Then, once a minute, we check this database for the presence of expired mutes, extract them and remove them.
Plus, the mute will survive the restart of the bot, and you can always see who-when-how-for-what.
Minus - since we check once a minute, the terms and balances less than a minute will be rounded up. It can be fixed by increasing the frequency of the check, but it’s also not worth it to peck the bot with this check in vain.
The mute itself is easiest to implement by creating an appropriate role, and issuing / removing it to the user.
Something like this. For specific answers "which methods to call" - see the documentation . If you need help with specific errors, create a new question, provide the code (format with the </> button!) and the full text of the error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question