update command structure and markup

This commit is contained in:
13xforever
2025-03-11 15:34:51 +05:00
parent e068a7870b
commit 06b375b972
39 changed files with 233 additions and 320 deletions

View File

@@ -1,5 +1,4 @@
using System.Net;
using CompatBot.Commands.Attributes;
using CompatBot.Database.Providers;
using CompatBot.EventHandlers;
using Microsoft.Extensions.Caching.Memory;
@@ -35,8 +34,7 @@ internal class BaseCommandModuleCustom : BaseCommandModule
await dm.SendMessageAsync($"Only `{Config.CommandPrefix}warn` and `{Config.CommandPrefix}report` are allowed in {ctx.Channel.Mention}").ConfigureAwait(false);
}
Config.TelemetryClient?.TrackRequest(ctx.Command.QualifiedName, executionStart, DateTimeOffset.UtcNow - executionStart, HttpStatusCode.Forbidden.ToString(), true);
throw new DSharpPlus.Commands.Exceptions.ChecksFailedException(ctx.Command, ctx, [new RequiresNotMediaAttribute()
]);
throw new DSharpPlus.Commands.Exceptions.ChecksFailedException(ctx.Command, ctx, [new RequiresNotMediaAttribute()]);
}
var disabledCmds = DisabledCommandsProvider.Get();

View File

@@ -1,32 +1,24 @@
using System.Globalization;
using CompatBot.Commands.Attributes;
using org.mariuszgromada.math.mxparser;
using License = org.mariuszgromada.math.mxparser.License;
namespace CompatBot.Commands;
[Group("math")]
[Command("math")]
[Description("Math, here you go Juhn. Use `math help` for syntax help")]
internal sealed class BotMath : BaseCommandModuleCustom
internal sealed class BotMath
{
static BotMath()
{
License.iConfirmNonCommercialUse("RPCS3");
}
[GroupCommand, Priority(9)]
public async Task Expression(CommandContext ctx, [RemainingText, Description("Math expression")] string expression)
[Command("calculate"), TextAlias("calc"), DefaultGroupCommand]
public async ValueTask Calc(CommandContext ctx, [RemainingText, Description("Math expression")] string expression)
{
if (string.IsNullOrEmpty(expression))
{
try
{
if (ctx.CommandsNext.FindCommand("math help", out _) is Command helpCmd)
{
var helpCtx = ctx.CommandsNext.CreateContext(ctx.Message, ctx.Prefix, helpCmd);
await helpCmd.ExecuteAsync(helpCtx).ConfigureAwait(false);
}
}
catch { }
await Help(ctx).ConfigureAwait(false);
return;
}
@@ -61,7 +53,8 @@ internal sealed class BotMath : BaseCommandModuleCustom
await ctx.Channel.SendMessageAsync(result).ConfigureAwait(false);
}
[Command("help"), LimitedToSpamChannel, Cooldown(1, 5, CooldownBucketType.Channel)]
[Command("help"), LimitedToSpamChannel]
//[Cooldown(1, 5, CooldownBucketType.Channel)]
[Description("General math expression help, or description of specific math word")]
public Task Help(CommandContext ctx)
=> ctx.Channel.SendMessageAsync("Help for all the features and built-in constants and functions could be found at [mXparser website](<https://mathparser.org/mxparser-math-collection/>)");

View File

@@ -9,19 +9,20 @@ using Microsoft.EntityFrameworkCore;
namespace CompatBot.Commands;
[Group("stats"), Aliases("status")]
internal sealed class BotStats: BaseCommandModuleCustom
[Command("stats"), TextAlias("status")]
internal sealed class BotStats
{
[GroupCommand]
[Command("show"), DefaultGroupCommand]
[Description("Use to look at various runtime stats")]
public async Task Show(CommandContext ctx)
{
var latency = ctx.Client.GetConnectionLatency(Config.BotGuildId);
var embed = new DiscordEmbedBuilder
{
Color = DiscordColor.Purple,
}
.AddField("Current Uptime", Config.Uptime.Elapsed.AsShortTimespan(), true)
.AddField("Discord Latency", $"{ctx.Client.Ping} ms", true);
.AddField("Discord Latency", $"{latency.TotalMilliseconds:0.0} ms", true);
if (!string.IsNullOrEmpty(Config.AzureComputerVisionKey))
embed.AddField("Max OCR Queue", MediaScreenshotMonitor.MaxQueueLength.ToString(), true);
var osInfo = RuntimeInformation.OSDescription;
@@ -68,9 +69,9 @@ internal sealed class BotStats: BaseCommandModuleCustom
await ch.SendMessageAsync(embed: embed).ConfigureAwait(false);
}
[Command("hw"), Aliases("hardware")]
[Command("hw"), TextAlias("hardware")]
[Description("Various hardware stats from uploaded log files")]
[Cooldown(1, 5, CooldownBucketType.Guild)]
//[Cooldown(1, 5, CooldownBucketType.Guild)]
public Task Hardware(CommandContext ctx, [Description("Desired period in days, default is 30")] int period = 30) => Commands.Hardware.ShowStats(ctx, period);
private static string GetConfiguredApiStats()

View File

@@ -1,5 +1,4 @@
using CompatBot.Commands.Attributes;
using CompatBot.Database.Providers;
using CompatBot.Database.Providers;
using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.Processors.TextCommands;

View File

@@ -1,5 +1,4 @@
using CompatBot.Commands.Attributes;
using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.ContextChecks;
namespace CompatBot.Commands.Checks;

View File

@@ -1,13 +1,12 @@
using CompatBot.Commands.Attributes;
using CompatBot.Database.Providers;
using CompatBot.Database.Providers;
namespace CompatBot.Commands;
[Group("commands"), Aliases("command"), RequiresBotModRole]
[Command("commands"), TextAlias("command"), RequiresBotModRole]
[Description("Used to enable and disable bot commands at runtime")]
public sealed class CommandsManagement : BaseCommandModule
public sealed class CommandsManagement
{
[Command("list"), Aliases("show")]
[Command("list"), TextAlias("show")]
[Description("Lists the disabled commands")]
public async Task List(CommandContext ctx)
{
@@ -26,7 +25,7 @@ public sealed class CommandsManagement : BaseCommandModule
await ctx.Channel.SendMessageAsync("All commands are enabled").ConfigureAwait(false);
}
[Command("disable"), Aliases("add")]
[Command("disable"), TextAlias("add")]
[Description("Disables the specified command")]
public async Task Disable(CommandContext ctx, [RemainingText, Description("Fully qualified command to disable, e.g. `explain add` or `sudo mod *`")] string? command)
{
@@ -89,7 +88,7 @@ public sealed class CommandsManagement : BaseCommandModule
}
}
[Command("enable"), Aliases("reenable", "remove", "delete", "del", "clear")]
[Command("enable"), TextAlias("reenable", "remove", "delete", "del", "clear")]
[Description("Enables the specified command")]
public async Task Enable(CommandContext ctx, [RemainingText, Description("Fully qualified command to enable, e.g. `explain add` or `sudo mod *`")] string? command)
{

View File

@@ -8,7 +8,6 @@ using CompatApiClient;
using CompatApiClient.Compression;
using CompatApiClient.POCOs;
using CompatApiClient.Utils;
using CompatBot.Commands.Attributes;
using CompatBot.Database;
using CompatBot.Database.Providers;
using CompatBot.EventHandlers;
@@ -20,7 +19,7 @@ using Microsoft.TeamFoundation.Build.WebApi;
namespace CompatBot.Commands;
internal sealed partial class CompatList : BaseCommandModuleCustom
internal sealed partial class CompatList
{
private static readonly Client Client = new();
private static readonly GithubClient.Client GithubClient = new(Config.GithubToken);
@@ -57,7 +56,7 @@ internal sealed partial class CompatList : BaseCommandModuleCustom
}
}
[Command("compat"), Aliases("c", "compatibility")]
[Command("compatibility"), TextAlias("c", "compat")]
[Description("Searches the compatibility database, USE: !compat search term")]
public async Task Compat(CommandContext ctx, [RemainingText, Description("Game title to look up")] string? title)
{
@@ -102,7 +101,8 @@ internal sealed partial class CompatList : BaseCommandModuleCustom
}
}
[Command("top"), LimitedToOfftopicChannel, Cooldown(1, 5, CooldownBucketType.Channel)]
[Command("top"), LimitedToOfftopicChannel]
//[Cooldown(1, 5, CooldownBucketType.Channel)]
[Description("Provides top game lists based on Metacritic and compatibility lists")]
public async Task Top(CommandContext ctx,
[Description("Number of entries in the list")] int number = 10,
@@ -155,12 +155,12 @@ internal sealed partial class CompatList : BaseCommandModuleCustom
await ctx.Channel.SendMessageAsync("Failed to generate list").ConfigureAwait(false);
}
[Group("latest"), TriggersTyping]
[Command("latest"), TriggersTyping]
[Description("Provides links to the latest RPCS3 build")]
[Cooldown(1, 30, CooldownBucketType.Channel)]
public sealed class UpdatesCheck: BaseCommandModuleCustom
//[Cooldown(1, 30, CooldownBucketType.Channel)]
public sealed class UpdatesCheck
{
[GroupCommand]
[Command("build"), DefaultGroupCommand]
public Task Latest(CommandContext ctx) => CheckForRpcs3Updates(ctx.Client, ctx.Channel);
[Command("since")]

View File

@@ -5,7 +5,6 @@ using System.Text.RegularExpressions;
using System.Xml.Linq;
using CompatApiClient.Compression;
using CompatApiClient.Utils;
using CompatBot.Commands.Attributes;
using CompatBot.Database;
using CompatBot.Database.Providers;
using CompatBot.Utils.Extensions;
@@ -14,9 +13,9 @@ using Exception = System.Exception;
namespace CompatBot.Commands;
[Group("filters"), Aliases("piracy", "filter"), RequiresBotSudoerRole, RequiresDm]
[Command("filters"), TextAlias("piracy", "filter"), RequiresBotSudoerRole, RequiresDm]
[Description("Used to manage content filters. **Works only in DM**")]
internal sealed partial class ContentFilters: BaseCommandModuleCustom
internal sealed partial class ContentFilters
{
private static readonly TimeSpan InteractTimeout = TimeSpan.FromMinutes(5);
private static readonly char[] Separators = [' ', ',', ';', '|'];
@@ -88,7 +87,7 @@ internal sealed partial class ContentFilters: BaseCommandModuleCustom
await ctx.Channel.SendMessageAsync(new DiscordMessageBuilder().AddFile("filters.txt", output)).ConfigureAwait(false);
}
[Command("add"), Aliases("create")]
[Command("add"), TextAlias("create")]
[Description("Adds a new content filter")]
public async Task Add(CommandContext ctx, [RemainingText, Description("A plain string to match")] string? trigger)
{
@@ -222,7 +221,7 @@ internal sealed partial class ContentFilters: BaseCommandModuleCustom
}
}
[Command("edit"), Aliases("fix", "update", "change")]
[Command("edit"), TextAlias("fix", "update", "change")]
[Description("Modifies the specified content filter")]
public async Task Edit(CommandContext ctx, [Description("Filter ID")] int id)
{
@@ -251,7 +250,7 @@ internal sealed partial class ContentFilters: BaseCommandModuleCustom
await EditFilterCmd(ctx, db, filter).ConfigureAwait(false);
}
[Command("view"), Aliases("show")]
[Command("view"), TextAlias("show")]
[Description("Shows the details of the specified content filter")]
public async Task View(CommandContext ctx, [Description("Filter ID")] int id)
{
@@ -281,7 +280,7 @@ internal sealed partial class ContentFilters: BaseCommandModuleCustom
await ctx.Channel.SendMessageAsync(new DiscordMessageBuilder().AddEmbed(FormatFilter(filter))).ConfigureAwait(false);
}
[Command("remove"), Aliases("delete", "del")]
[Command("remove"), TextAlias("delete", "del")]
[Description("Removes a content filter trigger")]
public async Task Remove(CommandContext ctx, [Description("Filter IDs to remove, separated with spaces")] params int[] ids)
{

View File

@@ -1,8 +1,8 @@
namespace CompatBot.Commands;
internal sealed class DevOnly : BaseCommandModuleCustom
#if DEBUG
internal sealed class DevOnly
{
[Command("whitespacetest"), Aliases("wst", "wstest")]
[Command("whitespacetest"), TextAlias("wst", "wstest")]
[Description("Testing discord embeds breakage for whitespaces")]
public async Task WhitespaceTest(CommandContext ctx)
{
@@ -52,9 +52,10 @@ internal sealed class DevOnly : BaseCommandModuleCustom
var builder = new DiscordMessageBuilder()
.WithContent("Regular button vs emoji button")
.AddComponents(
new DiscordButtonComponent(ButtonStyle.Primary, "pt", "✅ Regular"),
new DiscordButtonComponent(ButtonStyle.Primary, "pe", "Emoji", emoji: new(DiscordEmoji.FromUnicode("✅")))
new DiscordButtonComponent(DiscordButtonStyle.Primary, "pt", "✅ Regular"),
new DiscordButtonComponent(DiscordButtonStyle.Primary, "pe", "Emoji", emoji: new(DiscordEmoji.FromUnicode("✅")))
);
await ctx.RespondAsync(builder).ConfigureAwait(false);
}
}
}
#endif

View File

@@ -1,43 +0,0 @@
using CompatBot.Commands.Attributes;
namespace CompatBot.Commands;
[Group("e3")]
[Description("Provides information about the E3 event")]
internal sealed class E3: EventsBaseCommand
{
[GroupCommand]
public Task E3Countdown(CommandContext ctx)
=> NearestEvent(ctx, "E3");
[Command("add"), RequiresBotModRole]
[Description("Adds new E3 event to the schedule")]
public Task AddE3(CommandContext ctx)
=> Add(ctx, "E3");
[Command("remove"), Aliases("delete", "del"), RequiresBotModRole]
[Description("Removes event with the specified IDs")]
public Task RemoveE3(CommandContext ctx, [Description("Event IDs to remove separated with space")] params int[] ids)
=> Remove(ctx, ids);
[Command("clean"), Aliases("cleanup", "Clear"), RequiresBotModRole]
[Description("Removes past events")]
public Task ClearE3(CommandContext ctx, [Description("Optional year to remove, by default everything before current year")] int? year = null)
=> Clear(ctx, year);
[Command("edit"), Aliases("adjust", "change", "modify", "update"), RequiresBotModRole]
[Description("Updates the event entry properties")]
public Task AdjustE3(CommandContext ctx, [Description("Event ID")] int id)
=> Update(ctx, id, "E3");
[Command("schedule"), Aliases("show", "list")]
[Description("Outputs current schedule")]
public Task ListE3(CommandContext ctx, [Description("Optional year to list")] int? year = null)
=> List(ctx, "E3", year);
[Command("countdown")]
[Description("Provides countdown for the nearest known E3 event")]
public Task Countdown(CommandContext ctx)
=> E3Countdown(ctx);
}

View File

@@ -1,13 +1,11 @@
using CompatBot.Commands.Attributes;
namespace CompatBot.Commands;
namespace CompatBot.Commands;
[Group("event"), Aliases("events", "e")]
[Command("event"), TextAlias("events", "e")]
[Description("Provides information about the various events in the game industry")]
internal sealed class Events: EventsBaseCommand
{
[GroupCommand]
public Task NearestGenericEvent(CommandContext ctx, [Description("Optional event name"), RemainingText] string? eventName = null)
[Command("show"), DefaultGroupCommand]
public Task Show(CommandContext ctx, [Description("Optional event name"), RemainingText] string? eventName = null)
=> NearestEvent(ctx, eventName);
[Command("add"), RequiresBotModRole]
@@ -15,22 +13,22 @@ internal sealed class Events: EventsBaseCommand
public Task AddGeneric(CommandContext ctx)
=> Add(ctx);
[Command("remove"), Aliases("delete", "del"), RequiresBotModRole]
[Command("remove"), TextAlias("delete", "del"), RequiresBotModRole]
[Description("Removes schedule entries with the specified IDs")]
public Task RemoveGeneric(CommandContext ctx, [Description("Event IDs to remove separated with space")] params int[] ids)
=> Remove(ctx, ids);
[Command("clean"), Aliases("cleanup", "Clear"), RequiresBotModRole]
[Command("clean"), TextAlias("cleanup", "Clear"), RequiresBotModRole]
[Description("Removes past events")]
public Task ClearGeneric(CommandContext ctx, [Description("Optional year to remove, by default everything before current year")] int? year = null)
=> Clear(ctx, year);
[Command("edit"), Aliases("adjust", "change", "modify", "update"), RequiresBotModRole]
[Command("edit"), TextAlias("adjust", "change", "modify", "update"), RequiresBotModRole]
[Description("Updates the event entry properties")]
public Task AdjustGeneric(CommandContext ctx, [Description("Event ID")] int id)
=> Update(ctx, id);
[Command("schedule"), Aliases("show", "list")]
[Command("schedule"), TextAlias("show", "list")]
[Description("Outputs current schedule")]
public Task ListGeneric(CommandContext ctx)
=> List(ctx);

View File

@@ -1,6 +1,5 @@
using System.Text.RegularExpressions;
using CompatApiClient.Utils;
using CompatBot.Commands.Attributes;
using CompatBot.Commands.Checks;
using CompatBot.Database;
using CompatBot.Database.Providers;
@@ -9,7 +8,7 @@ using Microsoft.EntityFrameworkCore;
namespace CompatBot.Commands;
internal partial class EventsBaseCommand: BaseCommandModuleCustom
internal partial class EventsBaseCommand
{
private static readonly TimeSpan InteractTimeout = TimeSpan.FromMinutes(5);

View File

@@ -1,30 +1,27 @@
using System.ComponentModel;
using System.Globalization;
using System.Globalization;
using System.IO;
using System.Net.Http;
using System.Runtime.InteropServices;
using CompatApiClient.Compression;
using CompatApiClient.Utils;
using CompatBot.Commands.Attributes;
using CompatBot.Commands.Checks;
using CompatBot.Database;
using CompatBot.Database.Providers;
using CompatBot.EventHandlers;
using DSharpPlus.Commands.Converters;
using Microsoft.EntityFrameworkCore;
using Description = DSharpPlus.Commands.Attributes.DescriptionAttribute;
namespace CompatBot.Commands;
[Group("explain"), Aliases("botsplain", "define")]
[Cooldown(1, 3, CooldownBucketType.Channel)]
[Command("explain"), TextAlias("botsplain", "define")]
//[Cooldown(1, 3, CooldownBucketType.Channel)]
[Description("Used to manage and show explanations")]
internal sealed class Explain: BaseCommandModuleCustom
internal sealed class Explain
{
private const string TermListTitle = "Defined terms";
[GroupCommand]
public async Task ShowExplanation(CommandContext ctx, [RemainingText, Description("Term to explain")] string term)
[Command("show"), DefaultGroupCommand]
public async Task Show(CommandContext ctx, [RemainingText, Description("Term to explain")] string term)
{
if (string.IsNullOrEmpty(term))
{
@@ -148,7 +145,7 @@ internal sealed class Explain: BaseCommandModuleCustom
}
}
[Command("update"), Aliases("replace"), RequiresBotModRole]
[Command("update"), TextAlias("replace"), RequiresBotModRole]
[Description("Update explanation for a given term")]
public async Task Update(CommandContext ctx,
[Description("A term to update. Quote it if it contains spaces")] string term,
@@ -188,7 +185,7 @@ internal sealed class Explain: BaseCommandModuleCustom
}
}
[Command("rename"), Priority(10), RequiresBotModRole]
[Command("rename"), RequiresBotModRole]
public async Task Rename(CommandContext ctx,
[Description("A term to rename. Remember quotes if it contains spaces")] string oldTerm,
[Description("New term. Again, quotes")] string newTerm)
@@ -209,7 +206,7 @@ internal sealed class Explain: BaseCommandModuleCustom
}
}
[Command("rename"), Priority(1), RequiresBotModRole]
[Command("rename"), RequiresBotModRole]
[Description("Renames a term in case you misspelled it or something")]
public async Task Rename(CommandContext ctx,
[Description("A term to rename. Remember quotes if it contains spaces")] string oldTerm,
@@ -243,11 +240,11 @@ internal sealed class Explain: BaseCommandModuleCustom
}
}
[Group("remove"), Aliases("delete", "del", "erase", "obliterate"), RequiresBotModRole]
[Command("remove"), TextAlias("delete", "del", "erase", "obliterate"), RequiresBotModRole]
[Description("Removes an explanation from the definition list")]
internal sealed class Remove: BaseCommandModuleCustom
internal sealed class Remove
{
[GroupCommand]
[Command("entry"), DefaultGroupCommand]
public async Task RemoveExplanation(CommandContext ctx, [RemainingText, Description("Term to remove")] string term)
{
term = term.ToLowerInvariant().StripQuotes();
@@ -263,7 +260,7 @@ internal sealed class Explain: BaseCommandModuleCustom
}
}
[Command("attachment"), Aliases("image", "picture", "file")]
[Command("attachment"), TextAlias("image", "picture", "file")]
[Description("Removes attachment from specified explanation. If there is no text, the whole explanation is removed")]
public async Task Attachment(CommandContext ctx, [RemainingText, Description("Term to remove")] string term)
{
@@ -285,7 +282,7 @@ internal sealed class Explain: BaseCommandModuleCustom
}
}
[Command("text"), Aliases("description")]
[Command("text"), TextAlias("description")]
[Description("Removes explanation text. If there is no attachment, the whole explanation is removed")]
public async Task Text(CommandContext ctx, [RemainingText, Description("Term to remove")] string term)
{
@@ -307,7 +304,7 @@ internal sealed class Explain: BaseCommandModuleCustom
}
}
[Command("dump"), Aliases("download")]
[Command("dump"), TextAlias("download")]
[Description("Returns explanation text as a file attachment")]
public async Task Dump(CommandContext ctx, [RemainingText, Description("Term to dump **or** a link to a message containing the explanation")] string? termOrLink = null)
{

View File

@@ -1,16 +1,15 @@
using CompatBot.Commands.Attributes;
using CompatBot.Database;
using CompatBot.Database;
using CompatBot.EventHandlers;
using CompatBot.Utils.Extensions;
using Microsoft.EntityFrameworkCore;
namespace CompatBot.Commands;
[Group("rename")]
[Command("rename")]
[Description("Manage users who has forced nickname.")]
internal sealed class ForcedNicknames : BaseCommandModuleCustom
internal sealed class ForcedNicknames
{
[GroupCommand]
[Command("user"), DefaultGroupCommand]
[Description("Enforces specific nickname for particular user.")]
public async Task Rename(CommandContext ctx,
[Description("Discord user to add to forced nickname list.")] DiscordUser discordUser,
@@ -110,7 +109,7 @@ internal sealed class ForcedNicknames : BaseCommandModuleCustom
}
}
[Command("clear"), Aliases("remove"), RequiresBotModRole]
[Command("clear"), TextAlias("remove"), RequiresBotModRole]
[Description("Removes nickname restriction from particular user.")]
public async Task Remove(CommandContext ctx, [Description("Discord user to remove from forced nickname list.")] DiscordUser discordUser)
{
@@ -145,7 +144,7 @@ internal sealed class ForcedNicknames : BaseCommandModuleCustom
}
}
[Command("cleanup"), Aliases("clean", "fix"), RequiresBotModRole]
[Command("cleanup"), TextAlias("clean", "fix"), RequiresBotModRole]
[Description("Removes zalgo from specified user nickname")]
public async Task Cleanup(CommandContext ctx, [Description("Discord user to clean up")] DiscordUser discordUser)
{
@@ -192,7 +191,7 @@ internal sealed class ForcedNicknames : BaseCommandModuleCustom
await ctx.Channel.SendMessageAsync(result).ConfigureAwait(false);
}
[Command("generate"), Aliases("gen", "suggest")]
[Command("generate"), TextAlias("gen", "suggest")]
[Description("Generates random name for specified user")]
public async Task Generate(CommandContext ctx, [Description("Discord user to dump")] DiscordUser discordUser)
{
@@ -200,7 +199,7 @@ internal sealed class ForcedNicknames : BaseCommandModuleCustom
await ctx.Channel.SendMessageAsync(newName).ConfigureAwait(false);
}
[Command("autorename"), Aliases("auto"), RequiresBotModRole]
[Command("autorename"), TextAlias("auto"), RequiresBotModRole]
[Description("Sets automatically generated nickname without enforcing it")]
public async Task Autorename(CommandContext ctx, [Description("Discord user to rename")] DiscordUser discordUser)
{

View File

@@ -2,19 +2,18 @@
using System.IO;
using System.Net.Http;
using CompatApiClient.Compression;
using CompatBot.Commands.Attributes;
using CompatBot.Database;
using Microsoft.EntityFrameworkCore;
namespace CompatBot.Commands;
[Group("fortune"), Aliases("fortunes")]
[Command("fortune"), TextAlias("fortunes")]
[Description("Gives you a fortune once a day")]
internal sealed class Fortune : BaseCommandModuleCustom
internal sealed class Fortune
{
private static readonly SemaphoreSlim ImportCheck = new(1, 1);
[GroupCommand]
[Command("open"), TextAlias("show"), DefaultGroupCommand]
public Task ShowFortune(CommandContext ctx)
=> ShowFortune(ctx.Message, ctx.User);
@@ -72,7 +71,7 @@ internal sealed class Fortune : BaseCommandModuleCustom
await ctx.ReactWithAsync(Config.Reactions.Success).ConfigureAwait(false);
}
[Command("remove"), Aliases("delete"), RequiresBotModRole]
[Command("remove"), TextAlias("delete"), RequiresBotModRole]
[Description("Removes fortune with specified ID")]
public async Task Remove(CommandContext ctx, int id)
{
@@ -89,7 +88,7 @@ internal sealed class Fortune : BaseCommandModuleCustom
await ctx.ReactWithAsync(Config.Reactions.Success).ConfigureAwait(false);
}
[Command("import"), Aliases("append"), RequiresBotModRole, TriggersTyping]
[Command("import"), TextAlias("append"), RequiresBotModRole, TriggersTyping]
[Description("Imports new fortunes from specified URL or attachment. Data should be formatted as standard UNIX fortune source file.")]
public async Task Import(CommandContext ctx, string? url = null)
{

View File

@@ -3,12 +3,12 @@ using Microsoft.EntityFrameworkCore;
namespace CompatBot.Commands;
[Group("hardware"), Aliases("hw")]
[Command("hardware"), TextAlias("hw")]
[Description("Various hardware stats from uploaded log files")]
[Cooldown(1, 5, CooldownBucketType.Guild)]
internal sealed class Hardware: BaseCommandModuleCustom
//[Cooldown(1, 5, CooldownBucketType.Guild)]
internal sealed class Hardware
{
[GroupCommand]
[Command("show"), DefaultGroupCommand]
public Task Show(CommandContext ctx) => ShowStats(ctx);
[Command("stats")]

View File

@@ -1,6 +1,5 @@
using System.IO;
using CompatApiClient.Utils;
using CompatBot.Commands.Attributes;
using CompatBot.Database;
using CompatBot.Database.Providers;
using CompatBot.EventHandlers;
@@ -8,11 +7,11 @@ using Microsoft.EntityFrameworkCore;
namespace CompatBot.Commands;
[Group("invite"), Aliases("invites"), RequiresBotModRole]
[Command("invite"), TextAlias("invites"), RequiresBotModRole]
[Description("Used to manage Discord invites whitelist")]
internal sealed class Invites: BaseCommandModuleCustom
internal sealed class Invites
{
[Command("list"), Aliases("show")]
[Command("list"), TextAlias("show")]
[Description("Lists all filters")]
public async Task List(CommandContext ctx)
{
@@ -67,7 +66,7 @@ internal sealed class Invites: BaseCommandModuleCustom
await ctx.Channel.SendMessageAsync(new DiscordMessageBuilder().AddFile("invites.txt", output)).ConfigureAwait(false);
}
[Command("whitelist"), Aliases("add", "allow"), Priority(10)]
[Command("whitelist"), TextAlias("add", "allow")]
[Description("Adds a new guild to the whitelist")]
public async Task Add(CommandContext ctx, [Description("A Discord server IDs to whitelist")] params ulong[] guildIds)
{
@@ -82,7 +81,7 @@ internal sealed class Invites: BaseCommandModuleCustom
await ctx.ReactWithAsync(Config.Reactions.Failure, $"Failed to add {errors} invite{StringUtils.GetSuffix(errors)} to the whitelist").ConfigureAwait(false);
}
[Command("whitelist"), Priority(0)]
[Command("whitelist")]
[Description("Adds a new guild to the whitelist")]
public async Task Add(CommandContext ctx, [RemainingText, Description("An invite link or just an invite token")] string invite)
{
@@ -129,7 +128,7 @@ internal sealed class Invites: BaseCommandModuleCustom
await List(ctx).ConfigureAwait(false);
}
[Command("rename"), Aliases("name")]
[Command("rename"), TextAlias("name")]
[Description("Give a custom name for a Discord server")]
public async Task Rename(CommandContext ctx, [Description("Filter ID to rename")] int id, [RemainingText, Description("Custom server name")] string name)
{
@@ -153,7 +152,7 @@ internal sealed class Invites: BaseCommandModuleCustom
await List(ctx).ConfigureAwait(false);
}
[Command("remove"), Aliases("delete", "del")]
[Command("remove"), TextAlias("delete", "del")]
[Description("Removes server from whitelist")]
public async Task Remove(CommandContext ctx, [Description("Filter IDs to remove, separated with spaces")] params int[] ids)
{

View File

@@ -1,10 +1,9 @@
using CompatBot.Commands.Attributes;
using CompatBot.Utils.ResultFormatters;
using CompatBot.Utils.ResultFormatters;
using IrdLibraryClient;
namespace CompatBot.Commands;
internal sealed class Ird: BaseCommandModuleCustom
internal sealed class Ird
{
private static readonly IrdClient Client = new();

View File

@@ -1,11 +1,6 @@
using CompatBot.Commands.Attributes;
namespace CompatBot.Commands;
namespace CompatBot.Commands;
[Group("minesweeper"), Aliases("msgen")]
[LimitedToOfftopicChannel, Cooldown(1, 30, CooldownBucketType.Channel)]
[Description("Generates a minesweeper field with specified parameters")]
internal sealed class Minesweeper : BaseCommandModuleCustom
internal sealed class Minesweeper
{
//private static readonly string[] Numbers = ["0⃣", "1⃣", "2⃣", "3⃣", "4⃣", "5⃣", "6⃣", "7⃣", "8⃣", "9⃣"];
private static readonly string[] Numbers = ["", "", "", "", "", "", "", "", "", ""];
@@ -34,7 +29,10 @@ internal sealed class Minesweeper : BaseCommandModuleCustom
Mine = 255,
}
[GroupCommand]
[Command("minesweeper"), TextAlias("msgen")]
[LimitedToOfftopicChannel]
//[Cooldown(1, 30, CooldownBucketType.Channel)]
[Description("Generates a minesweeper field with specified parameters")]
public async Task Generate(CommandContext ctx,
[Description("Width of the field")] int width = 14,
[Description("Height of the field")] int height = 14,

View File

@@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore;
namespace CompatBot.Commands;
internal sealed partial class Misc: BaseCommandModuleCustom
internal sealed partial class Misc
{
private static readonly Random rng = new();
@@ -123,6 +123,32 @@ internal sealed partial class Misc: BaseCommandModuleCustom
[GeneratedRegex(@"(?<num>\d+)?d(?<face>\d+)(?:\+(?<mod>\d+))?")]
private static partial Regex DiceNotationPattern();
[Command("about"), Description("Bot information")]
public async Task About(CommandContext ctx)
{
var hcorion = ctx.Client.GetEmoji(":hcorion:", DiscordEmoji.FromUnicode("🍁"));
var clienthax = ctx.Client.GetEmoji(":gooseknife:", DiscordEmoji.FromUnicode("🐱"));
var embed = new DiscordEmbedBuilder
{
Title = "RPCS3 Compatibility Bot",
Url = "https://github.com/RPCS3/discord-bot",
Color = DiscordColor.Purple,
}.AddField("Made by", $"""
💮 13xforever
🇭🇷 Roberto Anić Banić aka nicba1010
{clienthax} clienthax
"""
).AddField("People who ~~broke~~ helped test the bot", $"""
🐱 Juhn
{hcorion} hcorion
🙃 TGE
🍒 Maru
♋ Tourghool
"""
).WithFooter($"Running {Config.GitRevision}");
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AddEmbed(embed.Build()).AsEphemeral());
}
[Command("roll")]
[Description("Generates a random number between 1 and maxValue. Can also roll dices like `2d6`. Default is 1d6")]
public Task Roll(CommandContext ctx, [Description("Some positive natural number")] int maxValue = 6, [RemainingText, Description("Optional text")] string? comment = null)
@@ -205,7 +231,8 @@ internal sealed partial class Misc: BaseCommandModuleCustom
await message.Channel.SendMessageAsync(new DiscordMessageBuilder().WithContent(result).WithReply(message.Id)).ConfigureAwait(false);
}
[Command("random"), Aliases("rng"), Hidden, Cooldown(1, 3, CooldownBucketType.Channel)]
[Command("random"), TextAlias("rng")]
//[Hidden, Cooldown(1, 3, CooldownBucketType.Channel)]
[Description("Provides random stuff")]
public async Task RandomShit(CommandContext ctx, string stuff)
{
@@ -243,7 +270,8 @@ internal sealed partial class Misc: BaseCommandModuleCustom
}
}
[Command("8ball"), Cooldown(20, 60, CooldownBucketType.Channel)]
[Command("8ball")]
//[Cooldown(20, 60, CooldownBucketType.Channel)]
[Description("Provides a ~~random~~ objectively best answer to your question")]
public async Task EightBall(CommandContext ctx, [RemainingText, Description("A yes/no question")] string question)
{
@@ -261,7 +289,8 @@ internal sealed partial class Misc: BaseCommandModuleCustom
}
}
[Command("when"), Hidden, Cooldown(20, 60, CooldownBucketType.Channel)]
[Command("when")]
//[Hidden, Cooldown(20, 60, CooldownBucketType.Channel)]
[Description("Provides advanced clairvoyance services to predict the time frame for specified event with maximum accuracy")]
public async Task When(CommandContext ctx, [RemainingText, Description("Something to happen")] string something = "")
{
@@ -282,11 +311,12 @@ internal sealed partial class Misc: BaseCommandModuleCustom
await ctx.RespondAsync($"🔮 My psychic powers tell me it {willWont} happen in the next **{number} {unit}** 🔮").ConfigureAwait(false);
}
[Group("how"), Hidden, Cooldown(20, 60, CooldownBucketType.Channel)]
[Command("how")]
//[Hidden, Cooldown(20, 60, CooldownBucketType.Channel)]
[Description("Provides advanced clairvoyance services to predict the exact amount of anything that could be measured")]
public class How: BaseCommandModuleCustom
public class How
{
[Command("much"), Aliases("many")]
[Command("much"), TextAlias("many")]
[Description("Provides advanced clairvoyance services to predict the exact amount of anything that could be measured")]
public async Task Much(CommandContext ctx, [RemainingText, Description("much or many ")] string ofWhat = "")
{
@@ -300,7 +330,8 @@ internal sealed partial class Misc: BaseCommandModuleCustom
}
}
[Command("rate"), Cooldown(20, 60, CooldownBucketType.Channel)]
[Command("rate")]
//[Cooldown(20, 60, CooldownBucketType.Channel)]
[Description("Gives a ~~random~~ expert judgment on the matter at hand")]
public async Task Rate(CommandContext ctx, [RemainingText, Description("Something to rate")] string whatever = "")
{
@@ -478,7 +509,8 @@ internal sealed partial class Misc: BaseCommandModuleCustom
}
}
[Command("meme"), Aliases("memes"), Cooldown(1, 30, CooldownBucketType.Channel), Hidden]
[Command("meme"), TextAlias("memes")]
//[Cooldown(1, 30, CooldownBucketType.Channel), Hidden]
[Description("No, memes are not implemented yet")]
public async Task Memes(CommandContext ctx, [RemainingText] string? _ = null)
{
@@ -490,11 +522,13 @@ internal sealed partial class Misc: BaseCommandModuleCustom
await ch.SendMessageAsync(msgBuilder).ConfigureAwait(false);
}
[Command("firmware"), Aliases("fw"), Cooldown(1, 10, CooldownBucketType.Channel)]
[Command("firmware"), TextAlias("fw")]
//[Cooldown(1, 10, CooldownBucketType.Channel)]
[Description("Checks for latest PS3 firmware version")]
public Task Firmware(CommandContext ctx) => Psn.Check.GetFirmwareAsync(ctx);
[Command("compare"), Hidden]
[Command("compare")]
//[Hidden]
[Description("Calculates the similarity metric of two phrases from 0 (completely different) to 1 (identical)")]
public Task Compare(CommandContext ctx, string strA, string strB)
{
@@ -502,7 +536,7 @@ internal sealed partial class Misc: BaseCommandModuleCustom
return ctx.Channel.SendMessageAsync($"Similarity score is {result:0.######}");
}
[Command("productcode"), Aliases("pci", "decode")]
[Command("productcode"), TextAlias("pci", "decode")]
[Description("Describe Playstation product code")]
public async Task ProductCode(CommandContext ctx, [RemainingText, Description("Product code such as BLUS12345 or SCES")] string productCode)
{

View File

@@ -1,20 +1,19 @@
using System.IO;
using System.IO.Compression;
using CompatApiClient.Utils;
using CompatBot.Commands.Attributes;
using CompatBot.EventHandlers;
namespace CompatBot.Commands;
internal sealed partial class Moderation
{
[Group("audit"), RequiresBotModRole]
[Command("audit"), RequiresBotModRole]
[Description("Commands to audit server things")]
public sealed class Audit: BaseCommandModuleCustom
public sealed class Audit
{
public static readonly SemaphoreSlim CheckLock = new(1, 1);
[Command("spoofing"), Aliases("impersonation"), RequireDirectMessage]
[Command("spoofing"), TextAlias("impersonation"), RequiresDm]
[Description("Checks every user on the server for name spoofing")]
public Task Spoofing(CommandContext ctx)
{
@@ -22,7 +21,7 @@ internal sealed partial class Moderation
return Task.CompletedTask;
}
[Command("members"), Aliases("users"), RequireDirectMessage]
[Command("members"), TextAlias("users"), RequiresDm]
[Description("Dumps server member information, including usernames, nicknames, and roles")]
public async Task Members(CommandContext ctx)
{
@@ -125,7 +124,7 @@ internal sealed partial class Moderation
}
[Command("zalgo"), Aliases("diacritics")]
[Command("zalgo"), TextAlias("diacritics")]
[Description("Checks every member's display name for discord and rule #7 requirements")]
public async Task Zalgo(CommandContext ctx)
{
@@ -182,7 +181,7 @@ internal sealed partial class Moderation
}
#if DEBUG
[Command("locales"), Aliases("locale", "languages", "language", "lang", "loc")]
[Command("locales"), TextAlias("locale", "languages", "language", "lang", "loc")]
public async Task UserLocales(CommandContext ctx)
{
#pragma warning disable VSTHRD103

View File

@@ -1,9 +1,8 @@
using CompatBot.Commands.Attributes;
using CompatBot.EventHandlers;
using CompatBot.EventHandlers;
namespace CompatBot.Commands;
internal sealed partial class Moderation: BaseCommandModuleCustom
internal sealed partial class Moderation
{
[Command("report"), RequiresWhitelistedRole]
[Description("Adds specified message to the moderation queue")]
@@ -41,7 +40,7 @@ internal sealed partial class Moderation: BaseCommandModuleCustom
}
}
[Command("analyze"), Aliases("reanalyze", "parse", "a")]
[Command("analyze"), TextAlias("reanalyze", "parse", "a")]
[Description("Make bot to look at the attached log again")]
public async Task Reanalyze(CommandContext ctx, [Description("Message ID from the same channel")]ulong messageId)
{
@@ -96,7 +95,7 @@ internal sealed partial class Moderation: BaseCommandModuleCustom
}
}
[Command("badupdate"), Aliases("bad", "recall"), RequiresBotModRole]
[Command("badupdate"), TextAlias("bad", "recall"), RequiresBotModRole]
[Description("Toggles new update announcement as being bad")]
public async Task BadUpdate(CommandContext ctx, [Description("Link to the update announcement")] string updateMessageLink)
{

View File

@@ -1,5 +1,4 @@
using CompatApiClient.Utils;
using CompatBot.Commands.Attributes;
using CompatBot.Utils.Extensions;
using CompatBot.Utils.ResultFormatters;
using Microsoft.TeamFoundation.Build.WebApi;
@@ -7,17 +6,17 @@ using BuildStatus = Microsoft.TeamFoundation.Build.WebApi.BuildStatus;
namespace CompatBot.Commands;
[Group("pr"), TriggersTyping]
[Command("pr"), TriggersTyping]
[Description("Commands to list opened pull requests information")]
internal sealed class Pr: BaseCommandModuleCustom
internal sealed class Pr
{
private static readonly GithubClient.Client GithubClient = new(Config.GithubToken);
private static readonly CompatApiClient.Client CompatApiClient = new();
[GroupCommand]
[Command("search"), DefaultGroupCommand]
public Task List(CommandContext ctx, [Description("Get information for specific PR number")] int pr) => LinkPrBuild(ctx.Client, ctx.Message, pr);
[GroupCommand]
[Command("search"), DefaultGroupCommand]
public async Task List(CommandContext ctx, [Description("Get information for PRs with specified text in description. First word might be an author"), RemainingText] string? searchStr = null)
{
var openPrList = await GithubClient.GetOpenPrsAsync(Config.Cts.Token).ConfigureAwait(false);
@@ -81,7 +80,7 @@ internal sealed class Pr: BaseCommandModuleCustom
await responseChannel.SendAutosplitMessageAsync(result, blockStart: null, blockEnd: null).ConfigureAwait(false);
}
[Command("link"), Aliases("old")]
[Command("link"), TextAlias("old")]
[Description("Links to the official binary builds produced after specified PR was merged")]
public Task Link(CommandContext ctx, [Description("PR number")] int pr) => LinkPrBuild(ctx.Client, ctx.Message, pr, true);

View File

@@ -1,6 +1,5 @@
using CompatApiClient;
using CompatApiClient.Utils;
using CompatBot.Commands.Attributes;
using CompatBot.Database;
using CompatBot.Database.Providers;
using CompatBot.EventHandlers;
@@ -12,13 +11,13 @@ namespace CompatBot.Commands;
internal sealed partial class Psn
{
[Group("check")]
[Command("check")]
[Description("Commands to check for various stuff on PSN")]
public sealed class Check: BaseCommandModuleCustom
public sealed class Check
{
private static string? latestFwVersion;
[Command("updates"), Aliases("update"), LimitedToSpamChannel]
[Command("updates"), TextAlias("update"), LimitedToSpamChannel]
[Description("Checks if specified product has any updates")]
public async Task Updates(CommandContext ctx, [RemainingText, Description("Product code such as `BLUS12345`")] string productCode)
{
@@ -136,7 +135,8 @@ internal sealed partial class Psn
}
}
[Command("content"), Hidden]
[Command("content")]
//[Hidden]
[Description("Adds PSN content id to the scraping queue")]
public async Task Content(CommandContext ctx, [RemainingText, Description("Content IDs to scrape, such as `UP0006-NPUB30592_00-MONOPOLYPSNNA000`")] string contentIds)
{
@@ -160,8 +160,8 @@ internal sealed partial class Psn
await ctx.ReactWithAsync(Config.Reactions.Success, $"Added {itemsToCheck.Count} ID{StringUtils.GetSuffix(itemsToCheck.Count)} to the scraping queue").ConfigureAwait(false);
}
[Command("firmware"), Aliases("fw")]
[Cooldown(1, 10, CooldownBucketType.Channel)]
[Command("firmware"), TextAlias("fw")]
//[Cooldown(1, 10, CooldownBucketType.Channel)]
[Description("Checks for latest PS3 firmware version")]
public Task Firmware(CommandContext ctx) => GetFirmwareAsync(ctx);

View File

@@ -1,18 +1,17 @@
using CompatBot.Commands.Attributes;
using CompatBot.Database;
using CompatBot.Database;
using CompatBot.EventHandlers;
using CompatBot.ThumbScrapper;
using PsnClient;
namespace CompatBot.Commands;
[Group("psn")]
[Command("psn")]
[Description("Commands related to PSN metadata")]
internal sealed partial class Psn: BaseCommandModuleCustom
internal sealed partial class Psn
{
private static readonly Client Client = new();
[Command("rename"), Aliases("setname", "settitle"), RequiresBotModRole]
[Command("rename"), TextAlias("setname", "settitle"), RequiresBotModRole]
[Description("Command to set or change game title for specific product code")]
public async Task Rename(CommandContext ctx, [Description("Product code such as BLUS12345")] string productCode, [RemainingText, Description("New game title to save in the database")] string title)
{

View File

@@ -1,30 +0,0 @@
namespace CompatBot.Commands;
internal sealed class SlashMisc: BaseApplicationCommandModuleCustom
{
[SlashCommand("about", "Bot information")]
public async Task About(InteractionContext ctx)
{
var hcorion = ctx.Client.GetEmoji(":hcorion:", DiscordEmoji.FromUnicode("🍁"));
var clienthax = ctx.Client.GetEmoji(":gooseknife:", DiscordEmoji.FromUnicode("🐱"));
var embed = new DiscordEmbedBuilder
{
Title = "RPCS3 Compatibility Bot",
Url = "https://github.com/RPCS3/discord-bot",
Color = DiscordColor.Purple,
}.AddField("Made by", $"""
💮 13xforever
🇭🇷 Roberto Anić Banić aka nicba1010
{clienthax} clienthax
"""
).AddField("People who ~~broke~~ helped test the bot", $"""
🐱 Juhn
{hcorion} hcorion
🙃 TGE
🍒 Maru
♋ Tourghool
"""
).WithFooter($"Running {Config.GitRevision}");
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AddEmbed(embed.Build()).AsEphemeral());
}
}

View File

@@ -1,5 +1,4 @@
using CompatBot.Commands.Attributes;
using CompatBot.Database;
using CompatBot.Database;
using CompatBot.Database.Providers;
using Microsoft.EntityFrameworkCore;
@@ -9,11 +8,11 @@ internal partial class Sudo
{
public sealed partial class Bot
{
[Group("config"), RequiresBotSudoerRole]
[Command("config"), RequiresBotSudoerRole]
[Description("Commands to set or clear bot configuration variables")]
public sealed class Configuration : BaseCommandModule
public sealed class Configuration
{
[Command("list"), Aliases("show")]
[Command("list"), TextAlias("show")]
[Description("Lists set variable names")]
public async Task List(CommandContext ctx)
{
@@ -56,7 +55,7 @@ internal partial class Sudo
await ctx.ReactWithAsync(Config.Reactions.Success, "Set variable successfully").ConfigureAwait(false);
}
[Command("clear"), Aliases("unset", "remove", "reset")]
[Command("clear"), TextAlias("unset", "remove", "reset")]
[Description("Removes configuration variable")]
public async Task Clear(CommandContext ctx, string key)
{

View File

@@ -1,5 +1,4 @@
using System.Diagnostics;
using CompatBot.Commands.Attributes;
using CompatBot.Database;
using CompatBot.Database.Providers;
using Microsoft.EntityFrameworkCore;
@@ -13,9 +12,9 @@ internal partial class Sudo
private static readonly SemaphoreSlim ImportLockObj = new(1, 1);
private static readonly ProcessStartInfo RestartInfo = new("dotnet", $"run -c Release");
[Group("bot"), Aliases("kot")]
[Command("bot"), TextAlias("kot")]
[Description("Commands to manage the bot instance")]
public sealed partial class Bot: BaseCommandModuleCustom
public sealed partial class Bot
{
[Command("version")]
[Description("Returns currently checked out bot commit")]
@@ -38,11 +37,11 @@ internal partial class Sudo
await ctx.Channel.SendMessageAsync("```" + stdout + "```").ConfigureAwait(false);
}
[Command("update"), Aliases("upgrade", "pull", "pet")]
[Command("update"), TextAlias("upgrade", "pull", "pet")]
[Description("Updates the bot, and then restarts it")]
public Task Update(CommandContext ctx) => UpdateCheckAsync(ctx.Channel, Config.Cts.Token);
[Command("restart"), Aliases("reboot")]
[Command("restart"), TextAlias("reboot")]
[Description("Restarts the bot")]
public async Task Restart(CommandContext ctx)
{
@@ -69,7 +68,7 @@ internal partial class Sudo
await ctx.Channel.SendMessageAsync("Update is in progress").ConfigureAwait(false);
}
[Command("stop"), Aliases("exit", "shutdown", "terminate")]
[Command("stop"), TextAlias("exit", "shutdown", "terminate")]
[Description("Stops the bot. Useful if you can't find where you left one running")]
public async Task Stop(CommandContext ctx)
{
@@ -118,7 +117,7 @@ internal partial class Sudo
}
}
[Command("import_metacritic"), Aliases("importmc", "imc"), TriggersTyping]
[Command("import_metacritic"), TextAlias("importmc", "imc"), TriggersTyping]
[Description("Imports Metacritic database dump and links it to existing items")]
public async Task ImportMc(CommandContext ctx)
{

View File

@@ -6,14 +6,14 @@ namespace CompatBot.Commands;
internal partial class Sudo
{
[Group("dotnet")]
[Command("dotnet")]
[Description("Commands to manage dotnet")]
public sealed partial class Dotnet : BaseCommandModuleCustom
public sealed partial class Dotnet
{
[GeneratedRegex(@"\.NET( Core)? (?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(-.+)?", RegexOptions.ExplicitCapture | RegexOptions.Singleline)]
private static partial Regex DotnetVersionPattern();
[Command("update"), Aliases("upgrade")]
[Command("update"), TextAlias("upgrade")]
[Description("Updates dotnet, and then restarts the bot")]
public async Task Update(CommandContext ctx, [Description("Dotnet SDK version (e.g. `5.1`)")] string version = "")
{

View File

@@ -12,9 +12,10 @@ internal sealed partial class Sudo
private static readonly Regex Timestamp = new(@"^(?<cutout>(?<date>\d{4}-\d\d-\d\d[ T][0-9:\.]+Z?) - )", RegexOptions.ExplicitCapture | RegexOptions.Singleline);
private static readonly Regex Channel = new(@"(?<id><#\d+>)", RegexOptions.ExplicitCapture | RegexOptions.Singleline);
[Group("fix"), Hidden]
[Command("fix")]
//[Hidden]
[Description("Commands to fix various stuff")]
public sealed class Fix: BaseCommandModuleCustom
public sealed class Fix
{
[Command("timestamps")]
[Description("Fixes `timestamp` column in the `warning` table")]
@@ -99,7 +100,7 @@ internal sealed partial class Sudo
}
}
[Command("title_marks"), Aliases("trademarks", "tms")]
[Command("title_marks"), TextAlias("trademarks", "tms")]
[Description("Strips trade marks and similar cruft from game titles in local database")]
public async Task TitleMarks(CommandContext ctx)
{
@@ -128,7 +129,7 @@ internal sealed partial class Sudo
await ctx.Channel.SendMessageAsync($"Fixed {changed} title{(changed == 1 ? "" : "s")}").ConfigureAwait(false);
}
[Command("metacritic_links"), Aliases("mcl")]
[Command("metacritic_links"), TextAlias("mcl")]
[Description("Cleans up Metacritic links")]
public async Task MetacriticLinks(CommandContext ctx, [Description("Remove links for trial and demo versions only")] bool demosOnly = true)
{

View File

@@ -4,9 +4,9 @@ namespace CompatBot.Commands;
internal partial class Sudo
{
[Group("mod")]
[Command("mod")]
[Description("Used to manage bot moderators")]
public sealed class Mod : BaseCommandModuleCustom
public sealed class Mod
{
[Command("add")]
[Description("Adds a new moderator")]
@@ -25,7 +25,7 @@ internal partial class Sudo
await ctx.ReactWithAsync(Config.Reactions.Failure, $"{user.Mention} is already a moderator").ConfigureAwait(false);
}
[Command("remove"), Aliases("delete", "del")]
[Command("remove"), TextAlias("delete", "del")]
[Description("Removes a moderator")]
public async Task Remove(CommandContext ctx, [Description("Discord user to remove from the bot mod list")] DiscordMember user)
{
@@ -41,7 +41,7 @@ internal partial class Sudo
await ctx.ReactWithAsync(Config.Reactions.Failure, $"{user.Mention} is not a moderator").ConfigureAwait(false);
}
[Command("list"), Aliases("show")]
[Command("list"), TextAlias("show")]
[Description("Lists all moderators")]
public async Task List(CommandContext ctx)
{

View File

@@ -3,7 +3,6 @@ using System.IO;
using System.Net.Http;
using CompatApiClient.Compression;
using CompatApiClient.Utils;
using CompatBot.Commands.Attributes;
using CompatBot.Commands.Converters;
using CompatBot.Database;
using Microsoft.EntityFrameworkCore;
@@ -15,9 +14,9 @@ using SharpCompress.Writers.Zip;
namespace CompatBot.Commands;
[Group("sudo"), RequiresBotSudoerRole]
[Command("sudo"), RequiresBotSudoerRole]
[Description("Used to manage bot moderators and sudoers")]
internal sealed partial class Sudo : BaseCommandModuleCustom
internal sealed partial class Sudo
{
[Command("say")]
[Description("Make bot say things. Specify #channel or put message link in the beginning to specify where to reply")]
@@ -161,7 +160,7 @@ internal sealed partial class Sudo : BaseCommandModuleCustom
}
}
[Command("dbbackup"), Aliases("dbb"), TriggersTyping]
[Command("dbbackup"), TextAlias("dbb"), TriggersTyping]
[Description("Uploads current Thumbs.db and Hardware.db files as an attachments")]
public async Task DbBackup(CommandContext ctx, [Description("Name of the database")]string name = "")
{

View File

@@ -1,17 +1,16 @@
using System.IO;
using CompatApiClient.Utils;
using CompatBot.Commands.Attributes;
using CompatBot.Database;
using CompatBot.EventHandlers;
using Microsoft.EntityFrameworkCore;
namespace CompatBot.Commands;
[Group("syscall"), Aliases("syscalls", "cell", "sce", "scecall", "scecalls"), LimitedToSpamChannel]
[Command("syscall"), TextAlias("syscalls", "cell", "sce", "scecall", "scecalls"), LimitedToSpamChannel]
[Description("Provides information about syscalls used by games")]
internal sealed class Syscall: BaseCommandModuleCustom
internal sealed class Syscall
{
[GroupCommand]
[Command("search"), DefaultGroupCommand]
public async Task Search(CommandContext ctx, [RemainingText, Description("Product ID, module, or function name. **Case sensitive**")] string search)
{
if (string.IsNullOrEmpty(search))

View File

@@ -2,7 +2,6 @@
using System.Net;
using System.Net.Http;
using ColorThiefDotNet;
using CompatBot.Commands.Attributes;
using CompatBot.EventHandlers;
using CompatBot.Utils.Extensions;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
@@ -22,8 +21,8 @@ using SystemFonts = SixLabors.Fonts.SystemFonts;
namespace CompatBot.Commands;
[Cooldown(1, 5, CooldownBucketType.Channel)]
internal sealed class Vision: BaseCommandModuleCustom
//[Cooldown(1, 5, CooldownBucketType.Channel)]
internal sealed class Vision
{
static Vision()
{

View File

@@ -1,5 +1,4 @@
using CompatApiClient.Utils;
using CompatBot.Commands.Attributes;
using CompatBot.Database;
using CompatBot.Database.Providers;
using DSharpPlus.Commands.Converters;
@@ -8,11 +7,16 @@ namespace CompatBot.Commands;
internal sealed partial class Warnings
{
[Group("list"), Aliases("show")]
[Command("list"), TextAlias("show")]
[Description("Allows to list warnings in various ways. Users can only see their own warnings.")]
public class ListGroup : BaseCommandModuleCustom
public class ListGroup
{
[GroupCommand, Priority(10)]
[Command("me"), DefaultGroupCommand]
[Description("List your own warning list")]
public async Task List(CommandContext ctx)
=> await List(ctx, ctx.Message.Author).ConfigureAwait(false);
[Command("user")]
[Description("Show warning list for a user. Default is to show warning list for yourself")]
public async Task List(CommandContext ctx, [Description("Discord user to list warnings for")] DiscordUser user)
{
@@ -20,19 +24,14 @@ internal sealed partial class Warnings
await ListUserWarningsAsync(ctx.Client, ctx.Message, user.Id, user.Username.Sanitize(), false);
}
[GroupCommand]
[Command("user")]
public async Task List(CommandContext ctx, [Description("Id of the user to list warnings for")] ulong userId)
{
if (await CheckListPermissionAsync(ctx, userId).ConfigureAwait(false))
await ListUserWarningsAsync(ctx.Client, ctx.Message, userId, $"<@{userId}>", false);
}
[GroupCommand]
[Description("List your own warning list")]
public async Task List(CommandContext ctx)
=> await List(ctx, ctx.Message.Author).ConfigureAwait(false);
[Command("users"), Aliases("top"), RequiresBotModRole, TriggersTyping]
[Command("users"), TextAlias("top"), RequiresBotModRole, TriggersTyping]
[Description("List users with warnings, sorted from most warned to least")]
public async Task Users(CommandContext ctx, [Description("Optional number of items to show. Default is 10")] int number = 10)
{
@@ -67,7 +66,7 @@ internal sealed partial class Warnings
}
}
[Command("mods"), Aliases("mtop"), RequiresBotModRole, TriggersTyping]
[Command("mods"), TextAlias("mtop"), RequiresBotModRole, TriggersTyping]
[Description("List bot mods, sorted by the number of warnings issued")]
public async Task Mods(CommandContext ctx, [Description("Optional number of items to show. Default is 10")] int number = 10)
{
@@ -134,7 +133,7 @@ internal sealed partial class Warnings
}
[Command("by"), Priority(1), RequiresBotModRole]
[Command("by"), RequiresBotModRole]
public async Task By(CommandContext ctx, string me, [Description("Optional number of items to show. Default is 10")] int number = 10)
{
if (me.ToLowerInvariant() == "me")
@@ -148,11 +147,11 @@ internal sealed partial class Warnings
await By(ctx, user.Value, number).ConfigureAwait(false);
}
[Command("by"), Priority(10), RequiresBotModRole]
[Command("by"), RequiresBotModRole]
public Task By(CommandContext ctx, DiscordUser moderator, [Description("Optional number of items to show. Default is 10")] int number = 10)
=> By(ctx, moderator.Id, number);
[Command("recent"), Aliases("last", "all"), RequiresBotModRole]
[Command("recent"), TextAlias("last", "all"), RequiresBotModRole]
[Description("Shows last issued warnings in chronological order")]
public async Task Last(CommandContext ctx, [Description("Optional number of items to show. Default is 10")] int number = 10)
{

View File

@@ -1,15 +1,14 @@
using CompatApiClient.Utils;
using CompatBot.Commands.Attributes;
using CompatBot.Database;
using Microsoft.EntityFrameworkCore;
namespace CompatBot.Commands;
[Group("warn")]
[Command("warn")]
[Description("Command used to manage warnings")]
internal sealed partial class Warnings: BaseCommandModuleCustom
internal sealed partial class Warnings
{
[GroupCommand] //attributes on overloads do not work, so no easy permission checks
[DefaultGroupCommand] //attributes on overloads do not work, so no easy permission checks
[Description("Command used to issue a new warning")]
public async Task Warn(CommandContext ctx, [Description("User to warn. Can also use @id")] DiscordUser user, [RemainingText, Description("Warning explanation")] string reason)
{
@@ -23,7 +22,7 @@ internal sealed partial class Warnings: BaseCommandModuleCustom
await ctx.ReactWithAsync(Config.Reactions.Failure, "Couldn't save the warning, please try again").ConfigureAwait(false);
}
[GroupCommand]
[DefaultGroupCommand]
public async Task Warn(CommandContext ctx, [Description("ID of a user to warn")] ulong userId, [RemainingText, Description("Warning explanation")] string reason)
{
if (!await new RequiresBotModRoleAttribute().ExecuteCheckAsync(ctx, false).ConfigureAwait(false))
@@ -75,7 +74,7 @@ internal sealed partial class Warnings: BaseCommandModuleCustom
await ctx.Channel.SendMessageAsync($"Warning successfully edited!").ConfigureAwait(false);
}
[Command("remove"), Aliases("delete", "del"), RequiresBotModRole]
[Command("remove"), TextAlias("delete", "del"), RequiresBotModRole]
[Description("Removes specified warnings")]
public async Task Remove(CommandContext ctx, [Description("Warning IDs to remove separated with space")] params int[] ids)
{

View File

@@ -145,33 +145,11 @@ internal static class Program
});
textCommandProcessor.AddConverter<TextOnlyDiscordChannelConverter>();
extension.AddProcessor(textCommandProcessor);
#if DEBUG
extension.AddCommands<DevOnly>();
#endif
extension.AddCommands<Misc>();
extension.AddCommands<SlashMisc>();
extension.AddCommands<CompatList>();
extension.AddCommands<Sudo>();
extension.AddCommands<CommandsManagement>();
extension.AddCommands<ContentFilters>();
extension.AddCommands<Warnings>();
extension.AddCommands<Explain>();
extension.AddCommands<Psn>();
extension.AddCommands<Invites>();
extension.AddCommands<Moderation>();
extension.AddCommands<Ird>();
extension.AddCommands<BotMath>();
extension.AddCommands<Pr>();
extension.AddCommands<Events>();
extension.AddCommands<E3>();
extension.AddCommands<BotStats>();
extension.AddCommands<Hardware>();
extension.AddCommands<Syscall>();
extension.AddCommands<ForcedNicknames>();
extension.AddCommands<Minesweeper>();
extension.AddCommands<Fortune>();
extension.AddCommands(Assembly.GetAssembly(typeof(CompatList))!);
/*
if (!string.IsNullOrEmpty(Config.AzureComputerVisionKey))
extension.AddCommands<Vision>();
*/
//extension.CommandErrored += UnknownCommandHandler.OnError;
}, new()

View File

@@ -2,13 +2,19 @@
global using System;
global using System.Collections.Generic;
global using System.ComponentModel;
global using System.Linq;
global using System.Text;
global using System.Threading;
global using System.Threading.Tasks;
global using CompatBot.Commands.Attributes;
global using CompatBot.Utils;
global using DSharpPlus;
global using DSharpPlus.Commands;
global using DSharpPlus.Commands.ArgumentModifiers;
global using DSharpPlus.Commands.Trees;
global using DSharpPlus.Commands.Trees.Metadata;
global using DSharpPlus.Entities;
global using DSharpPlus.EventArgs;
global using DSharpPlus.Interactivity.Extensions;

View File

@@ -5,6 +5,7 @@ using CompatBot.Database.Providers;
using CompatBot.EventHandlers;
using PsnClient.POCOs;
using PsnClient.Utils;
using Container = PsnClient.POCOs.Container;
namespace CompatBot.ThumbScrapper;