Message Queue to prevent weird behavior
See original GitHub issueHey there,
my bot currently has 2 commands. /warn <IUser> <string>
and /unwarn <IUser> <string>
.
While it’s no problem if only one person can warn and unwarn members, it got complicated after I gave those rights to a second person.
Scenario:
User A will be warned by myself and another moderator. If this happens at the same time, I don’t havve anything in my code to queue these commands and make them execute one after another. They both get executed at the same time. Thus User A will get Warning 3 for my command execution and again Warning 3 for the moderators command execution.
So far I’ve tried it with SimpleSemaphore but with this approach I only get the following message in my log: A MessageReceived handler is blocking the gateway task.
Is there a built in Message queue?
If not, is there a need for in this project? Because I really need it and would create a Pull request if finished.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
I’ve come up with a solution.
There is a class called StaticLock
To use you make it the following in your command:
Run it in a new Task.Run() and then use a lock. This should fix it 🤔