comment most of the broken stuff, so the project can be compiled

This commit is contained in:
13xforever
2025-03-12 10:24:46 +05:00
parent 06b375b972
commit 54e4f3a721
31 changed files with 145 additions and 91 deletions

View File

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

View File

@@ -5,6 +5,7 @@ using Microsoft.Extensions.Caching.Memory;
namespace CompatBot.Commands;
/*
internal class BaseCommandModuleCustom : BaseCommandModule
{
private DateTimeOffset executionStart;
@@ -68,3 +69,4 @@ internal class BaseCommandModuleCustom : BaseCommandModule
private static bool TriggersTyping(CommandContext ctx)
=> ctx.Command?.CustomAttributes.OfType<TriggersTyping>().FirstOrDefault() is TriggersTyping a && a.ExecuteCheck(ctx);
}
*/

View File

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

View File

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

View File

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

View File

@@ -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
@@ -54,3 +55,4 @@ internal sealed class Events: EventsBaseCommand
public Task Countdown(CommandContext ctx, string? eventName = null)
=> NearestEvent(ctx, eventName);
}
*/

View File

@@ -8,6 +8,7 @@ using Microsoft.EntityFrameworkCore;
namespace CompatBot.Commands;
/*
internal partial class EventsBaseCommand
{
private static readonly TimeSpan InteractTimeout = TimeSpan.FromMinutes(5);
@@ -610,3 +611,4 @@ internal partial class EventsBaseCommand
return result;
}
}
*/

View File

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

View File

@@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore;
namespace CompatBot.Commands;
/*
[Command("rename")]
[Description("Manage users who has forced nickname.")]
internal sealed class ForcedNicknames
@@ -258,3 +259,4 @@ internal sealed class ForcedNicknames
await ctx.SendAutosplitMessageAsync(table.ToString()).ConfigureAwait(false);
}
}
*/

View File

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

View File

@@ -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:")
@@ -167,3 +168,4 @@ internal sealed class Invites
await List(ctx).ConfigureAwait(false);
}
}
*/

View File

@@ -3,6 +3,7 @@ using IrdLibraryClient;
namespace CompatBot.Commands;
/*
internal sealed class Ird
{
private static readonly IrdClient Client = new();
@@ -22,3 +23,4 @@ internal sealed class Ird
await ctx.Channel.SendMessageAsync(embed: embed).ConfigureAwait(false);
}
}
*/

View File

@@ -123,6 +123,7 @@ internal sealed partial class Misc
[GeneratedRegex(@"(?<num>\d+)?d(?<face>\d+)(?:\+(?<mod>\d+))?")]
private static partial Regex DiceNotationPattern();
/*
[Command("about"), Description("Bot information")]
public async Task About(CommandContext ctx)
{
@@ -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);
}
*/
}

View File

@@ -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<DiscordMember> GetMembers(DiscordClient client)
{
//owner -> white name
@@ -309,5 +316,6 @@ internal sealed partial class Moderation
await ctx.RemoveReactionAsync(Config.Reactions.PleaseWait).ConfigureAwait(false);
}
}
*/
}
}

View File

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

View File

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

View File

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

View File

@@ -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)
@@ -68,4 +69,5 @@ internal sealed partial class Psn
else
await ctx.ReactWithAsync(Config.Reactions.Failure, $"Product code {contentId} already exists", true).ConfigureAwait(false);
}
*/
}

View File

@@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore;
namespace CompatBot.Commands;
/*
internal partial class Sudo
{
public sealed partial class Bot
@@ -74,3 +75,4 @@ internal partial class Sudo
}
}
}
*/

View File

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

View File

@@ -4,6 +4,7 @@ using CompatBot.Database.Providers;
namespace CompatBot.Commands;
/*
internal partial class Sudo
{
[Command("dotnet")]
@@ -96,3 +97,4 @@ internal partial class Sudo
}
}
}
*/

View File

@@ -5,6 +5,7 @@ using CompatBot.Database.Providers;
namespace CompatBot.Commands;
/*
internal sealed partial class Sudo
{
// '2018-06-09 08:20:44.968000 - '
@@ -168,3 +169,4 @@ internal sealed partial class Sudo
}
}
}
*/

View File

@@ -2,6 +2,7 @@
namespace CompatBot.Commands;
/*
internal partial class Sudo
{
[Command("mod")]
@@ -91,3 +92,4 @@ internal partial class Sudo
}
}
}
*/

View File

@@ -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
@@ -251,3 +252,4 @@ internal sealed partial class Sudo
}
}
}
*/

View File

@@ -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
@@ -166,3 +167,4 @@ internal sealed class Syscall
await ctx.Channel.SendMessageAsync($"No information available for `{title}`").ConfigureAwait(false);
}
}
*/

View File

@@ -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<string> GetImagesFromEmbeds(DiscordMessage msg)
{
@@ -409,7 +414,10 @@ internal sealed class Vision
private static async Task<string?> 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

View File

@@ -5,6 +5,7 @@ using DSharpPlus.Commands.Converters;
namespace CompatBot.Commands;
/*
internal sealed partial class Warnings
{
[Command("list"), TextAlias("show")]
@@ -208,3 +209,4 @@ internal sealed partial class Warnings
}
}
}
*/

View File

@@ -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<bool> 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();

View File

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

View File

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

View File

@@ -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<TextOnlyDiscordChannelConverter>();
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<Vision>();
@@ -154,7 +162,7 @@ internal static class Program
//extension.CommandErrored += UnknownCommandHandler.OnError;
}, new()
{
RegisterDefaultCommandProcessors = true,
RegisterDefaultCommandProcessors = false,
//UseDefaultCommandErrorHandler = false,
#if DEBUG
DebugGuildId = Config.BotGuildId,