From 56dd6a61663dbd9a605cf5340e18c671779b017a Mon Sep 17 00:00:00 2001 From: skyjoshua Date: Sat, 28 Feb 2026 21:59:37 +0000 Subject: [PATCH] Dev Branch yay! --- Commands/HelpCommand.cs | 8 ++-- Commands/SourceCommand.cs | 14 +++++++ Program.cs | 4 ++ utils.cs | 82 --------------------------------------- 4 files changed, 22 insertions(+), 86 deletions(-) create mode 100644 Commands/SourceCommand.cs delete mode 100644 utils.cs diff --git a/Commands/HelpCommand.cs b/Commands/HelpCommand.cs index 493d519..a8c84d5 100644 --- a/Commands/HelpCommand.cs +++ b/Commands/HelpCommand.cs @@ -9,9 +9,9 @@ public static class HelpComamnd string helpMessage = $@"**Reactor Commands**: - `{prefix}help` - Shows this list."; - if (channelCache.TryGetValue(channelId, out var channel)) - { - await channel.SendMessageAsync($"{memberPing}\n{helpMessage}"); - } + if (channelCache.TryGetValue(channelId, out var channel)) + { + await channel.SendMessageAsync($"{memberPing}\n{helpMessage}"); + } } } \ No newline at end of file diff --git a/Commands/SourceCommand.cs b/Commands/SourceCommand.cs new file mode 100644 index 0000000..1b74bde --- /dev/null +++ b/Commands/SourceCommand.cs @@ -0,0 +1,14 @@ +using Valour.Sdk.Models; + +namespace Reactor.Commands; + +public static class SourceComamnd +{ + public static async Task Execute(Dictionary channelCache, long channelId, string memberPing) + { + if (channelCache.TryGetValue(channelId, out var channel)) + { + await channel.SendMessageAsync($"{memberPing} You can see my source code here: https://github.com/SkyJoshua/Reactor"); + } + } +} \ No newline at end of file diff --git a/Program.cs b/Program.cs index 39a91d6..cc6b9af 100644 --- a/Program.cs +++ b/Program.cs @@ -106,6 +106,10 @@ namespace Reactor case "help": await HelpComamnd.Execute(_channelCache, channelId, _prefix, memberPing); break; + + case "source": + await SourceComamnd.Execute(_channelCache, channelId, memberPing); + break; } } diff --git a/utils.cs b/utils.cs deleted file mode 100644 index 8ff18a9..0000000 --- a/utils.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Globalization; -using System.Text.Json; -using Valour.Sdk.Models; - -namespace Reactor -{ - 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)) - return false; - - input = input.Trim(); - - var enumerator = StringInfo.GetTextElementEnumerator(input); - int count = 0; - - while (enumerator.MoveNext()) - count++; - - return count == 1; - } - - public static bool ContainsAny(string input, params string[] values) - { - var lower = input.ToLower(); - - foreach (var value in values) - { - if (lower.Contains(value.ToLower())) - return true; - }; - - return false; - } - - public static async Task SendReplyAsync(Dictionary channelCache, long channel, string reply) - { - if (channelCache.TryGetValue(channel, out var chan)) - { - await chan.SendMessageAsync(reply); - } - else - { - 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(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(); - } - }; -}; \ No newline at end of file