Answer the question
In order to leave comments, you need to log in
How to make the bot in discord give out roles after the correct answer to the question?
See how the bot works, you write a command in the channel, after that the bot asks you a question in private messages, and after the correct answer, it should issue a role in the channel, but the role is temporary. So I don’t understand how to make this moment so that after giving the correct answer in private messages, the bot will automatically issue the role for a while.
Answer the question
In order to leave comments, you need to log in
It is necessary to store the user base, and for each user to store the id, state and timestamp.
The state can be one of the following:
* start - the user did nothing
* the user was asked a question
* the user received the role, then the time field stores the moment when the role was received.
Then, when responding to a command or a message, you look up the user ID in the database, and check that it is in the correct state. Those. if you react to a personal, then the user should be able to "ask a question". At the right moments, you save a new state to the database, for example, "question asked" -> "role granted".
To remove a role, from time to time you look in the database for users in the "issued role" state, for whom a lot of time has passed since the issuance, remove the role for them and write a new state (starting) to the database.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question