v0.3.1.0 - Added a few commands + fixes

This commit is contained in:
2026-04-18 03:21:02 +01:00
parent f7fd877023
commit 675ea71948
10 changed files with 67 additions and 13 deletions

View File

@@ -13,7 +13,6 @@ namespace SkyBot.Commands
public async Task Execute(CommandContext ctx)
{
if (!ctx.ChannelCache.TryGetValue(ctx.Channel.Id, out var channel)) return;
}
}
}

View File

@@ -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;

View File

@@ -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.");

View File

@@ -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))
{

View File

@@ -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))

View File

@@ -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}");
}
}
}

View File

@@ -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<NuGetVersions>("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<string>? Versions { get; set; }
}
}
}

View File

@@ -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";
}
}

View File

@@ -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;

View File

@@ -5,7 +5,7 @@
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.3.0.1</Version>
<Version>0.3.0.2</Version>
</PropertyGroup>
<ItemGroup>