diff --git a/CHANGELOG.md b/CHANGELOG.md index de15f44..6712037 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ 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.3] - 2023-07-27 + +### Added + +- Added repo URL to `/info` embed. +- #channel_name in suggestion content is now automatically converted to a mention string. + ## [1.6.2] - 2023-07-26 ### Added diff --git a/SuggestionBot/Commands/InfoCommand.cs b/SuggestionBot/Commands/InfoCommand.cs index eb04bdb..5f25ce3 100644 --- a/SuggestionBot/Commands/InfoCommand.cs +++ b/SuggestionBot/Commands/InfoCommand.cs @@ -40,6 +40,7 @@ public async Task InfoAsync(InteractionContext context) embed.WithTitle($"SuggestionBot v{botVersion}"); embed.AddField("Ping", client.Ping, true); embed.AddField("Uptime", (DateTimeOffset.UtcNow - _botService.StartedAt).Humanize(), true); + embed.AddField("View Source", "[View on GitHub](https://github.com/BrackeysBot/SuggestionBot/)", true); var builder = new StringBuilder(); builder.AppendLine($"SuggestionBot: {botVersion}"); diff --git a/SuggestionBot/Commands/SuggestCommand.cs b/SuggestionBot/Commands/SuggestCommand.cs index eefa2d0..33a4d74 100644 --- a/SuggestionBot/Commands/SuggestCommand.cs +++ b/SuggestionBot/Commands/SuggestCommand.cs @@ -36,7 +36,8 @@ public SuggestCommand(CooldownService cooldownService, [SlashRequireGuild] public async Task SuggestAsync(InteractionContext context) { - if (_userBlockingService.IsUserBlocked(context.Guild, context.User)) + DiscordGuild guild = context.Guild; + if (_userBlockingService.IsUserBlocked(guild, context.User)) { var builder = new DiscordInteractionResponseBuilder(); builder.AsEphemeral(); @@ -75,7 +76,8 @@ public async Task SuggestAsync(InteractionContext context) return; } - Suggestion suggestion = _suggestionService.CreateSuggestion(context.Member, input.Value); + string content = MentionUtility.ReplaceChannelMentions(guild, input.Value); + Suggestion suggestion = _suggestionService.CreateSuggestion(context.Member, content); DiscordMessage? message = await _suggestionService.PostSuggestionAsync(suggestion).ConfigureAwait(false); if (message == null) { diff --git a/SuggestionBot/MentionUtility.cs b/SuggestionBot/MentionUtility.cs new file mode 100644 index 0000000..f315e14 --- /dev/null +++ b/SuggestionBot/MentionUtility.cs @@ -0,0 +1,22 @@ +using DSharpPlus.Entities; + +namespace SuggestionBot; + +internal sealed class MentionUtility +{ + /// + /// Replaces raw channel mentions with Discord channel mentions. + /// + /// The guild. + /// The input to sanitize. + /// The sanitized input. + public static string ReplaceChannelMentions(DiscordGuild guild, string input) + { + foreach (DiscordChannel channel in guild.Channels.Values) + { + input = input.Replace($"#{channel.Name}", channel.Mention); + } + + return input; + } +} diff --git a/SuggestionBot/Services/SuggestionService.cs b/SuggestionBot/Services/SuggestionService.cs index 7c7964e..4313236 100644 --- a/SuggestionBot/Services/SuggestionService.cs +++ b/SuggestionBot/Services/SuggestionService.cs @@ -13,6 +13,8 @@ namespace SuggestionBot.Services; +using MentionUtility = X10D.DSharpPlus.MentionUtility; + internal sealed class SuggestionService : BackgroundService { private readonly ConcurrentDictionary> _suggestions = new(); diff --git a/SuggestionBot/SuggestionBot.csproj b/SuggestionBot/SuggestionBot.csproj index 43f5e2c..437a750 100644 --- a/SuggestionBot/SuggestionBot.csproj +++ b/SuggestionBot/SuggestionBot.csproj @@ -6,7 +6,7 @@ enable enable Linux - 1.6.2 + 1.6.3