Rewrite xp gain loop. Hopefully faster and fixes xp freeze bugs.

This commit is contained in:
Kwoth
2022-07-07 17:09:11 +00:00
parent 470bb9657f
commit 744018802f
5 changed files with 260 additions and 167 deletions

View File

@@ -221,7 +221,7 @@ public class StreamRoleService : IReadyExecutor, INService
}
private async ValueTask RescanUser(IGuildUser user, StreamRoleSettings setting, IRole addRole = null)
=> await _queueRunner.Enqueue(() => RescanUserInternal(user, setting, addRole));
=> await _queueRunner.EnqueueAsync(() => RescanUserInternal(user, setting, addRole));
private async Task RescanUserInternal(IGuildUser user, StreamRoleSettings setting, IRole addRole = null)
{
@@ -239,7 +239,7 @@ public class StreamRoleService : IReadyExecutor, INService
&& setting.Blacklist.All(x => x.UserId != user.Id)
&& user.RoleIds.Contains(setting.FromRoleId))
{
await _queueRunner.Enqueue(async () =>
await _queueRunner.EnqueueAsync(async () =>
{
try
{
@@ -277,7 +277,7 @@ public class StreamRoleService : IReadyExecutor, INService
//check if user is in the addrole
if (user.RoleIds.Contains(setting.AddRoleId))
{
await _queueRunner.Enqueue(async () =>
await _queueRunner.EnqueueAsync(async () =>
{
try
{