diff --git a/CHANGELOG.md b/CHANGELOG.md index 15b86e7..04c2e3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.6.0] - 2023-07-24 + +### Added + +- Added optional staff remarks to suggestion embeds. +- Staff can now remove suggestions. + +### Changed + +- `/suggestion view` now uses the same search logic as `/suggestion setstatus`. +- Suggestion updates are now sent to the author. + ## [1.5.1] - 2023-07-24 ### Added @@ -92,6 +104,7 @@ implemented, accepted, or rejected. - Initial release. +[1.6.0]: https://github.com/BrackeysBot/SuggestionBot/releases/tag/v1.6.0 [1.5.1]: https://github.com/BrackeysBot/SuggestionBot/releases/tag/v1.5.1 [1.5.0]: https://github.com/BrackeysBot/SuggestionBot/releases/tag/v1.5.0 [1.4.0]: https://github.com/BrackeysBot/SuggestionBot/releases/tag/v1.4.0 diff --git a/SuggestionBot/AutocompleteProviders/SuggestionAutocompleteProvider.cs b/SuggestionBot/AutocompleteProviders/SuggestionAutocompleteProvider.cs index 7ee27e5..c24eae2 100644 --- a/SuggestionBot/AutocompleteProviders/SuggestionAutocompleteProvider.cs +++ b/SuggestionBot/AutocompleteProviders/SuggestionAutocompleteProvider.cs @@ -35,6 +35,11 @@ public Task> Provider(AutocompleteContext for (var index = 0; index < count; index++) { Suggestion suggestion = suggestions[index]; + if (suggestion.Status == SuggestionStatus.Removed) + { + continue; + } + DiscordUser author = suggestionService.GetAuthor(suggestion); string[] contentWords = suggestion.Content.Split(); diff --git a/SuggestionBot/Commands/SuggestionCommand.Remove.cs b/SuggestionBot/Commands/SuggestionCommand.Remove.cs new file mode 100644 index 0000000..bdfc40e --- /dev/null +++ b/SuggestionBot/Commands/SuggestionCommand.Remove.cs @@ -0,0 +1,46 @@ +using DSharpPlus.Entities; +using DSharpPlus.SlashCommands; +using SuggestionBot.AutocompleteProviders; +using SuggestionBot.Data; +using X10D.DSharpPlus; + +namespace SuggestionBot.Commands; + +internal sealed partial class SuggestionCommand +{ + [SlashCommand("remove", "Remove a suggestion.", false)] + public async Task RemoveAsync(InteractionContext context, + [Option("suggestion", "The suggestion whose status to change.")] + [Autocomplete(typeof(SuggestionAutocompleteProvider))] + string query, + [Option("remarks", "Additional remarks about the suggestion.")] + string? remarks = null) + { + var response = new DiscordInteractionResponseBuilder(); + + if (!TryGetSuggestion(context.Guild, query, out Suggestion? suggestion)) + { + response.AsEphemeral(); + response.AddEmbed(CreateNotFoundEmbed(query)); + await context.CreateResponseAsync(ResponseType, response).ConfigureAwait(false); + return; + } + + var embed = new DiscordEmbedBuilder(); + if (_suggestionService.SetStatus(suggestion, SuggestionStatus.Removed, context.Member, remarks)) + { + embed.WithColor(DiscordColor.Red); + embed.WithTitle("Suggestion Removed"); + embed.WithDescription($"The suggestion with the ID {suggestion.Id} has been REMOVED."); + if (!string.IsNullOrWhiteSpace(remarks)) + { + embed.AddField("Staff Remarks", remarks); + } + + await _mailmanService.SendSuggestionAsync(suggestion).ConfigureAwait(false); + } + + response.AddEmbed(embed); + await context.CreateResponseAsync(ResponseType, response).ConfigureAwait(false); + } +} diff --git a/SuggestionBot/Commands/SuggestionCommand.SetStatus.cs b/SuggestionBot/Commands/SuggestionCommand.SetStatus.cs index ce3d105..679697a 100644 --- a/SuggestionBot/Commands/SuggestionCommand.SetStatus.cs +++ b/SuggestionBot/Commands/SuggestionCommand.SetStatus.cs @@ -15,11 +15,14 @@ public async Task SetStatusAsync(InteractionContext context, [Autocomplete(typeof(SuggestionAutocompleteProvider))] string query, [Option("status", "The new status of the suggestion.")] - SuggestionStatus status) + SuggestionStatus status, + [Option("remarks", "Additional remarks about the suggestion.")] + string? remarks = null) { var response = new DiscordInteractionResponseBuilder(); - if (!TryGetSuggestion(context.Guild, query, out Suggestion? suggestion)) + if (!TryGetSuggestion(context.Guild, query, out Suggestion? suggestion) || + suggestion.Status == SuggestionStatus.Removed) { response.AsEphemeral(); response.AddEmbed(CreateNotFoundEmbed(query)); @@ -32,11 +35,17 @@ public async Task SetStatusAsync(InteractionContext context, string humanizedStatus = status.Humanize(LetterCasing.AllCaps); - if (_suggestionService.SetStatus(suggestion, status, context.Member)) + if (_suggestionService.SetStatus(suggestion, status, context.Member, remarks)) { embed.WithColor(DiscordColor.Orange); embed.WithTitle("Suggestion Status Changed"); embed.WithDescription($"The suggestion with the ID {suggestion.Id} has been marked as {humanizedStatus}."); + if (!string.IsNullOrWhiteSpace(remarks)) + { + embed.AddField("Staff Remarks", remarks); + } + + await _mailmanService.SendSuggestionAsync(suggestion).ConfigureAwait(false); } else { diff --git a/SuggestionBot/Commands/SuggestionCommand.View.cs b/SuggestionBot/Commands/SuggestionCommand.View.cs index ad854ea..a926dd9 100644 --- a/SuggestionBot/Commands/SuggestionCommand.View.cs +++ b/SuggestionBot/Commands/SuggestionCommand.View.cs @@ -13,29 +13,17 @@ public async Task ViewAsync(InteractionContext context, [Autocomplete(typeof(SuggestionAutocompleteProvider))] string query) { - Suggestion? suggestion = null; - - ulong guildId = context.Guild.Id; - if (ulong.TryParse(query, out ulong messageId) && - _suggestionService.TryGetSuggestion(guildId, messageId, out suggestion)) - { - } - else if (long.TryParse(query, out long id) && _suggestionService.TryGetSuggestion(guildId, id, out suggestion)) - { - } - - var builder = new DiscordInteractionResponseBuilder(); - - if (suggestion is null) + var response = new DiscordInteractionResponseBuilder(); + if (!TryGetSuggestion(context.Guild, query, out Suggestion? suggestion)) { - builder.WithContent($"The suggestion with ID {query} does not exist."); - builder.AsEphemeral(); - await context.CreateResponseAsync(ResponseType, builder).ConfigureAwait(false); + response.AsEphemeral(); + response.AddEmbed(CreateNotFoundEmbed(query)); + await context.CreateResponseAsync(ResponseType, response).ConfigureAwait(false); return; } DiscordEmbed embed = _suggestionService.CreatePrivateEmbed(suggestion); - builder.AddEmbed(embed); - await context.CreateResponseAsync(ResponseType, builder).ConfigureAwait(false); + response.AddEmbed(embed); + await context.CreateResponseAsync(ResponseType, response).ConfigureAwait(false); } } diff --git a/SuggestionBot/Commands/SuggestionCommand.cs b/SuggestionBot/Commands/SuggestionCommand.cs index ade0b65..ade2ab6 100644 --- a/SuggestionBot/Commands/SuggestionCommand.cs +++ b/SuggestionBot/Commands/SuggestionCommand.cs @@ -16,16 +16,21 @@ internal sealed partial class SuggestionCommand : ApplicationCommandModule private readonly SuggestionService _suggestionService; private readonly UserBlockingService _userBlockingService; + private readonly MailmanService _mailmanService; /// /// Initializes a new instance of the class. /// /// The . /// The . - public SuggestionCommand(SuggestionService suggestionService, UserBlockingService userBlockingService) + /// The . + public SuggestionCommand(SuggestionService suggestionService, + UserBlockingService userBlockingService, + MailmanService mailmanService) { _suggestionService = suggestionService; _userBlockingService = userBlockingService; + _mailmanService = mailmanService; } private static DiscordEmbed CreateNotFoundEmbed(string query) diff --git a/SuggestionBot/Configuration/GuildConfiguration.cs b/SuggestionBot/Configuration/GuildConfiguration.cs index 4d3a852..296edb0 100644 --- a/SuggestionBot/Configuration/GuildConfiguration.cs +++ b/SuggestionBot/Configuration/GuildConfiguration.cs @@ -47,6 +47,12 @@ public sealed class GuildConfiguration /// The embed color for rejected suggestions. public int RejectedColor { get; set; } = 0xFF0000; + /// + /// Gets or sets the embed color for removed suggestions. + /// + /// The embed color for removed suggestions. + public int RemovedColor { get; set; } = 0xFF0000; + /// /// Gets or sets the channel ID for posting suggestions. /// diff --git a/SuggestionBot/Data/EntityConfigurations/SuggestionConfiguration.cs b/SuggestionBot/Data/EntityConfigurations/SuggestionConfiguration.cs index fef7298..49f34ae 100644 --- a/SuggestionBot/Data/EntityConfigurations/SuggestionConfiguration.cs +++ b/SuggestionBot/Data/EntityConfigurations/SuggestionConfiguration.cs @@ -22,5 +22,6 @@ public void Configure(EntityTypeBuilder builder) builder.Property(e => e.Timestamp).IsRequired(); builder.Property(e => e.ThreadId); builder.Property(e => e.StaffMemberId); + builder.Property(e => e.Remarks); } } diff --git a/SuggestionBot/Data/Suggestion.cs b/SuggestionBot/Data/Suggestion.cs index 07bc139..796e080 100644 --- a/SuggestionBot/Data/Suggestion.cs +++ b/SuggestionBot/Data/Suggestion.cs @@ -34,6 +34,12 @@ public sealed class Suggestion /// The message ID. public ulong MessageId { get; set; } + /// + /// Gets or sets the additional remarks about the suggestion. + /// + /// The remarks. + public string? Remarks { get; set; } + /// /// Gets or sets the ID of the staff member who implemented or rejected the suggestion. /// diff --git a/SuggestionBot/Data/SuggestionStatus.cs b/SuggestionBot/Data/SuggestionStatus.cs index 9dbfd20..9500eee 100644 --- a/SuggestionBot/Data/SuggestionStatus.cs +++ b/SuggestionBot/Data/SuggestionStatus.cs @@ -8,5 +8,6 @@ public enum SuggestionStatus Suggested, Rejected, Implemented, - Accepted + Accepted, + Removed } diff --git a/SuggestionBot/Program.cs b/SuggestionBot/Program.cs index bd84528..500fcdf 100644 --- a/SuggestionBot/Program.cs +++ b/SuggestionBot/Program.cs @@ -30,6 +30,7 @@ builder.Services.AddSingleton(); builder.Services.AddHostedSingleton(); builder.Services.AddHostedSingleton(); +builder.Services.AddSingleton(); builder.Services.AddHostedSingleton(); IHost app = builder.Build(); diff --git a/SuggestionBot/Resources/PrivateMessages.Designer.cs b/SuggestionBot/Resources/PrivateMessages.Designer.cs new file mode 100644 index 0000000..11a660a --- /dev/null +++ b/SuggestionBot/Resources/PrivateMessages.Designer.cs @@ -0,0 +1,110 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SuggestionBot.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class PrivateMessages { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal PrivateMessages() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SuggestionBot.Resources.PrivateMessages", typeof(PrivateMessages).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Hi {user.Mention}. Your suggestion in **{guild.Name}** has been accepted by staff members. + ///Depending on the complexity of your suggestion, it may take time to implement it into the server. Please be patient during this process. + /// + ///If you have any further questions, please reach us by sending a DM to ModMail.. + /// + internal static string AcceptedDescription { + get { + return ResourceManager.GetString("AcceptedDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hi {user.Mention}. Your suggestion in **{guild.Name}** has been implemented and is now live in the server! + ///Thank you for your contribution and feedback, and we hope you enjoy the new changes. + /// + ///If you have any further questions, please reach us by sending a DM to ModMail.. + /// + internal static string ImplementedDescription { + get { + return ResourceManager.GetString("ImplementedDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hi {user.Mention}. Unfortunately, your suggestion in **{guild.Name}** has been rejected by staff at this time. + ///Keep in mind that while a suggestion may be popular, there is no guarantee that it will be accepted. Nevertheless, we thank you for your contribution and feedback. + /// + ///If you have any further questions, please reach us by sending a DM to ModMail.. + /// + internal static string RejectedDescription { + get { + return ResourceManager.GetString("RejectedDescription", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {user.Mention}, your suggestion in **{guild.Name}** has been removed by staff because it was inappropriate or violated our server rules. + ///Repeated abuse will result in you losing access to the channel. + /// + ///If you have any further questions, please reach us by sending a DM to ModMail.. + /// + internal static string RemovedDescription { + get { + return ResourceManager.GetString("RemovedDescription", resourceCulture); + } + } + } +} diff --git a/SuggestionBot/Resources/PrivateMessages.resx b/SuggestionBot/Resources/PrivateMessages.resx new file mode 100644 index 0000000..76456ea --- /dev/null +++ b/SuggestionBot/Resources/PrivateMessages.resx @@ -0,0 +1,54 @@ + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + + + + + {user.Mention}, your suggestion in **{guild.Name}** has been removed by staff because it was inappropriate or violated our server rules. +Repeated abuse will result in you losing access to the channel. + +If you have any further questions, please reach us by sending a DM to ModMail. + + + + Hi {user.Mention}. Unfortunately, your suggestion in **{guild.Name}** has been rejected by staff at this time. +Keep in mind that while a suggestion may be popular, there is no guarantee that it will be accepted. Nevertheless, we thank you for your contribution and feedback. + +If you have any further questions, please reach us by sending a DM to ModMail. + + + + Hi {user.Mention}. Your suggestion in **{guild.Name}** has been accepted by staff members. +Depending on the complexity of your suggestion, it may take time to implement it into the server. Please be patient during this process. + +If you have any further questions, please reach us by sending a DM to ModMail. + + + + Hi {user.Mention}. Your suggestion in **{guild.Name}** has been implemented and is now live in the server! +Thank you for your contribution and feedback, and we hope you enjoy the new changes. + +If you have any further questions, please reach us by sending a DM to ModMail. + + \ No newline at end of file diff --git a/SuggestionBot/Services/MailmanService.cs b/SuggestionBot/Services/MailmanService.cs new file mode 100644 index 0000000..d386d3f --- /dev/null +++ b/SuggestionBot/Services/MailmanService.cs @@ -0,0 +1,124 @@ +using DSharpPlus; +using DSharpPlus.Entities; +using Humanizer; +using SmartFormat; +using SuggestionBot.Configuration; +using SuggestionBot.Data; +using SuggestionBot.Resources; +using X10D.DSharpPlus; + +namespace SuggestionBot.Services; + +internal sealed class MailmanService +{ + private readonly DiscordClient _discordClient; + private readonly ConfigurationService _configurationService; + private readonly SuggestionService _suggestionService; + + /// + /// Initializes a new instance of the class. + /// + /// The . + /// The . + /// The . + public MailmanService(DiscordClient discordClient, + ConfigurationService configurationService, + SuggestionService suggestionService) + { + _discordClient = discordClient; + _configurationService = configurationService; + _suggestionService = suggestionService; + } + + /// + /// Sends a suggestion to the author via DM. + /// + /// The to send. + /// is . + public async Task SendSuggestionAsync(Suggestion suggestion) + { + if (suggestion is null) + { + throw new ArgumentNullException(nameof(suggestion)); + } + + if (!_discordClient.Guilds.TryGetValue(suggestion.GuildId, out DiscordGuild? guild)) + { + return; + } + + DiscordUser author = _suggestionService.GetAuthor(suggestion); + DiscordMember? member = await author.GetAsMemberOfAsync(guild).ConfigureAwait(false); + if (member is null) + { + return; + } + + Uri suggestionLink = _suggestionService.GetSuggestionLink(suggestion); + string iconUrl = guild.GetIconUrl(ImageFormat.Png); + + var embed = new DiscordEmbedBuilder(); + embed.WithThumbnail(iconUrl); + embed.WithFooter(guild.Name, iconUrl); + + if (!TryBuildEmbed(suggestion, embed, author, guild)) + { + return; + } + + suggestion.Content = suggestion.Content.Truncate(250, "..."); + embed.AddField("Your Suggestion", suggestion.Content); + + if (!string.IsNullOrWhiteSpace(suggestion.Remarks)) + { + embed.AddField("Staff Remarks", suggestion.Remarks); + } + + if (suggestion.Status != SuggestionStatus.Removed) + { + embed.AddField("View Suggestion", suggestionLink); + } + + await member.SendMessageAsync(embed).ConfigureAwait(false); + } + + private bool TryBuildEmbed(Suggestion suggestion, DiscordEmbedBuilder embed, DiscordUser author, DiscordGuild guild) + { + if (!_configurationService.TryGetGuildConfiguration(guild, out GuildConfiguration? configuration)) + { + configuration = new GuildConfiguration(); + } + + switch (suggestion.Status) + { + case SuggestionStatus.Removed: + embed.WithColor(configuration.RemovedColor); + embed.WithTitle("Suggestion Removed"); + embed.WithDescription(PrivateMessages.RemovedDescription.FormatSmart(new { user = author, guild })); + break; + + case SuggestionStatus.Rejected: + embed.WithColor(configuration.RejectedColor); + embed.WithTitle("Suggestion Rejected"); + embed.WithDescription(PrivateMessages.RejectedDescription.FormatSmart(new { user = author, guild })); + break; + + case SuggestionStatus.Accepted: + embed.WithColor(configuration.AcceptedColor); + embed.WithTitle("Suggestion Accepted"); + embed.WithDescription(PrivateMessages.AcceptedDescription.FormatSmart(new { user = author, guild })); + break; + + case SuggestionStatus.Implemented: + embed.WithColor(configuration.ImplementedColor); + embed.WithTitle("Suggestion Implemented"); + embed.WithDescription(PrivateMessages.ImplementedDescription.FormatSmart(new { user = author, guild })); + break; + + default: + return false; + } + + return true; + } +} diff --git a/SuggestionBot/Services/SuggestionService.cs b/SuggestionBot/Services/SuggestionService.cs index ca33d30..abe48c5 100644 --- a/SuggestionBot/Services/SuggestionService.cs +++ b/SuggestionBot/Services/SuggestionService.cs @@ -99,11 +99,21 @@ public DiscordEmbed CreatePrivateEmbed(Suggestion suggestion) embed.AddField("Submitted", Formatter.Timestamp(suggestion.Timestamp), true); embed.AddField("View Suggestion", GetSuggestionLink(suggestion), true); + if (suggestion.ThreadId != 0 && suggestion.Status != SuggestionStatus.Removed) + { + embed.AddField("View Discussion", MentionUtility.MentionChannel(suggestion.ThreadId), true); + } + if (suggestion.StaffMemberId.HasValue) { embed.AddField("Approver", MentionUtility.MentionUser(suggestion.StaffMemberId.Value), true); } + if (!string.IsNullOrWhiteSpace(suggestion.Remarks)) + { + embed.AddField("Staff Remarks", suggestion.Remarks); + } + return embed; } @@ -161,6 +171,11 @@ public DiscordEmbed CreatePublicEmbed(Suggestion suggestion) embed.AddField("Status", $"{emoji} **{suggestion.Status.Humanize(LetterCasing.AllCaps)}**", true); + if (!string.IsNullOrWhiteSpace(suggestion.Remarks)) + { + embed.AddField("Staff Remarks", suggestion.Remarks); + } + return embed; } @@ -451,13 +466,17 @@ public bool SetMessage(Suggestion suggestion, DiscordMessage message) /// The suggestion to update. /// The new status of the suggestion. /// The staff member who updated the status. + /// Additional remarks about the suggestion. /// if the status was updated; otherwise, . /// /// is . /// -or- /// is . /// - public bool SetStatus(Suggestion suggestion, SuggestionStatus status, DiscordMember staffMember) + public bool SetStatus(Suggestion suggestion, + SuggestionStatus status, + DiscordMember staffMember, + string? remarks = null) { if (suggestion is null) { @@ -472,18 +491,41 @@ public bool SetStatus(Suggestion suggestion, SuggestionStatus status, DiscordMem string humanizedStatus = status.Humanize(LetterCasing.AllCaps); string oldHumanizedStatus = suggestion.Status.Humanize(LetterCasing.AllCaps); + if (!_configurationService.TryGetGuildConfiguration(suggestion.GuildId, out GuildConfiguration? configuration)) + { + configuration = new GuildConfiguration(); + } + var embed = new DiscordEmbedBuilder(); - embed.WithColor(DiscordColor.CornflowerBlue); + embed.WithColor(status switch + { + SuggestionStatus.Suggested => configuration.SuggestedColor, + SuggestionStatus.Rejected => configuration.RejectedColor, + SuggestionStatus.Implemented => configuration.ImplementedColor, + SuggestionStatus.Accepted => configuration.AcceptedColor, + SuggestionStatus.Removed => configuration.RemovedColor, + _ => DiscordColor.CornflowerBlue + }); embed.WithTitle("Suggestion Status Updated"); embed.WithDescription($"The status of suggestion {suggestion.Id} has been updated to **{humanizedStatus}**."); embed.AddField("Old Status", oldHumanizedStatus, true); embed.AddField("New Status", humanizedStatus, true); embed.AddField("Staff Member", staffMember.Mention, true); - embed.AddField("View Suggestion", GetSuggestionLink(suggestion), true); + if (status != SuggestionStatus.Removed) + { + embed.AddField("View Suggestion", GetSuggestionLink(suggestion), true); + } + + if (!string.IsNullOrWhiteSpace(remarks)) + { + embed.AddField("Staff Remarks", remarks); + } + _ = _logService.LogAsync(suggestion.GuildId, embed); suggestion.Status = status; suggestion.StaffMemberId = staffMember.Id; + suggestion.Remarks = remarks; using SuggestionContext context = _contextFactory.CreateDbContext(); context.Suggestions.Update(suggestion); @@ -614,6 +656,18 @@ public async Task UpdateSuggestionAsync(Suggestion suggestion) return; } + if (suggestion.Status == SuggestionStatus.Removed) + { + DiscordThreadChannel? thread = GetThread(suggestion); + if (thread is not null) + { + await thread.DeleteAsync().ConfigureAwait(false); + } + + await message.DeleteAsync(); + return; + } + DiscordEmbed embed = CreatePublicEmbed(suggestion); await message.ModifyAsync(m => m.Embed = embed).ConfigureAwait(false); diff --git a/SuggestionBot/SuggestionBot.csproj b/SuggestionBot/SuggestionBot.csproj index b841d27..0e89249 100644 --- a/SuggestionBot/SuggestionBot.csproj +++ b/SuggestionBot/SuggestionBot.csproj @@ -6,7 +6,7 @@ enable enable Linux - 1.5.1 + 1.6.0 @@ -40,6 +40,7 @@ + @@ -54,4 +55,19 @@ + + + ResXFileCodeGenerator + PrivateMessages.Designer.cs + + + + + + True + True + PrivateMessages.resx + + +