Added a few things.

This commit is contained in:
2026-02-26 22:25:14 +00:00
parent d4013d1bb8
commit 9589447019
2 changed files with 102 additions and 21 deletions

View File

@@ -1,10 +1,21 @@
using System.Globalization;
using System.Net.NetworkInformation;
using System.Security.Cryptography.X509Certificates;
using System.Text.Json;
using Valour.Sdk.Models;
namespace SkyBot
{
public static class Utils
{
private static readonly HttpClient _http = new HttpClient();
private static long _valourUserCount;
public static long ValourUserCount => _valourUserCount;
public static bool IsSingleEmoji(string input)
{
if (string.IsNullOrWhiteSpace(input))
@@ -45,5 +56,29 @@ namespace SkyBot
Console.WriteLine($"Channel {channel} was not found in the cache.");
};
}
public static async Task UpdateValourUserCountAsync()
{
try
{
var response = await _http.GetStringAsync("https://api.valour.gg/api/users/count");
_valourUserCount = JsonSerializer.Deserialize<long>(response);
Console.WriteLine($"Valour user count updated: {_valourUserCount}");
}
catch (Exception ex)
{
Console.WriteLine($"Failed to update Valour user count: {ex.Message}");
}
}
public static void StartValourUserUpdater()
{
var timer = new System.Timers.Timer(300_000);
timer.Elapsed += async (_, _) => await UpdateValourUserCountAsync();
timer.AutoReset = true;
timer.Start();
}
};
};