Fixed playing rotate nullref

This commit is contained in:
Kwoth
2022-03-21 11:07:42 +01:00
parent 57e65e5515
commit 798b66db9b

View File

@@ -11,6 +11,7 @@ public sealed class PlayingRotateService : INService, IReadyExecutor
private readonly SelfService _selfService; private readonly SelfService _selfService;
private readonly Replacer _rep; private readonly Replacer _rep;
private readonly DbService _db; private readonly DbService _db;
private readonly DiscordSocketClient _client;
public PlayingRotateService( public PlayingRotateService(
DiscordSocketClient client, DiscordSocketClient client,
@@ -22,6 +23,7 @@ public sealed class PlayingRotateService : INService, IReadyExecutor
_db = db; _db = db;
_bss = bss; _bss = bss;
_selfService = selfService; _selfService = selfService;
_client = client;
if (client.ShardId == 0) if (client.ShardId == 0)
_rep = new ReplacementBuilder().WithClient(client).WithProviders(phProviders).Build(); _rep = new ReplacementBuilder().WithClient(client).WithProviders(phProviders).Build();
@@ -29,6 +31,9 @@ public sealed class PlayingRotateService : INService, IReadyExecutor
public async Task OnReadyAsync() public async Task OnReadyAsync()
{ {
if (_client.ShardId != 0)
return;
using var timer = new PeriodicTimer(TimeSpan.FromMinutes(1)); using var timer = new PeriodicTimer(TimeSpan.FromMinutes(1));
var index = 0; var index = 0;
while (await timer.WaitForNextTickAsync()) while (await timer.WaitForNextTickAsync())