Skip to content

Commit

Permalink
Merge branch 'v1.6.3' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbooth committed Jul 27, 2023
2 parents 52f4e20 + 80dcedf commit 5f2ce3c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions SuggestionBot/Commands/InfoCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
Expand Down
6 changes: 4 additions & 2 deletions SuggestionBot/Commands/SuggestCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)
{
Expand Down
22 changes: 22 additions & 0 deletions SuggestionBot/MentionUtility.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using DSharpPlus.Entities;

namespace SuggestionBot;

internal sealed class MentionUtility
{
/// <summary>
/// Replaces raw channel mentions with Discord channel mentions.
/// </summary>
/// <param name="guild">The guild.</param>
/// <param name="input">The input to sanitize.</param>
/// <returns>The sanitized input.</returns>
public static string ReplaceChannelMentions(DiscordGuild guild, string input)
{
foreach (DiscordChannel channel in guild.Channels.Values)
{
input = input.Replace($"#{channel.Name}", channel.Mention);
}

return input;
}
}
2 changes: 2 additions & 0 deletions SuggestionBot/Services/SuggestionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace SuggestionBot.Services;

using MentionUtility = X10D.DSharpPlus.MentionUtility;

internal sealed class SuggestionService : BackgroundService
{
private readonly ConcurrentDictionary<ulong, List<Suggestion>> _suggestions = new();
Expand Down
2 changes: 1 addition & 1 deletion SuggestionBot/SuggestionBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<VersionPrefix>1.6.2</VersionPrefix>
<VersionPrefix>1.6.3</VersionPrefix>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
Expand Down

0 comments on commit 5f2ce3c

Please sign in to comment.