public MovingWorker(ILogger <MovingWorker> logger, IOptionsMonitor <AppOptions> appOptionsAccessor, IOptionsMonitor <DiscordOptions> discordOptionsAccessor, IDiscordConnectionStorage discordConnectionStorage, HubConnection hub) { this.logger = logger; this.appOptions = appOptionsAccessor.CurrentValue; this.discordOptions = discordOptionsAccessor.CurrentValue; this.discordConnectionStorage = discordConnectionStorage; this.hub = hub; hub.Reconnecting += Hub_Reconnecting; hub.Reconnected += Hub_Reconnected; hub.On <string, int?, int?>("ChangeFrequency", async(clientId, from, to) => { try { logger.LogDebug("Got ChangeFrequency message from {clientId} to change from {fromFrequency} to {toFrequency}", clientId, from, to); await CreateVoiceChannelAndMoveAsync(clientId, to); } catch (Exception ex) { logger.LogError(ex, "Cannot handle changing frequency of {0} from {1} to {2}!", clientId, from, to); } }); }