Discord-bot + server updates
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Linq;
|
||||
using Discord;
|
||||
using Discord.Interactions;
|
||||
using Discord.Rest;
|
||||
@@ -872,16 +869,17 @@ internal class DiscordBot : IHostedService
|
||||
string? SenderHashedCid,
|
||||
string Message);
|
||||
|
||||
private async Task UpdateStatusAsync(CancellationToken token)
|
||||
private async Task UpdateStatusAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
while (!token.IsCancellationRequested)
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
var endPoint = _connectionMultiplexer.GetEndPoints().First();
|
||||
var onlineUsers = await _connectionMultiplexer.GetServer(endPoint).KeysAsync(pattern: "UID:*").CountAsync().ConfigureAwait(false);
|
||||
var keys = _connectionMultiplexer.GetServer(endPoint).KeysAsync(pattern: "UID:*");
|
||||
var onlineUsers = await keys.CountAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
_logger.LogInformation("Users online: " + onlineUsers);
|
||||
_logger.LogInformation("Users online: " + onlineUsers);
|
||||
await _discordClient.SetActivityAsync(new Game("Lightless for " + onlineUsers + " Users")).ConfigureAwait(false);
|
||||
await Task.Delay(TimeSpan.FromSeconds(10)).ConfigureAwait(false);
|
||||
await Task.Delay(TimeSpan.FromSeconds(10), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user