v0.3.1.0 - Added a few commands + fixes
This commit is contained in:
@@ -13,7 +13,6 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
{
|
{
|
||||||
if (!ctx.ChannelCache.TryGetValue(ctx.Channel.Id, out var channel)) return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,8 +15,6 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
{
|
{
|
||||||
if (!ctx.ChannelCache.TryGetValue(ctx.Channel.Id, out var channel)) return;
|
|
||||||
|
|
||||||
if (!PermissionHelper.IsOwner(ctx.Member))
|
if (!PermissionHelper.IsOwner(ctx.Member))
|
||||||
{
|
{
|
||||||
await MessageHelper.ReplyAsync(ctx, "You do not have permission to execute this command.");
|
await MessageHelper.ReplyAsync(ctx, "You do not have permission to execute this command.");
|
||||||
@@ -42,7 +40,7 @@ namespace SkyBot.Commands
|
|||||||
return;
|
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.");
|
await MessageHelper.ReplyAsync(ctx, "I do not have permission to delete other members' messages in this channel.");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
{
|
{
|
||||||
if (!ctx.ChannelCache.TryGetValue(ctx.Channel.Id, out var channel)) return;
|
|
||||||
|
|
||||||
if (!PermissionHelper.IsOwner(ctx.Member))
|
if (!PermissionHelper.IsOwner(ctx.Member))
|
||||||
{
|
{
|
||||||
await MessageHelper.ReplyAsync(ctx, "You do not have permission to execute this command.");
|
await MessageHelper.ReplyAsync(ctx, "You do not have permission to execute this command.");
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
{
|
{
|
||||||
if (!ctx.ChannelCache.TryGetValue(ctx.Channel.Id, out var channel)) return;
|
|
||||||
|
|
||||||
string reply = string.Join(' ', ctx.Args);
|
string reply = string.Join(' ', ctx.Args);
|
||||||
if (string.IsNullOrWhiteSpace(reply))
|
if (string.IsNullOrWhiteSpace(reply))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ namespace SkyBot.Commands
|
|||||||
|
|
||||||
public async Task Execute(CommandContext ctx)
|
public async Task Execute(CommandContext ctx)
|
||||||
{
|
{
|
||||||
if (!ctx.ChannelCache.TryGetValue(ctx.Channel.Id, out var channel)) return;
|
|
||||||
|
|
||||||
var categories = CommandRegistry.Categories
|
var categories = CommandRegistry.Categories
|
||||||
.Where(c => c.Key != "template")
|
.Where(c => c.Key != "template")
|
||||||
.Where(c => c.Key != "dev" || PermissionHelper.IsOwner(ctx.Member))
|
.Where(c => c.Key != "dev" || PermissionHelper.IsOwner(ctx.Member))
|
||||||
|
|||||||
20
SkyBot/Commands/Info/Source.cs
Normal file
20
SkyBot/Commands/Info/Source.cs
Normal 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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
44
SkyBot/Commands/Info/Version.cs
Normal file
44
SkyBot/Commands/Info/Version.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ namespace SkyBot
|
|||||||
{
|
{
|
||||||
public static class Config {
|
public static class Config {
|
||||||
public static readonly long OwnerId = 15652354820931584;
|
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";
|
public static readonly string SourceLink = "https://git.skyjoshua.xyz/SkyJoshua/SkyBot";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using SkyBot.Models;
|
using SkyBot.Models;
|
||||||
using Valour.Sdk.Client;
|
|
||||||
using Valour.Sdk.Models;
|
using Valour.Sdk.Models;
|
||||||
using Valour.Sdk.Models.Messages.Embeds;
|
using Valour.Sdk.Models.Messages.Embeds;
|
||||||
using Valour.Shared;
|
using Valour.Shared;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Version>0.3.0.1</Version>
|
<Version>0.3.0.2</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user