Holy Big Commit!
This commit is contained in:
33
SkyBot/Commands/CommandRegistry.cs
Normal file
33
SkyBot/Commands/CommandRegistry.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using SkyBot.Models;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public static class CommandRegistry
|
||||
{
|
||||
public static readonly Dictionary<string, ICommand> Commands = new();
|
||||
public static readonly Dictionary<string, List<ICommand>> Sections = new();
|
||||
|
||||
static CommandRegistry()
|
||||
{
|
||||
var allCommands = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(a => a.GetTypes())
|
||||
.Where(t => typeof(ICommand).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract)
|
||||
.Select(t => (ICommand?)Activator.CreateInstance(t))
|
||||
.Select(c => c!);
|
||||
|
||||
foreach (var cmd in allCommands)
|
||||
{
|
||||
Commands[cmd.Name.ToLower()] = cmd;
|
||||
foreach (var alias in cmd.Aliases)
|
||||
{
|
||||
Commands[alias.ToLower()] = cmd;
|
||||
}
|
||||
|
||||
Sections = Commands.Values
|
||||
.Distinct()
|
||||
.GroupBy(c => c.Section.ToLower())
|
||||
.ToDictionary(g => g.Key, g => g.ToList());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
SkyBot/Commands/CommandTemplate.cs
Normal file
29
SkyBot/Commands/CommandTemplate.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Concurrent;
|
||||
using SkyBot.Models;
|
||||
using Valour.Sdk.Models;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public class CommandTemplate : ICommand
|
||||
{
|
||||
public string Name => "template";
|
||||
public string[] Aliases => [];
|
||||
public string Description => "";
|
||||
public string Section => "template";
|
||||
public string Usage => "";
|
||||
|
||||
public async Task Execute(CommandContext ctx)
|
||||
{
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
long channelId = ctx.ChannelId;
|
||||
PlanetMember member = ctx.Member;
|
||||
|
||||
string message = $"";
|
||||
|
||||
if (channelCache.TryGetValue(channelId, out var channel))
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
SkyBot/Commands/Dev/Test.cs
Normal file
32
SkyBot/Commands/Dev/Test.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections.Concurrent;
|
||||
using SkyBot.Helpers;
|
||||
using SkyBot.Models;
|
||||
using Valour.Sdk.Client;
|
||||
using Valour.Sdk.Models;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public class Test : ICommand
|
||||
{
|
||||
public string Name => "test";
|
||||
public string[] Aliases => [];
|
||||
public string Description => "Just a test command";
|
||||
public string Section => "Dev";
|
||||
public string Usage => "test";
|
||||
|
||||
public async Task Execute(CommandContext ctx)
|
||||
{
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
long channelId = ctx.ChannelId;
|
||||
ValourClient client = ctx.Client;
|
||||
PlanetMember member = ctx.Member;
|
||||
Message message = ctx.Message;
|
||||
Planet planet = ctx.Planet;
|
||||
|
||||
if (channelCache.TryGetValue(channelId, out var channel))
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, "This is a test message");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
42
SkyBot/Commands/Fun/Echo.cs
Normal file
42
SkyBot/Commands/Fun/Echo.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Net.NetworkInformation;
|
||||
using SkyBot.Helpers;
|
||||
using SkyBot.Models;
|
||||
using Valour.Sdk.Models;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public class Echo : ICommand
|
||||
{
|
||||
public string Name => "echo";
|
||||
public string[] Aliases => [];
|
||||
public string Description => "Echos what you said through the bot.";
|
||||
public string Section => "Fun";
|
||||
public string Usage => "echo <message>";
|
||||
|
||||
public async Task Execute(CommandContext ctx)
|
||||
{
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
long channelId = ctx.ChannelId;
|
||||
PlanetMember member = ctx.Member;
|
||||
String[] args = ctx.Args;
|
||||
Message message = ctx.Message;
|
||||
|
||||
string reply = string.Join(" ", args);
|
||||
|
||||
if (channelCache.TryGetValue(channelId, out var channel))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(reply)) await channel.SendMessageAsync($"{MentionHelper.Mention(member)} Enter a message to echo.");
|
||||
|
||||
reply = $"{member.Name} » {reply}";
|
||||
|
||||
if (reply.Length > 2048)
|
||||
{
|
||||
reply = reply.Substring(0, 2048);
|
||||
}
|
||||
|
||||
await MessageHelper.ReplyAsync(ctx, channel, reply);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using System.Collections.Concurrent;
|
||||
using SkyBot.Helpers;
|
||||
using Valour.Sdk.Models;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public static class HelpCommand
|
||||
{
|
||||
public static async Task Execute(ConcurrentDictionary<long, Channel> channelCache, long channelId, String prefix, PlanetMember member)
|
||||
{
|
||||
string helpMessage = $@"**Skybot Commands**:
|
||||
- `s/echo <text>` - Echos text into the chat
|
||||
- `s/suggest` - Shares the suggestions link
|
||||
- `s/source` - Sends link for the source code
|
||||
- `s/joincode` - Sends a link to a github that you can use to make your bot join your planet.
|
||||
- `s/joinsite` - Sends a link to a website that you can use to make yout bot join your planet.
|
||||
- `s/api|swagger` - Sends a link to the Swagger API
|
||||
- `s/cmds|help` - Shows this list
|
||||
- `s/usercount` - Shows the user count of Valour
|
||||
- `s/devcentral` - Sends the invite link to the Dev Central Planet
|
||||
- `s/mc` - Sends Unofficial ValourSMP IPs
|
||||
";
|
||||
|
||||
if (channelCache.TryGetValue(channelId, out var channel))
|
||||
{
|
||||
await channel.SendMessageAsync($"{MentionHelper.Mention(member)}\n{helpMessage}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
SkyBot/Commands/Info/Devcentral.cs
Normal file
29
SkyBot/Commands/Info/Devcentral.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Concurrent;
|
||||
using SkyBot.Models;
|
||||
using Valour.Sdk.Models;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public class Devcentral : ICommand
|
||||
{
|
||||
public string Name => "devcentral";
|
||||
public string[] Aliases => ["dev"];
|
||||
public string Description => "Sends an invite link to the Dev Central Planet.";
|
||||
public string Section => "Info";
|
||||
public string Usage => "devcentral|dev";
|
||||
|
||||
public async Task Execute(CommandContext ctx)
|
||||
{
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
long channelId = ctx.ChannelId;
|
||||
PlanetMember member = ctx.Member;
|
||||
|
||||
string message = $"you can join the Dev Central (ID: 42439954653511681) planet here: https://app.valour.gg/I/k2tz9c4i";
|
||||
|
||||
if (channelCache.TryGetValue(channelId, out var channel))
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
92
SkyBot/Commands/Info/Help.cs
Normal file
92
SkyBot/Commands/Info/Help.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Text;
|
||||
using SkyBot.Helpers;
|
||||
using SkyBot.Models;
|
||||
using Valour.Sdk.Models;
|
||||
using Valour.Shared.Authorization;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public class Help : ICommand
|
||||
{
|
||||
public string Name => "help";
|
||||
public string[] Aliases => ["h"];
|
||||
public string Description => "Shows all the commands and their descriptions.";
|
||||
public string Section => "Info";
|
||||
public string Usage => "help|h [section] [page]";
|
||||
private const int PageSize = 5;
|
||||
|
||||
public async Task Execute(CommandContext ctx)
|
||||
{
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
long channelId = ctx.ChannelId;
|
||||
string[] args = ctx.Args;
|
||||
PlanetMember member = ctx.Member;
|
||||
|
||||
bool isOwner = await PermissionHelper.IsOwner(member);
|
||||
|
||||
if (!channelCache.TryGetValue(channelId, out var channel)) return;
|
||||
|
||||
// Show all sections.
|
||||
if (args.Length == 0)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("**Available Categories**");
|
||||
foreach (var section in CommandRegistry.Sections.Keys)
|
||||
{
|
||||
if (section == "template") continue;
|
||||
if (section == "dev" && !isOwner) continue;
|
||||
if (section == "mod" && !PermissionHelper.HasPermAsync(member, [PlanetPermissions.Kick, PlanetPermissions.Ban, PlanetPermissions.ManageRoles]).Result) continue;
|
||||
sb.AppendLine($"- `{section.ToTitleCase()}` ({CommandRegistry.Sections[section].Count})");
|
||||
}
|
||||
sb.AppendLine($"\nUse `{Config.Prefix}help <category>` to see commands in a category.");
|
||||
await MessageHelper.ReplyAsync(ctx, channel, sb.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
// section [page]
|
||||
string sectionName = args[0].ToLower();
|
||||
if (!CommandRegistry.Sections.TryGetValue(sectionName, out var commands))
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, $"Unknown category `{sectionName}`.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sectionName == "dev" && !isOwner)
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, $"Unknown category `{sectionName}`.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sectionName == "mod" && !PermissionHelper.HasPermAsync(member, [PlanetPermissions.Kick, PlanetPermissions.Ban, PlanetPermissions.ManageRoles]).Result)
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, $"Unknown category `{sectionName}`.");
|
||||
return;
|
||||
}
|
||||
|
||||
int page = 1;
|
||||
if (args.Length >= 2 && int.TryParse(args[1], out int parsedPage))
|
||||
{
|
||||
page = parsedPage;
|
||||
}
|
||||
|
||||
int totalPages = (int)Math.Ceiling(commands.Count / (double)PageSize);
|
||||
page = Math.Clamp(page, 1, totalPages);
|
||||
|
||||
var pageCommands = commands.Skip((page - 1) * PageSize).Take(PageSize);
|
||||
|
||||
var sb2 = new StringBuilder();
|
||||
sb2.AppendLine($"**{sectionName.ToTitleCase()} commands** (Page {page}/{totalPages}):");
|
||||
foreach (var cmd in pageCommands)
|
||||
{
|
||||
var name = cmd.Aliases.Length > 0
|
||||
? $"{cmd.Name}|{string.Join("|", cmd.Aliases)}"
|
||||
: cmd.Name;
|
||||
sb2.AppendLine($"`{Config.Prefix}{name}` - {cmd.Description}");
|
||||
}
|
||||
sb2.AppendLine($"\nUse `{Config.Prefix}help {sectionName} <page>` to see more.");
|
||||
|
||||
await MessageHelper.ReplyAsync(ctx, channel, sb2.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
29
SkyBot/Commands/Info/JoinSite.cs
Normal file
29
SkyBot/Commands/Info/JoinSite.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Concurrent;
|
||||
using SkyBot.Models;
|
||||
using Valour.Sdk.Models;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public class JoinSite : ICommand
|
||||
{
|
||||
public string Name => "joinsite";
|
||||
public string[] Aliases => [];
|
||||
public string Description => "Links to a site to help your bots join a planet.";
|
||||
public string Section => "Info";
|
||||
public string Usage => "joinsite";
|
||||
|
||||
public async Task Execute(CommandContext ctx)
|
||||
{
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
long channelId = ctx.ChannelId;
|
||||
PlanetMember member = ctx.Member;
|
||||
|
||||
string message = $"You can use this website to easily add your bot to a planet: https://skyjoshua.xyz/planetjoiner";
|
||||
|
||||
if (channelCache.TryGetValue(channelId, out var channel))
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
31
SkyBot/Commands/Info/Minecraft.cs
Normal file
31
SkyBot/Commands/Info/Minecraft.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Concurrent;
|
||||
using SkyBot.Models;
|
||||
using Valour.Sdk.Models;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public class Minecraft : ICommand
|
||||
{
|
||||
public string Name => "minecraft";
|
||||
public string[] Aliases => ["mc"];
|
||||
public string Description => "Sends the Unofficial ValourSMP IPs";
|
||||
public string Section => "Info";
|
||||
public string Usage => "minecraft|mc";
|
||||
|
||||
public async Task Execute(CommandContext ctx)
|
||||
{
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
long channelId = ctx.ChannelId;
|
||||
PlanetMember member = ctx.Member;
|
||||
|
||||
string message = @$"you can join the Unofficial ValourSMP Minecraft Server by using this ip:
|
||||
Java: `valour.sxsc.xyz`, Bedrock: `valourbr.sxsc.xyz` Both with the default ports.
|
||||
Cool features can be found here: https://sxsc.xyz/servers/valour/";
|
||||
|
||||
if (channelCache.TryGetValue(channelId, out var channel))
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
SkyBot/Commands/Info/Source.cs
Normal file
29
SkyBot/Commands/Info/Source.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Concurrent;
|
||||
using SkyBot.Models;
|
||||
using Valour.Sdk.Models;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public class Source : ICommand
|
||||
{
|
||||
public string Name => "source";
|
||||
public string[] Aliases => ["src"];
|
||||
public string Description => "Shows the source code for this bot.";
|
||||
public string Section => "Info";
|
||||
public string Usage => "source";
|
||||
|
||||
public async Task Execute(CommandContext ctx)
|
||||
{
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
long channelId = ctx.ChannelId;
|
||||
PlanetMember member = ctx.Member;
|
||||
|
||||
string message = $"You can find my source code here: {Config.SourceLink}";
|
||||
|
||||
if (channelCache.TryGetValue(channelId, out var channel))
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
SkyBot/Commands/Info/Suggest.cs
Normal file
29
SkyBot/Commands/Info/Suggest.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Concurrent;
|
||||
using SkyBot.Models;
|
||||
using Valour.Sdk.Models;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public class Suggest : ICommand
|
||||
{
|
||||
public string Name => "suggest";
|
||||
public string[] Aliases => [];
|
||||
public string Description => "Shows the source code for this bot.";
|
||||
public string Section => "Info";
|
||||
public string Usage => "source";
|
||||
|
||||
public async Task Execute(CommandContext ctx)
|
||||
{
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
long channelId = ctx.ChannelId;
|
||||
PlanetMember member = ctx.Member;
|
||||
|
||||
string message = $"You can suggest a command to be added here: https://docs.google.com/spreadsheets/d/1CzcpLAuMiPL_RODrZ5x25cPj8yE-rR3mEnqrd_2Fbmk";
|
||||
|
||||
if (channelCache.TryGetValue(channelId, out var channel))
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
SkyBot/Commands/Info/SwaggerAPI.cs
Normal file
29
SkyBot/Commands/Info/SwaggerAPI.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Concurrent;
|
||||
using SkyBot.Models;
|
||||
using Valour.Sdk.Models;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public class SwaggerAPI : ICommand
|
||||
{
|
||||
public string Name => "swagger";
|
||||
public string[] Aliases => ["api"];
|
||||
public string Description => "Sends a link to the Valour.gg Swagger API.";
|
||||
public string Section => "Info";
|
||||
public string Usage => "swagger|api";
|
||||
|
||||
public async Task Execute(CommandContext ctx)
|
||||
{
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
long channelId = ctx.ChannelId;
|
||||
PlanetMember member = ctx.Member;
|
||||
|
||||
string message = $"Here is a link to the Swagger API: https://api.valour.gg/swagger";
|
||||
|
||||
if (channelCache.TryGetValue(channelId, out var channel))
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
31
SkyBot/Commands/Info/UserCount.cs
Normal file
31
SkyBot/Commands/Info/UserCount.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Concurrent;
|
||||
using SkyBot.Helpers;
|
||||
using SkyBot.Models;
|
||||
using Valour.Sdk.Models;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public class UserCount : ICommand
|
||||
{
|
||||
public string Name => "usercount";
|
||||
public string[] Aliases => ["users"];
|
||||
public string Description => "Shows the user count of Valour.";
|
||||
public string Section => "Info";
|
||||
public string Usage => "usercount|users";
|
||||
|
||||
public async Task Execute(CommandContext ctx)
|
||||
{
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
long channelId = ctx.ChannelId;
|
||||
PlanetMember member = ctx.Member;
|
||||
|
||||
string message = @$"Current Valour user count is: {ValourUsercountHelper.ValourUsercount:N0}
|
||||
You can see a graph of the user count here: /meow";
|
||||
|
||||
if (channelCache.TryGetValue(channelId, out var channel))
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
30
SkyBot/Commands/Info/Version.cs
Normal file
30
SkyBot/Commands/Info/Version.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Concurrent;
|
||||
using SkyBot.Models;
|
||||
using Valour.Sdk.Models;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public class Version : ICommand
|
||||
{
|
||||
public string Name => "version";
|
||||
public string[] Aliases => [];
|
||||
public string Description => "Shows the current version of the Bot and Valour.";
|
||||
public string Section => "Info";
|
||||
public string Usage => "";
|
||||
|
||||
public async Task Execute(CommandContext ctx)
|
||||
{
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
long channelId = ctx.ChannelId;
|
||||
PlanetMember member = ctx.Member;
|
||||
|
||||
string message = @$"Bot Version: {typeof(Version).Assembly.GetName().Version}
|
||||
Valour Version: {typeof(Channel).Assembly.GetName().Version}";
|
||||
|
||||
if (channelCache.TryGetValue(channelId, out var channel))
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
SkyBot/Commands/Mod/Ban.cs
Normal file
36
SkyBot/Commands/Mod/Ban.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Collections.Concurrent;
|
||||
using SkyBot.Helpers;
|
||||
using SkyBot.Models;
|
||||
using Valour.Sdk.Models;
|
||||
using Valour.Shared.Authorization;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public class Ban : ICommand
|
||||
{
|
||||
public string Name => "ban";
|
||||
public string[] Aliases => [];
|
||||
public string Description => "Bans a user from the planet.";
|
||||
public string Section => "mod";
|
||||
public string Usage => "ban <user> [reason]";
|
||||
|
||||
public async Task Execute(CommandContext ctx)
|
||||
{
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
long channelId = ctx.ChannelId;
|
||||
PlanetMember member = ctx.Member;
|
||||
|
||||
if (channelCache.TryGetValue(channelId, out var channel))
|
||||
{
|
||||
if (!PermissionHelper.HasPermAsync(member, [PlanetPermissions.Ban]).Result)
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, $"You don't have permission to use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
string message = $"Work in progress...";
|
||||
await MessageHelper.ReplyAsync(ctx, channel, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
37
SkyBot/Commands/Mod/Kick.cs
Normal file
37
SkyBot/Commands/Mod/Kick.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Collections.Concurrent;
|
||||
using SkyBot.Helpers;
|
||||
using SkyBot.Models;
|
||||
using Valour.Sdk.Models;
|
||||
using Valour.Shared.Authorization;
|
||||
|
||||
namespace SkyBot.Commands
|
||||
{
|
||||
public class Kick : ICommand
|
||||
{
|
||||
public string Name => "kick";
|
||||
public string[] Aliases => [];
|
||||
public string Description => "Kicks a user from the planet.";
|
||||
public string Section => "mod";
|
||||
public string Usage => "kick <user> [reason]";
|
||||
|
||||
public async Task Execute(CommandContext ctx)
|
||||
{
|
||||
ConcurrentDictionary<long, Channel> channelCache = ctx.ChannelCache;
|
||||
long channelId = ctx.ChannelId;
|
||||
PlanetMember member = ctx.Member;
|
||||
|
||||
if (channelCache.TryGetValue(channelId, out var channel))
|
||||
{
|
||||
if (!PermissionHelper.HasPermAsync(member, [PlanetPermissions.Kick]).Result)
|
||||
{
|
||||
await MessageHelper.ReplyAsync(ctx, channel, $"You don't have permission to use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
string message = $"Work in progress...";
|
||||
|
||||
await MessageHelper.ReplyAsync(ctx, channel, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user