diff --git a/CompatBot/Commands/BaseApplicationCommandModuleCustom.cs b/CompatBot/Commands/BaseApplicationCommandModuleCustom.cs deleted file mode 100644 index 6a190518..00000000 --- a/CompatBot/Commands/BaseApplicationCommandModuleCustom.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Net; -using CompatBot.Database.Providers; - -namespace CompatBot.Commands; - -internal class BaseApplicationCommandModuleCustom : ApplicationCommandModule -{ - private DateTimeOffset executionStart; - - public override async Task BeforeSlashExecutionAsync(InteractionContext ctx) - { - executionStart = DateTimeOffset.UtcNow; - if (ctx is {Channel.Name: "media", Interaction: { Type: InteractionType.ApplicationCommand, Data.Name: not ("warn" or "report") } }) - { - //todo: look what's available in data - Config.Log.Info($"Ignoring slash command from {ctx.User.Username} (<@{ctx.User.Id}>) in #media: {ctx.Interaction.Data}"); - await ctx.Interaction.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, - new DiscordInteractionResponseBuilder().WithContent($"Only `warn` and `report` are allowed in {ctx.Channel.Mention}").AsEphemeral() - ).ConfigureAwait(false); - Config.TelemetryClient?.TrackRequest(ctx.Interaction.Data.Name, executionStart, DateTimeOffset.UtcNow - executionStart, HttpStatusCode.Forbidden.ToString(), true); - return false; - } - - var disabledCmds = DisabledCommandsProvider.Get(); - if (disabledCmds.Contains(ctx.Interaction.Data.Name) && !disabledCmds.Contains("*")) - { - await ctx.Interaction.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, - new DiscordInteractionResponseBuilder().WithContent($"Command `{ctx.Interaction.Data.Name}` is currently disabled").AsEphemeral() - ).ConfigureAwait(false); - Config.TelemetryClient?.TrackRequest(ctx.Interaction.Data.Name, executionStart, DateTimeOffset.UtcNow - executionStart, HttpStatusCode.Locked.ToString(), true); - return false; - } - - return await base.BeforeSlashExecutionAsync(ctx).ConfigureAwait(false); - } - - public override Task AfterSlashExecutionAsync(InteractionContext ctx) - { - StatsStorage.IncCmdStat(ctx.Interaction.Data.Name); - Config.TelemetryClient?.TrackRequest(ctx.Interaction.Data.Name, executionStart, DateTimeOffset.UtcNow - executionStart, HttpStatusCode.OK.ToString(), true); - return base.AfterSlashExecutionAsync(ctx); - } -} \ No newline at end of file diff --git a/CompatBot/Commands/BaseCommandModuleCustom.cs b/CompatBot/Commands/BaseCommandModuleCustom.cs index 572d77d8..c33505a2 100644 --- a/CompatBot/Commands/BaseCommandModuleCustom.cs +++ b/CompatBot/Commands/BaseCommandModuleCustom.cs @@ -5,6 +5,7 @@ using Microsoft.Extensions.Caching.Memory; namespace CompatBot.Commands; +/* internal class BaseCommandModuleCustom : BaseCommandModule { private DateTimeOffset executionStart; @@ -67,4 +68,5 @@ internal class BaseCommandModuleCustom : BaseCommandModule private static bool TriggersTyping(CommandContext ctx) => ctx.Command?.CustomAttributes.OfType().FirstOrDefault() is TriggersTyping a && a.ExecuteCheck(ctx); -} \ No newline at end of file +} +*/ diff --git a/CompatBot/Commands/CommandsManagement.cs b/CompatBot/Commands/CommandsManagement.cs index c7f5bb8e..6a3844d8 100644 --- a/CompatBot/Commands/CommandsManagement.cs +++ b/CompatBot/Commands/CommandsManagement.cs @@ -25,6 +25,7 @@ public sealed class CommandsManagement await ctx.Channel.SendMessageAsync("All commands are enabled").ConfigureAwait(false); } + /* [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) @@ -187,4 +188,5 @@ public sealed class CommandsManagement foreach (var subCmd in group.Children) EnableSubcommands(ctx, subCmd); } +*/ } \ No newline at end of file diff --git a/CompatBot/Commands/CompatList.cs b/CompatBot/Commands/CompatList.cs index 080555cc..98375185 100644 --- a/CompatBot/Commands/CompatList.cs +++ b/CompatBot/Commands/CompatList.cs @@ -56,6 +56,7 @@ internal sealed partial class CompatList } } + /* [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) @@ -100,6 +101,7 @@ internal sealed partial class CompatList Config.Log.Error(e, "Failed to get compat list info"); } } + */ [Command("top"), LimitedToOfftopicChannel] //[Cooldown(1, 5, CooldownBucketType.Channel)] @@ -260,7 +262,7 @@ internal sealed partial class CompatList if (botMember == null) return false; - if (!compatChannel.PermissionsFor(botMember).HasPermission(Permissions.SendMessages)) + if (!compatChannel.PermissionsFor(botMember).HasPermission(DiscordPermission.SendMessages)) { NewBuildsMonitor.Reset(); return false; @@ -392,6 +394,7 @@ internal sealed partial class CompatList } } + /* private static async Task DoRequestAndRespond(CommandContext ctx, RequestBuilder requestBuilder) { Config.Log.Info(requestBuilder.Build()); @@ -423,6 +426,7 @@ internal sealed partial class CompatList foreach (var msg in FormatSearchResults(ctx, result)) await channel.SendAutosplitMessageAsync(msg, blockStart: "", blockEnd: "").ConfigureAwait(false); } + */ internal static CompatResult GetLocalCompatResult(RequestBuilder requestBuilder) { @@ -453,6 +457,7 @@ internal sealed partial class CompatList return result; } + /* private static IEnumerable FormatSearchResults(CommandContext ctx, CompatResult compatResult) { var returnCode = ApiConfig.ReturnCodes[compatResult.ReturnCode]; @@ -507,6 +512,7 @@ internal sealed partial class CompatList } } } + */ public static string FixGameTitleSearch(string title) { @@ -701,4 +707,4 @@ internal sealed partial class CompatList } } } -} \ No newline at end of file +} diff --git a/CompatBot/Commands/ContentFilters.cs b/CompatBot/Commands/ContentFilters.cs index 7c227c85..2ec9ffb2 100644 --- a/CompatBot/Commands/ContentFilters.cs +++ b/CompatBot/Commands/ContentFilters.cs @@ -87,6 +87,7 @@ internal sealed partial class ContentFilters await ctx.Channel.SendMessageAsync(new DiscordMessageBuilder().AddFile("filters.txt", output)).ConfigureAwait(false); } + /* [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) @@ -192,7 +193,7 @@ internal sealed partial class ContentFilters if (string.IsNullOrEmpty(name)) continue; - + if (!ExtraIsoInfoPattern().IsMatch(name)) continue; @@ -220,7 +221,7 @@ internal sealed partial class ContentFilters ImportLock.Release(); } } - + [Command("edit"), TextAlias("fix", "update", "change")] [Description("Modifies the specified content filter")] public async Task Edit(CommandContext ctx, [Description("Filter ID")] int id) @@ -249,6 +250,7 @@ internal sealed partial class ContentFilters await EditFilterCmd(ctx, db, filter).ConfigureAwait(false); } + */ [Command("view"), TextAlias("show")] [Description("Shows the details of the specified content filter")] @@ -280,6 +282,7 @@ internal sealed partial class ContentFilters await ctx.Channel.SendMessageAsync(new DiscordMessageBuilder().AddEmbed(FormatFilter(filter))).ConfigureAwait(false); } + /* [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) @@ -897,6 +900,7 @@ internal sealed partial class ContentFilters } return (false, msg); } + */ private static DiscordEmbedBuilder FormatFilter(Piracystring filter, string? error = null, int highlight = -1) { diff --git a/CompatBot/Commands/Events.cs b/CompatBot/Commands/Events.cs index 71befe72..240878ee 100644 --- a/CompatBot/Commands/Events.cs +++ b/CompatBot/Commands/Events.cs @@ -1,5 +1,6 @@ namespace CompatBot.Commands; +/* [Command("event"), TextAlias("events", "e")] [Description("Provides information about the various events in the game industry")] internal sealed class Events: EventsBaseCommand @@ -53,4 +54,5 @@ internal sealed class Events: EventsBaseCommand [Description("Provides countdown for the nearest known event")] public Task Countdown(CommandContext ctx, string? eventName = null) => NearestEvent(ctx, eventName); -} \ No newline at end of file +} +*/ diff --git a/CompatBot/Commands/EventsBaseCommand.cs b/CompatBot/Commands/EventsBaseCommand.cs index 4a747f19..22b86600 100644 --- a/CompatBot/Commands/EventsBaseCommand.cs +++ b/CompatBot/Commands/EventsBaseCommand.cs @@ -8,6 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace CompatBot.Commands; +/* internal partial class EventsBaseCommand { private static readonly TimeSpan InteractTimeout = TimeSpan.FromMinutes(5); @@ -609,4 +610,5 @@ internal partial class EventsBaseCommand #endif return result; } -} \ No newline at end of file +} +*/ diff --git a/CompatBot/Commands/Explain.cs b/CompatBot/Commands/Explain.cs index dda0a83f..bcf7b67c 100644 --- a/CompatBot/Commands/Explain.cs +++ b/CompatBot/Commands/Explain.cs @@ -20,6 +20,7 @@ internal sealed class Explain { private const string TermListTitle = "Defined terms"; + /* [Command("show"), DefaultGroupCommand] public async Task Show(CommandContext ctx, [RemainingText, Description("Term to explain")] string term) { @@ -218,6 +219,7 @@ internal sealed class Explain else await ctx.ReactWithAsync(Config.Reactions.Failure).ConfigureAwait(false); } + */ [Command("list")] [Description("List all known terms that could be used for !explain command")] @@ -240,6 +242,7 @@ internal sealed class Explain } } + /* [Command("remove"), TextAlias("delete", "del", "erase", "obliterate"), RequiresBotModRole] [Description("Removes an explanation from the definition list")] internal sealed class Remove @@ -347,6 +350,7 @@ internal sealed class Explain } } } + */ [Command("error")] [Description("Provides additional information about Win32 and Linux system error")] @@ -455,6 +459,7 @@ internal sealed class Explain return false; } + /* private static async Task DumpLink(CommandContext ctx, string messageLink) { string? explanation = null; @@ -476,4 +481,5 @@ internal sealed class Explain await ctx.Channel.SendMessageAsync(new DiscordMessageBuilder().AddFile("explanation.txt", stream)).ConfigureAwait(false); } } -} \ No newline at end of file + */ +} diff --git a/CompatBot/Commands/ForcedNicknames.cs b/CompatBot/Commands/ForcedNicknames.cs index dee76404..aee72219 100644 --- a/CompatBot/Commands/ForcedNicknames.cs +++ b/CompatBot/Commands/ForcedNicknames.cs @@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore; namespace CompatBot.Commands; +/* [Command("rename")] [Description("Manage users who has forced nickname.")] internal sealed class ForcedNicknames @@ -257,4 +258,5 @@ internal sealed class ForcedNicknames } await ctx.SendAutosplitMessageAsync(table.ToString()).ConfigureAwait(false); } -} \ No newline at end of file +} +*/ diff --git a/CompatBot/Commands/Fortune.cs b/CompatBot/Commands/Fortune.cs index c510e091..02723d9a 100644 --- a/CompatBot/Commands/Fortune.cs +++ b/CompatBot/Commands/Fortune.cs @@ -7,15 +7,17 @@ using Microsoft.EntityFrameworkCore; namespace CompatBot.Commands; -[Command("fortune"), TextAlias("fortunes")] +//[Command("fortune"), TextAlias("fortunes")] [Description("Gives you a fortune once a day")] internal sealed class Fortune { private static readonly SemaphoreSlim ImportCheck = new(1, 1); + /* [Command("open"), TextAlias("show"), DefaultGroupCommand] public Task ShowFortune(CommandContext ctx) => ShowFortune(ctx.Message, ctx.User); + */ public static async Task ShowFortune(DiscordMessage message, DiscordUser user) { @@ -54,6 +56,7 @@ internal sealed class Fortune await message.Channel.SendMessageAsync(msgBuilder).ConfigureAwait(false); } + /* [Command("add"), RequiresBotModRole] [Description("Add a new fortune")] public async Task Add(CommandContext ctx, [RemainingText] string text) @@ -247,4 +250,5 @@ internal sealed class Fortune var count = await db.SaveChangesAsync(Config.Cts.Token).ConfigureAwait(false); await ctx.ReactWithAsync(Config.Reactions.Success, $"Removed {count} fortune{(count == 1 ? "" : "s")}", true).ConfigureAwait(false); } -} \ No newline at end of file + */ +} diff --git a/CompatBot/Commands/Invites.cs b/CompatBot/Commands/Invites.cs index dca53d89..1090e408 100644 --- a/CompatBot/Commands/Invites.cs +++ b/CompatBot/Commands/Invites.cs @@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore; namespace CompatBot.Commands; +/* [Command("invite"), TextAlias("invites"), RequiresBotModRole] [Description("Used to manage Discord invites whitelist")] internal sealed class Invites @@ -53,7 +54,7 @@ internal sealed class Invites if (!string.IsNullOrEmpty(item.InviteCode)) link = linkPrefix + item.InviteCode; //discord expands invite links even if they're inside the code block for some reason - table.Add(item.Id.ToString(), item.GuildId.ToString(), link /* + StringUtils.InvisibleSpacer*/, guildName.Sanitize()); + table.Add(item.Id.ToString(), item.GuildId.ToString(), link /* + StringUtils.InvisibleSpacer#1#, guildName.Sanitize()); } var result = new StringBuilder() .AppendLine("Whitelisted discord servers:") @@ -166,4 +167,5 @@ internal sealed class Invites await ctx.ReactWithAsync(Config.Reactions.Success, $"Invite{StringUtils.GetSuffix(ids.Length)} successfully removed!").ConfigureAwait(false); await List(ctx).ConfigureAwait(false); } -} \ No newline at end of file +} +*/ diff --git a/CompatBot/Commands/Ird.cs b/CompatBot/Commands/Ird.cs index 5389223e..4bdd7d61 100644 --- a/CompatBot/Commands/Ird.cs +++ b/CompatBot/Commands/Ird.cs @@ -3,6 +3,7 @@ using IrdLibraryClient; namespace CompatBot.Commands; +/* internal sealed class Ird { private static readonly IrdClient Client = new(); @@ -21,4 +22,5 @@ internal sealed class Ird var embed = result.AsEmbed(); await ctx.Channel.SendMessageAsync(embed: embed).ConfigureAwait(false); } -} \ No newline at end of file +} +*/ diff --git a/CompatBot/Commands/Misc.cs b/CompatBot/Commands/Misc.cs index 5e0c80dc..9e83168f 100644 --- a/CompatBot/Commands/Misc.cs +++ b/CompatBot/Commands/Misc.cs @@ -123,6 +123,7 @@ internal sealed partial class Misc [GeneratedRegex(@"(?\d+)?d(?\d+)(?:\+(?\d+))?")] private static partial Regex DiceNotationPattern(); + /* [Command("about"), Description("Bot information")] public async Task About(CommandContext ctx) { @@ -148,7 +149,7 @@ internal sealed partial class Misc ).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) @@ -157,7 +158,7 @@ internal sealed partial class Misc [Command("roll")] public Task Roll(CommandContext ctx, [RemainingText, Description("Dices to roll (i.e. 2d6+1 for two 6-sided dices with a bonus 1)")] string dices) => RollImpl(ctx.Message, dices); - + */ internal static async Task RollImpl(DiscordMessage message, int maxValue = 6) { @@ -231,6 +232,7 @@ internal sealed partial class Misc await message.Channel.SendMessageAsync(new DiscordMessageBuilder().WithContent(result).WithReply(message.Id)).ConfigureAwait(false); } + /* [Command("random"), TextAlias("rng")] //[Hidden, Cooldown(1, 3, CooldownBucketType.Channel)] [Description("Provides random stuff")] @@ -269,6 +271,7 @@ internal sealed partial class Misc break; } } + */ [Command("8ball")] //[Cooldown(20, 60, CooldownBucketType.Channel)] @@ -330,6 +333,7 @@ internal sealed partial class Misc } } + /* [Command("rate")] //[Cooldown(20, 60, CooldownBucketType.Channel)] [Description("Gives a ~~random~~ expert judgment on the matter at hand")] @@ -521,11 +525,14 @@ internal sealed partial class Misc msgBuilder.WithReply(ctx.Message.Id); await ch.SendMessageAsync(msgBuilder).ConfigureAwait(false); } + */ + /* [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] @@ -536,6 +543,7 @@ internal sealed partial class Misc return ctx.Channel.SendMessageAsync($"Similarity score is {result:0.######}"); } + /* [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) @@ -558,4 +566,5 @@ internal sealed partial class Misc else await ctx.ReactWithAsync(Config.Reactions.Failure, "Invalid product code").ConfigureAwait(false); } + */ } \ No newline at end of file diff --git a/CompatBot/Commands/Moderation.Audit.cs b/CompatBot/Commands/Moderation.Audit.cs index 2fbac224..7aeb3a95 100644 --- a/CompatBot/Commands/Moderation.Audit.cs +++ b/CompatBot/Commands/Moderation.Audit.cs @@ -7,12 +7,13 @@ namespace CompatBot.Commands; internal sealed partial class Moderation { - [Command("audit"), RequiresBotModRole] +// [Command("audit"), RequiresBotModRole] [Description("Commands to audit server things")] public sealed class Audit { public static readonly SemaphoreSlim CheckLock = new(1, 1); + /* [Command("spoofing"), TextAlias("impersonation"), RequiresDm] [Description("Checks every user on the server for name spoofing")] public Task Spoofing(CommandContext ctx) @@ -20,7 +21,9 @@ internal sealed partial class Moderation SpoofingCheck(ctx); return Task.CompletedTask; } + */ + /* [Command("members"), TextAlias("users"), RequiresDm] [Description("Dumps server member information, including usernames, nicknames, and roles")] public async Task Members(CommandContext ctx) @@ -179,7 +182,9 @@ internal sealed partial class Moderation await ctx.RemoveReactionAsync(Config.Reactions.PleaseWait).ConfigureAwait(false); } } + */ +/* #if DEBUG [Command("locales"), TextAlias("locale", "languages", "language", "lang", "loc")] public async Task UserLocales(CommandContext ctx) @@ -227,7 +232,9 @@ internal sealed partial class Moderation } } #endif +*/ + /* private static List GetMembers(DiscordClient client) { //owner -> white name @@ -309,5 +316,6 @@ internal sealed partial class Moderation await ctx.RemoveReactionAsync(Config.Reactions.PleaseWait).ConfigureAwait(false); } } + */ } -} \ No newline at end of file +} diff --git a/CompatBot/Commands/Moderation.cs b/CompatBot/Commands/Moderation.cs index 2127e172..248aaed2 100644 --- a/CompatBot/Commands/Moderation.cs +++ b/CompatBot/Commands/Moderation.cs @@ -4,6 +4,7 @@ namespace CompatBot.Commands; internal sealed partial class Moderation { + /* [Command("report"), RequiresWhitelistedRole] [Description("Adds specified message to the moderation queue")] public async Task Report(CommandContext ctx, [Description("Message ID from current channel to report")] ulong messageId, [RemainingText, Description("Optional report comment")] string? comment = null) @@ -76,7 +77,6 @@ internal sealed partial class Moderation } } - [Command("analyze")] public async Task Reanalyze(CommandContext ctx) { @@ -110,6 +110,7 @@ internal sealed partial class Moderation await ToggleBadUpdateAnnouncementAsync(msg).ConfigureAwait(false); await ctx.ReactWithAsync(Config.Reactions.Success).ConfigureAwait(false); } + */ public static async Task ToggleBadUpdateAnnouncementAsync(DiscordMessage? message) { @@ -149,6 +150,7 @@ internal sealed partial class Moderation await message.UpdateOrCreateMessageAsync(message.Channel, embed: result).ConfigureAwait(false); } + /* private static async Task ReportMessage(CommandContext ctx, string? comment, DiscordMessage msg) { if (msg.Reactions.Any(r => r.IsMe && r.Emoji == Config.Reactions.Moderated)) @@ -162,4 +164,5 @@ internal sealed partial class Moderation await msg.ReactWithAsync(Config.Reactions.Moderated).ConfigureAwait(false); await ctx.ReactWithAsync(Config.Reactions.Success, "Message reported").ConfigureAwait(false); } -} \ No newline at end of file + */ +} diff --git a/CompatBot/Commands/Pr.cs b/CompatBot/Commands/Pr.cs index d8cecaf1..8c7f42cf 100644 --- a/CompatBot/Commands/Pr.cs +++ b/CompatBot/Commands/Pr.cs @@ -6,13 +6,14 @@ using BuildStatus = Microsoft.TeamFoundation.Build.WebApi.BuildStatus; namespace CompatBot.Commands; -[Command("pr"), TriggersTyping] +//[Command("pr"), TriggersTyping] [Description("Commands to list opened pull requests information")] internal sealed class Pr { private static readonly GithubClient.Client GithubClient = new(Config.GithubToken); private static readonly CompatApiClient.Client CompatApiClient = new(); + /* [Command("search"), DefaultGroupCommand] public Task List(CommandContext ctx, [Description("Get information for specific PR number")] int pr) => LinkPrBuild(ctx.Client, ctx.Message, pr); @@ -101,6 +102,7 @@ internal sealed class Pr ).ConfigureAwait(false); } #endif +*/ public static async Task LinkPrBuild(DiscordClient client, DiscordMessage message, int pr, bool linkOld = false) { @@ -303,4 +305,4 @@ internal sealed class Pr await message.Channel.SendMessageAsync(embed: issueInfo.AsEmbed()).ConfigureAwait(false); } -} \ No newline at end of file +} diff --git a/CompatBot/Commands/Psn.Check.cs b/CompatBot/Commands/Psn.Check.cs index b50ec428..d4bd6374 100644 --- a/CompatBot/Commands/Psn.Check.cs +++ b/CompatBot/Commands/Psn.Check.cs @@ -17,6 +17,7 @@ internal sealed partial class Psn { private static string? latestFwVersion; + /* [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) @@ -159,6 +160,7 @@ 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"), TextAlias("fw")] //[Cooldown(1, 10, CooldownBucketType.Channel)] @@ -226,13 +228,15 @@ internal sealed partial class Psn if (e.User.Id != authorId) return; - await e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate).ConfigureAwait(false); + await e.Interaction.CreateResponseAsync(DiscordInteractionResponseType.DeferredMessageUpdate).ConfigureAwait(false); await e.Message.DeleteAsync().ConfigureAwait(false); var refMsg = await e.Channel.GetMessageAsync(refMsgId).ConfigureAwait(false); + /* var cne = client.GetCommandsNext(); var cmd = cne.FindCommand("psn check updates", out _); var context = cne.CreateContext(refMsg, Config.CommandPrefix, cmd, productCode); await cne.ExecuteCommandAsync(context).ConfigureAwait(false); + */ } catch (Exception ex) { @@ -240,4 +244,4 @@ internal sealed partial class Psn } } } -} \ No newline at end of file +} diff --git a/CompatBot/Commands/Psn.cs b/CompatBot/Commands/Psn.cs index 90241292..75609e71 100644 --- a/CompatBot/Commands/Psn.cs +++ b/CompatBot/Commands/Psn.cs @@ -11,6 +11,7 @@ internal sealed partial class Psn { private static readonly Client Client = new(); +/* [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) @@ -18,7 +19,7 @@ internal sealed partial class Psn productCode = productCode.ToUpperInvariant(); await using var db = new ThumbnailDb(); var item = db.Thumbnail.FirstOrDefault(t => t.ProductCode == productCode); - if (item == null) + if (item == null) await ctx.ReactWithAsync(Config.Reactions.Failure, $"Unknown product code {productCode}", true).ConfigureAwait(false); else { @@ -68,4 +69,5 @@ internal sealed partial class Psn else await ctx.ReactWithAsync(Config.Reactions.Failure, $"Product code {contentId} already exists", true).ConfigureAwait(false); } -} \ No newline at end of file +*/ +} diff --git a/CompatBot/Commands/Sudo.Bot.Configuration.cs b/CompatBot/Commands/Sudo.Bot.Configuration.cs index d3d34f5c..d2559eb1 100644 --- a/CompatBot/Commands/Sudo.Bot.Configuration.cs +++ b/CompatBot/Commands/Sudo.Bot.Configuration.cs @@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore; namespace CompatBot.Commands; +/* internal partial class Sudo { public sealed partial class Bot @@ -73,4 +74,5 @@ internal partial class Sudo } } } -} \ No newline at end of file +} +*/ diff --git a/CompatBot/Commands/Sudo.Bot.cs b/CompatBot/Commands/Sudo.Bot.cs index 430bd3b9..4d89c2a0 100644 --- a/CompatBot/Commands/Sudo.Bot.cs +++ b/CompatBot/Commands/Sudo.Bot.cs @@ -6,6 +6,7 @@ using NLog; namespace CompatBot.Commands; + internal partial class Sudo { private static readonly SemaphoreSlim LockObj = new(1, 1); @@ -90,7 +91,7 @@ internal partial class Sudo await using var db = new BotDb(); var status = await db.BotState.FirstOrDefaultAsync(s => s.Key == "bot-status-activity").ConfigureAwait(false); var txt = await db.BotState.FirstOrDefaultAsync(s => s.Key == "bot-status-text").ConfigureAwait(false); - if (Enum.TryParse(activity, true, out ActivityType activityType) + if (Enum.TryParse(activity, true, out DiscordActivityType activityType) && !string.IsNullOrEmpty(message)) { if (status == null) @@ -101,7 +102,7 @@ internal partial class Sudo await db.BotState.AddAsync(new() {Key = "bot-status-text", Value = message}).ConfigureAwait(false); else txt.Value = message; - await ctx.Client.UpdateStatusAsync(new(message, activityType), UserStatus.Online).ConfigureAwait(false); + await ctx.Client.UpdateStatusAsync(new(message, activityType), DiscordUserStatus.Online).ConfigureAwait(false); } else { @@ -248,4 +249,4 @@ internal partial class Sudo Environment.Exit(-1); } } -} \ No newline at end of file +} diff --git a/CompatBot/Commands/Sudo.Dotnet.cs b/CompatBot/Commands/Sudo.Dotnet.cs index a696214a..4836755c 100644 --- a/CompatBot/Commands/Sudo.Dotnet.cs +++ b/CompatBot/Commands/Sudo.Dotnet.cs @@ -4,6 +4,7 @@ using CompatBot.Database.Providers; namespace CompatBot.Commands; +/* internal partial class Sudo { [Command("dotnet")] @@ -95,4 +96,5 @@ internal partial class Sudo return (true, stdout); } } -} \ No newline at end of file +} +*/ diff --git a/CompatBot/Commands/Sudo.Fix.cs b/CompatBot/Commands/Sudo.Fix.cs index a27d118f..2f1a1c46 100644 --- a/CompatBot/Commands/Sudo.Fix.cs +++ b/CompatBot/Commands/Sudo.Fix.cs @@ -5,6 +5,7 @@ using CompatBot.Database.Providers; namespace CompatBot.Commands; +/* internal sealed partial class Sudo { // '2018-06-09 08:20:44.968000 - ' @@ -167,4 +168,5 @@ internal sealed partial class Sudo return msg; } } -} \ No newline at end of file +} +*/ diff --git a/CompatBot/Commands/Sudo.Mod.cs b/CompatBot/Commands/Sudo.Mod.cs index 478c0a49..6050a1a8 100644 --- a/CompatBot/Commands/Sudo.Mod.cs +++ b/CompatBot/Commands/Sudo.Mod.cs @@ -2,6 +2,7 @@ namespace CompatBot.Commands; +/* internal partial class Sudo { [Command("mod")] @@ -90,4 +91,5 @@ internal partial class Sudo await ctx.ReactWithAsync(Config.Reactions.Failure, $"{sudoer.Mention} is not even a moderator!").ConfigureAwait(false); } } -} \ No newline at end of file +} +*/ diff --git a/CompatBot/Commands/Sudo.cs b/CompatBot/Commands/Sudo.cs index b1b95ac5..7e808a60 100644 --- a/CompatBot/Commands/Sudo.cs +++ b/CompatBot/Commands/Sudo.cs @@ -14,6 +14,7 @@ using SharpCompress.Writers.Zip; namespace CompatBot.Commands; +/* [Command("sudo"), RequiresBotSudoerRole] [Description("Used to manage bot moderators and sudoers")] internal sealed partial class Sudo @@ -250,4 +251,5 @@ internal sealed partial class Sudo await msg.UpdateOrCreateMessageAsync(ctx.Channel, "Operation cancelled.").ConfigureAwait(false); } } -} \ No newline at end of file +} +*/ diff --git a/CompatBot/Commands/Syscall.cs b/CompatBot/Commands/Syscall.cs index c1ee0979..e93e51fd 100644 --- a/CompatBot/Commands/Syscall.cs +++ b/CompatBot/Commands/Syscall.cs @@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore; namespace CompatBot.Commands; +/* [Command("syscall"), TextAlias("syscalls", "cell", "sce", "scecall", "scecalls"), LimitedToSpamChannel] [Description("Provides information about syscalls used by games")] internal sealed class Syscall @@ -165,4 +166,5 @@ internal sealed class Syscall else await ctx.Channel.SendMessageAsync($"No information available for `{title}`").ConfigureAwait(false); } -} \ No newline at end of file +} +*/ diff --git a/CompatBot/Commands/Vision.cs b/CompatBot/Commands/Vision.cs index ae8b85b4..a34689f4 100644 --- a/CompatBot/Commands/Vision.cs +++ b/CompatBot/Commands/Vision.cs @@ -4,6 +4,7 @@ using System.Net.Http; using ColorThiefDotNet; using CompatBot.EventHandlers; using CompatBot.Utils.Extensions; +using DSharpPlus.Commands.Processors.TextCommands; using Microsoft.Azure.CognitiveServices.Vision.ComputerVision; using Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models; using SixLabors.Fonts; @@ -58,6 +59,7 @@ internal sealed class Vision ["strawberry"] = ["🍓",], }; + /* [Command("describe"), TriggersTyping] [Description("Generates an image description from the attached image, or from the url")] public Task Describe(CommandContext ctx, [RemainingText] string? imageUrl = null) @@ -66,7 +68,9 @@ internal sealed class Vision return Tag(ctx, imageUrl[3..].TrimStart()); return Tag(ctx, imageUrl); } + */ + /* [Command("tag"), TriggersTyping] [Description("Tags recognized objects in the image")] public async Task Tag(CommandContext ctx, string? imageUrl = null) @@ -226,7 +230,7 @@ internal sealed class Vision WrapTextWidth = r.W - 10, #endif }; - var textDrawingOptions = new DrawingOptions {GraphicsOptions = fgGop/*, TextOptions = textOptions*/}; + var textDrawingOptions = new DrawingOptions {GraphicsOptions = fgGop/*, TextOptions = textOptions#1#}; //var brush = Brushes.Solid(Color.Black); //var pen = Pens.Solid(color, 2); var textBox = TextMeasurer.MeasureBounds(label, textOptions); @@ -346,6 +350,7 @@ internal sealed class Vision await ctx.Channel.SendMessageAsync("Can't do anything with this image").ConfigureAwait(false); } } + */ internal static IEnumerable GetImagesFromEmbeds(DiscordMessage msg) { @@ -409,7 +414,10 @@ internal sealed class Vision private static async Task GetImageUrlAsync(CommandContext ctx, string? imageUrl) { - var reactMsg = ctx.Message; + if (ctx is not TextCommandContext tctx) + return null; + + var reactMsg = tctx.Message; if (GetImageAttachments(reactMsg).FirstOrDefault() is DiscordAttachment attachment) imageUrl = attachment.Url; imageUrl = imageUrl?.Trim() ?? ""; @@ -427,10 +435,10 @@ internal sealed class Vision || str.StartsWith("^")) && ctx.Channel.PermissionsFor( await ctx.Client.GetMemberAsync(ctx.Guild, ctx.Client.CurrentUser).ConfigureAwait(false) - ).HasPermission(Permissions.ReadMessageHistory)) + ).HasPermission(DiscordPermission.ReadMessageHistory)) try { - var previousMessages = (await ctx.Channel.GetMessagesBeforeCachedAsync(ctx.Message.Id, 10).ConfigureAwait(false))!; + var previousMessages = (await ctx.Channel.GetMessagesBeforeCachedAsync(tctx.Message.Id, 10).ConfigureAwait(false))!; imageUrl = ( from m in previousMessages where m.Attachments?.Count > 0 @@ -457,4 +465,4 @@ internal sealed class Vision } return imageUrl; } -} \ No newline at end of file +} diff --git a/CompatBot/Commands/Warnings.ListGroup.cs b/CompatBot/Commands/Warnings.ListGroup.cs index 514cb4cf..c093a3c7 100644 --- a/CompatBot/Commands/Warnings.ListGroup.cs +++ b/CompatBot/Commands/Warnings.ListGroup.cs @@ -5,6 +5,7 @@ using DSharpPlus.Commands.Converters; namespace CompatBot.Commands; +/* internal sealed partial class Warnings { [Command("list"), TextAlias("show")] @@ -207,4 +208,5 @@ internal sealed partial class Warnings return false; } } -} \ No newline at end of file +} +*/ diff --git a/CompatBot/Commands/Warnings.cs b/CompatBot/Commands/Warnings.cs index 1580c26c..e507fde1 100644 --- a/CompatBot/Commands/Warnings.cs +++ b/CompatBot/Commands/Warnings.cs @@ -4,10 +4,11 @@ using Microsoft.EntityFrameworkCore; namespace CompatBot.Commands; -[Command("warn")] +//[Command("warn")] [Description("Command used to manage warnings")] internal sealed partial class Warnings { + /* [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) @@ -170,9 +171,11 @@ internal sealed partial class Warnings reason = await Sudo.Fix.FixChannelMentionAsync(ctx, reason).ConfigureAwait(false); return await AddAsync(ctx.Client, ctx.Message, userId, userName, issuer, reason, fullReason); } + */ internal static async Task AddAsync(DiscordClient client, DiscordMessage message, ulong userId, string userName, DiscordUser issuer, string? reason, string? fullReason = null) { + /* if (string.IsNullOrEmpty(reason)) { var interact = client.GetInteractivity(); @@ -191,6 +194,7 @@ internal sealed partial class Warnings await msg.DeleteAsync().ConfigureAwait(false); reason = response.Result.Content; } + */ try { await using var db = new BotDb(); @@ -327,4 +331,4 @@ internal sealed partial class Warnings Config.Log.Warn(e); } } -} \ No newline at end of file +} diff --git a/CompatBot/Config.cs b/CompatBot/Config.cs index e4d1d27a..711c4f4d 100644 --- a/CompatBot/Config.cs +++ b/CompatBot/Config.cs @@ -276,7 +276,8 @@ internal static class Config }; watchdogTarget.Parameters.AddRange([new MethodCallParameter("${level}"), new("${message}")]); #if DEBUG - loggingConfig.AddRule(LogLevel.Trace, LogLevel.Fatal, consoleTarget, "default"); // only echo messages from default logger to the console + loggingConfig.AddRule(LogLevel.Error, LogLevel.Fatal, consoleTarget); + loggingConfig.AddRule(LogLevel.Trace, LogLevel.Fatal, consoleTarget, "default"); // echo all messages from default logger to the console #else loggingConfig.AddRule(LogLevel.Info, LogLevel.Fatal, consoleTarget, "default"); #endif @@ -320,7 +321,7 @@ internal static class Config telemetryConfig.TelemetryInitializers.Add(new HttpDependenciesParsingTelemetryInitializer()); DependencyTrackingTelemetryModule.Initialize(telemetryConfig); PerformanceCollectorModule.Initialize(telemetryConfig); - return telemetryClient = new TelemetryClient(telemetryConfig); + return telemetryClient = new(telemetryConfig); } } diff --git a/CompatBot/EventHandlers/Starbucks.cs b/CompatBot/EventHandlers/Starbucks.cs index d986e8ca..e324ab63 100644 --- a/CompatBot/EventHandlers/Starbucks.cs +++ b/CompatBot/EventHandlers/Starbucks.cs @@ -196,7 +196,6 @@ internal static class Starbucks catch { } } - private static async Task CheckGameFansAsync(DiscordClient client, DiscordChannel channel, DiscordMessage message) { var bot = await client.GetMemberAsync(channel.Guild, client.CurrentUser).ConfigureAwait(false); diff --git a/CompatBot/Program.cs b/CompatBot/Program.cs index 2b376be9..5a5b2e76 100644 --- a/CompatBot/Program.cs +++ b/CompatBot/Program.cs @@ -8,6 +8,7 @@ using CompatBot.Database; using CompatBot.Database.Providers; using CompatBot.EventHandlers; using CompatBot.Utils.Extensions; +using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Commands.Processors.TextCommands; using DSharpPlus.Commands.Processors.TextCommands.Parsing; using Microsoft.EntityFrameworkCore; @@ -143,9 +144,16 @@ internal static class Program Config.AutoRemoveCommandPrefix ).ResolvePrefixAsync, }); + var appCommandProcessor = new SlashCommandProcessor(new() + { + //NamingPolicy = new CamelCaseNamingPolicy(), + RegisterCommands = true, + }); textCommandProcessor.AddConverter(); extension.AddProcessor(textCommandProcessor); - extension.AddCommands(Assembly.GetAssembly(typeof(CompatList))!); + extension.AddProcessor(appCommandProcessor); + extension.AddCommands(Assembly.GetExecutingAssembly()); + extension.AddParameterChecks(Assembly.GetExecutingAssembly()); /* if (!string.IsNullOrEmpty(Config.AzureComputerVisionKey)) extension.AddCommands(); @@ -154,7 +162,7 @@ internal static class Program //extension.CommandErrored += UnknownCommandHandler.OnError; }, new() { - RegisterDefaultCommandProcessors = true, + RegisterDefaultCommandProcessors = false, //UseDefaultCommandErrorHandler = false, #if DEBUG DebugGuildId = Config.BotGuildId,