From 675ea71948fabb053c638c910b87076219e64cc7 Mon Sep 17 00:00:00 2001 From: skyjoshua Date: Sat, 18 Apr 2026 03:21:02 +0100 Subject: [PATCH] v0.3.1.0 - Added a few commands + fixes --- SkyBot/Commands/CommandTemplate.cs | 1 - SkyBot/Commands/Dev/Delete.cs | 4 +-- SkyBot/Commands/Dev/React.cs | 2 -- SkyBot/Commands/Fun/Echo.cs | 2 -- SkyBot/Commands/Info/Help.cs | 2 -- SkyBot/Commands/Info/Source.cs | 20 ++++++++++++++ SkyBot/Commands/Info/Version.cs | 44 ++++++++++++++++++++++++++++++ SkyBot/Config.cs | 2 +- SkyBot/Helpers/MessageHelper.cs | 1 - SkyBot/SkyBot.csproj | 2 +- 10 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 SkyBot/Commands/Info/Source.cs create mode 100644 SkyBot/Commands/Info/Version.cs diff --git a/SkyBot/Commands/CommandTemplate.cs b/SkyBot/Commands/CommandTemplate.cs index 3e8a324..2385ab1 100644 --- a/SkyBot/Commands/CommandTemplate.cs +++ b/SkyBot/Commands/CommandTemplate.cs @@ -13,7 +13,6 @@ namespace SkyBot.Commands public async Task Execute(CommandContext ctx) { - if (!ctx.ChannelCache.TryGetValue(ctx.Channel.Id, out var channel)) return; } } } \ No newline at end of file diff --git a/SkyBot/Commands/Dev/Delete.cs b/SkyBot/Commands/Dev/Delete.cs index 5ea505c..7e21bd2 100644 --- a/SkyBot/Commands/Dev/Delete.cs +++ b/SkyBot/Commands/Dev/Delete.cs @@ -15,8 +15,6 @@ namespace SkyBot.Commands public async Task Execute(CommandContext ctx) { - if (!ctx.ChannelCache.TryGetValue(ctx.Channel.Id, out var channel)) return; - if (!PermissionHelper.IsOwner(ctx.Member)) { await MessageHelper.ReplyAsync(ctx, "You do not have permission to execute this command."); @@ -42,7 +40,7 @@ namespace SkyBot.Commands return; } - if (replyMsg!.AuthorUserId != ctx.Client.Me.Id && !await PermissionHelper.HasPermAsync(ctx.Planet.MyMember, [ChatChannelPermissions.ManageMessages], channel)) + if (replyMsg!.AuthorUserId != ctx.Client.Me.Id && !await PermissionHelper.HasPermAsync(ctx.Planet.MyMember, [ChatChannelPermissions.ManageMessages], ctx.Channel)) { await MessageHelper.ReplyAsync(ctx, "I do not have permission to delete other members' messages in this channel."); return; diff --git a/SkyBot/Commands/Dev/React.cs b/SkyBot/Commands/Dev/React.cs index ada0dc2..dae8f1f 100644 --- a/SkyBot/Commands/Dev/React.cs +++ b/SkyBot/Commands/Dev/React.cs @@ -14,8 +14,6 @@ namespace SkyBot.Commands public async Task Execute(CommandContext ctx) { - if (!ctx.ChannelCache.TryGetValue(ctx.Channel.Id, out var channel)) return; - if (!PermissionHelper.IsOwner(ctx.Member)) { await MessageHelper.ReplyAsync(ctx, "You do not have permission to execute this command."); diff --git a/SkyBot/Commands/Fun/Echo.cs b/SkyBot/Commands/Fun/Echo.cs index 9174252..47f3f1e 100644 --- a/SkyBot/Commands/Fun/Echo.cs +++ b/SkyBot/Commands/Fun/Echo.cs @@ -19,8 +19,6 @@ namespace SkyBot.Commands public async Task Execute(CommandContext ctx) { - if (!ctx.ChannelCache.TryGetValue(ctx.Channel.Id, out var channel)) return; - string reply = string.Join(' ', ctx.Args); if (string.IsNullOrWhiteSpace(reply)) { diff --git a/SkyBot/Commands/Info/Help.cs b/SkyBot/Commands/Info/Help.cs index fa7b495..6a12c81 100644 --- a/SkyBot/Commands/Info/Help.cs +++ b/SkyBot/Commands/Info/Help.cs @@ -17,8 +17,6 @@ namespace SkyBot.Commands public async Task Execute(CommandContext ctx) { - if (!ctx.ChannelCache.TryGetValue(ctx.Channel.Id, out var channel)) return; - var categories = CommandRegistry.Categories .Where(c => c.Key != "template") .Where(c => c.Key != "dev" || PermissionHelper.IsOwner(ctx.Member)) diff --git a/SkyBot/Commands/Info/Source.cs b/SkyBot/Commands/Info/Source.cs new file mode 100644 index 0000000..1cb8247 --- /dev/null +++ b/SkyBot/Commands/Info/Source.cs @@ -0,0 +1,20 @@ +using SkyBot.Helpers; +using SkyBot.Models; + +namespace SkyBot.Commands +{ + public class Source : ICommand + { + public string Name => "source"; + public string[] Aliases => ["src"]; + public string Description => ""; + public string Category => "Info"; + public string Usage => "source"; + public string[] SubCommands => []; + + public async Task Execute(CommandContext ctx) + { + await MessageHelper.ReplyAsync(ctx, $"You can find my source code here: {Config.SourceLink}"); + } + } +} \ No newline at end of file diff --git a/SkyBot/Commands/Info/Version.cs b/SkyBot/Commands/Info/Version.cs new file mode 100644 index 0000000..587c450 --- /dev/null +++ b/SkyBot/Commands/Info/Version.cs @@ -0,0 +1,44 @@ +using System.Net.Http.Json; +using System.Text.Json.Serialization; +using SkyBot.Helpers; +using SkyBot.Models; +using Valour.Sdk.Models; +using Valour.Shared; + +namespace SkyBot.Commands +{ + public class Version : ICommand + { + private static readonly HttpClient http = new(); + + public string Name => "version"; + public string[] Aliases => ["versions", "ver"]; + public string Description => ""; + public string Category => "Info"; + public string Usage => "version"; + public string[] SubCommands => []; + + public async Task Execute(CommandContext ctx) + { + string latestSdk = "Unknown"; + try + { + NuGetVersions? response = await http.GetFromJsonAsync("https://api.nuget.org/v3-flatcontainer/valour.sdk/index.json"); + string? raw = response?.Versions?.LastOrDefault(); + latestSdk = raw is not null ? (raw.Count(c => c == '.') == 2 ? $"{raw}.0": raw) : "Unknown"; + } catch {} + + string msg = @$"Bot Version: {typeof(Version).Assembly.GetName().Version} + Valour Version: {ctx.Client.PrimaryNode.GetAsync("api/version").Result.Data} + ValourSDK Version: {typeof(Channel).Assembly.GetName().Version} (latest: {latestSdk})"; + + await MessageHelper.ReplyAsync(ctx, msg); + } + + private class NuGetVersions + { + [JsonPropertyName("versions")] + public List? Versions { get; set; } + } + } +} \ No newline at end of file diff --git a/SkyBot/Config.cs b/SkyBot/Config.cs index 51bc3a1..a1b8bb7 100644 --- a/SkyBot/Config.cs +++ b/SkyBot/Config.cs @@ -2,7 +2,7 @@ namespace SkyBot { public static class Config { public static readonly long OwnerId = 15652354820931584; - public static readonly string Prefix = "sd/"; + public static readonly string Prefix = "s/"; public static readonly string SourceLink = "https://git.skyjoshua.xyz/SkyJoshua/SkyBot"; } } \ No newline at end of file diff --git a/SkyBot/Helpers/MessageHelper.cs b/SkyBot/Helpers/MessageHelper.cs index 292165e..1f0fa03 100644 --- a/SkyBot/Helpers/MessageHelper.cs +++ b/SkyBot/Helpers/MessageHelper.cs @@ -1,7 +1,6 @@ using System.Globalization; using System.Text.Json; using SkyBot.Models; -using Valour.Sdk.Client; using Valour.Sdk.Models; using Valour.Sdk.Models.Messages.Embeds; using Valour.Shared; diff --git a/SkyBot/SkyBot.csproj b/SkyBot/SkyBot.csproj index 49fb903..28b049f 100644 --- a/SkyBot/SkyBot.csproj +++ b/SkyBot/SkyBot.csproj @@ -5,7 +5,7 @@ net10.0 enable enable - 0.3.0.1 + 0.3.0.2