From 1b2fc0f3b94ffa8b98e348cac56725f491ce0798 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Tue, 11 Feb 2025 10:24:29 +0100 Subject: [PATCH] fix: fix dcs changes --- ProjectMakoto/Commands/DebugCommands.cs | 4 +-- .../Commands/Moderation/CustomEmbedCommand.cs | 10 +++---- ProjectMakoto/Events/EmbedMessagesEvents.cs | 4 +-- .../Util/Extensions/DiscordExtensions.cs | 30 +++++++++---------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/ProjectMakoto/Commands/DebugCommands.cs b/ProjectMakoto/Commands/DebugCommands.cs index 8cfe7b2b..9fc56a02 100644 --- a/ProjectMakoto/Commands/DebugCommands.cs +++ b/ProjectMakoto/Commands/DebugCommands.cs @@ -1,4 +1,4 @@ -// Project Makoto +// Project Makoto // Copyright (C) 2024 Fortunevale // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -180,7 +180,7 @@ public sealed partial class DebugCommands : ApplicationCommandsModule } } - [SlashCommand("developertools", "Developer Tools used to manage Makoto.", dmPermission: false, defaultMemberPermissions: (long)Permissions.None)] + [SlashCommand("developertools", "Developer Tools used to manage Makoto.", defaultMemberPermissions: (long)Permissions.None, allowedContexts: [InteractionContextType.Guild])] [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0075:Simplify conditional expression", Justification = "")] public async Task DevTools(InteractionContext ctx, [Autocomplete(typeof(MaintainerAutoComplete))][Option("command", "The command to run.", true)] string command, diff --git a/ProjectMakoto/Commands/Moderation/CustomEmbedCommand.cs b/ProjectMakoto/Commands/Moderation/CustomEmbedCommand.cs index 8f9eb92f..213e7b24 100644 --- a/ProjectMakoto/Commands/Moderation/CustomEmbedCommand.cs +++ b/ProjectMakoto/Commands/Moderation/CustomEmbedCommand.cs @@ -1,4 +1,4 @@ -// Project Makoto +// Project Makoto // Copyright (C) 2024 Fortunevale // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -225,7 +225,7 @@ internal sealed class CustomEmbedCommand : BaseCommand var asset = await (await ctx.Client.GetChannelAsync(ctx.Bot.status.LoadedConfig.Channels.OtherAssets)).SendMessageAsync(new DiscordMessageBuilder().WithContent($"{ctx.User.Mention} `{ctx.User.GetUsernameWithIdentifier()} ({ctx.User.Id})`").WithFile($"{Guid.NewGuid()}.png", stream.stream)); - GeneratedEmbed.Author.IconUrl = asset.Attachments[0].Url; + GeneratedEmbed.Author.IconUrl = asset.Attachments[0].Url.ToString(); continue; } else if (Menu2.GetCustomId() == SetByUser.CustomId) @@ -320,7 +320,7 @@ internal sealed class CustomEmbedCommand : BaseCommand var asset = await (await ctx.Client.GetChannelAsync(ctx.Bot.status.LoadedConfig.Channels.OtherAssets)).SendMessageAsync(new DiscordMessageBuilder().WithContent($"{ctx.User.Mention} `{ctx.User.GetUsernameWithIdentifier()} ({ctx.User.Id})`").WithFile($"{Guid.NewGuid()}.png", stream.stream)); - GeneratedEmbed.Thumbnail.Url = asset.Attachments[0].Url; + GeneratedEmbed.Thumbnail.Url = asset.Attachments[0].Url.ToString(); continue; } else if (Menu1.GetCustomId() == SetDescription.CustomId) @@ -384,7 +384,7 @@ internal sealed class CustomEmbedCommand : BaseCommand var asset = await (await ctx.Client.GetChannelAsync(ctx.Bot.status.LoadedConfig.Channels.OtherAssets)).SendMessageAsync(new DiscordMessageBuilder().WithContent($"{ctx.User.Mention} `{ctx.User.GetUsernameWithIdentifier()} ({ctx.User.Id})`").WithFile($"{Guid.NewGuid()}.png", stream.stream)); - GeneratedEmbed.ImageUrl = asset.Attachments[0].Url; + GeneratedEmbed.ImageUrl = asset.Attachments[0].Url.ToString(); continue; } else if (Menu1.GetCustomId() == SetColor.CustomId) @@ -499,7 +499,7 @@ internal sealed class CustomEmbedCommand : BaseCommand var asset = await (await ctx.Client.GetChannelAsync(ctx.Bot.status.LoadedConfig.Channels.OtherAssets)).SendMessageAsync(new DiscordMessageBuilder().WithContent($"{ctx.User.Mention} `{ctx.User.GetUsernameWithIdentifier()} ({ctx.User.Id})`").WithFile($"{Guid.NewGuid()}.png", stream.stream)); - GeneratedEmbed.Footer.IconUrl = asset.Attachments[0].Url; + GeneratedEmbed.Footer.IconUrl = asset.Attachments[0].Url.ToString(); continue; } else if (Menu2.GetCustomId() == SetByUser.CustomId) diff --git a/ProjectMakoto/Events/EmbedMessagesEvents.cs b/ProjectMakoto/Events/EmbedMessagesEvents.cs index a273941d..fc8aadc2 100644 --- a/ProjectMakoto/Events/EmbedMessagesEvents.cs +++ b/ProjectMakoto/Events/EmbedMessagesEvents.cs @@ -1,4 +1,4 @@ -// Project Makoto +// Project Makoto // Copyright (C) 2024 Fortunevale // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -63,7 +63,7 @@ internal sealed class EmbedMessagesEvents(Bot bot) : RequiresTranslation(bot) ImageUrl = (message.Attachments?.Count > 0 && (message.Attachments[0].Filename.EndsWith(".png") || message.Attachments[0].Filename.EndsWith(".jpeg") || message.Attachments[0].Filename.EndsWith(".jpg") - || message.Attachments[0].Filename.EndsWith(".gif")) ? message.Attachments[0].Url : ""), + || message.Attachments[0].Filename.EndsWith(".gif")) ? message.Attachments[0].Url.ToString() : ""), Timestamp = message.Timestamp, }).AddComponents(JumpToMessage, Delete)); } diff --git a/ProjectMakoto/Util/Extensions/DiscordExtensions.cs b/ProjectMakoto/Util/Extensions/DiscordExtensions.cs index 64414102..ebf4887e 100644 --- a/ProjectMakoto/Util/Extensions/DiscordExtensions.cs +++ b/ProjectMakoto/Util/Extensions/DiscordExtensions.cs @@ -1,4 +1,4 @@ -// Project Makoto +// Project Makoto // Copyright (C) 2024 Fortunevale // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -159,23 +159,23 @@ public static class DiscordExtensions }))}" + $"{string.Join("", msg.Attachments?.Select(x => { - var tempUrl = x.Url.TruncateAt(true, '?'); + var tempUrl = x.Url.ToString().TruncateAt(true, '?'); var type = string.Empty; var alt = x.Description; - if (x.Url.EndsWith(".jpg", StringComparison.InvariantCultureIgnoreCase) || - x.Url.EndsWith(".jpeg", StringComparison.InvariantCultureIgnoreCase) || - x.Url.EndsWith(".png", StringComparison.InvariantCultureIgnoreCase) || - x.Url.EndsWith(".webp", StringComparison.InvariantCultureIgnoreCase) || - x.Url.EndsWith(".gifv", StringComparison.InvariantCultureIgnoreCase) || - x.Url.EndsWith(".gif", StringComparison.InvariantCultureIgnoreCase)) + if (x.Url.ToString().EndsWith(".jpg", StringComparison.InvariantCultureIgnoreCase) || + x.Url.ToString().EndsWith(".jpeg", StringComparison.InvariantCultureIgnoreCase) || + x.Url.ToString().EndsWith(".png", StringComparison.InvariantCultureIgnoreCase) || + x.Url.ToString().EndsWith(".webp", StringComparison.InvariantCultureIgnoreCase) || + x.Url.ToString().EndsWith(".gifv", StringComparison.InvariantCultureIgnoreCase) || + x.Url.ToString().EndsWith(".gif", StringComparison.InvariantCultureIgnoreCase)) type = "image"; - else if (x.Url.EndsWith(".webm", StringComparison.InvariantCultureIgnoreCase) || - x.Url.EndsWith(".mp4", StringComparison.InvariantCultureIgnoreCase)) + else if (x.Url.ToString().EndsWith(".webm", StringComparison.InvariantCultureIgnoreCase) || + x.Url.ToString().EndsWith(".mp4", StringComparison.InvariantCultureIgnoreCase)) type = "video"; - else if (x.Url.EndsWith(".wav", StringComparison.InvariantCultureIgnoreCase) || - x.Url.EndsWith(".ogg", StringComparison.InvariantCultureIgnoreCase) || - x.Url.EndsWith(".mp3", StringComparison.InvariantCultureIgnoreCase)) + else if (x.Url.ToString().EndsWith(".wav", StringComparison.InvariantCultureIgnoreCase) || + x.Url.ToString().EndsWith(".ogg", StringComparison.InvariantCultureIgnoreCase) || + x.Url.ToString().EndsWith(".mp3", StringComparison.InvariantCultureIgnoreCase)) type = "audio"; else { @@ -551,10 +551,10 @@ public static class DiscordExtensions => DigitsToEmotes(i.ToString()); public static string ToTimestamp(this DateTime dateTime, TimestampFormat format = TimestampFormat.RelativeTime) - => Formatter.Timestamp(dateTime, format); + => dateTime.Timestamp(format); public static string ToTimestamp(this DateTimeOffset dateTime, TimestampFormat format = TimestampFormat.RelativeTime) - => Formatter.Timestamp(dateTime, format); + => dateTime.Timestamp(format); public static string GetCommandMention(this DiscordClient client, Bot bot, string command) => (bot.status.LoadedConfig.IsDev ?