Skip to content

Commit

Permalink
Add message acknowledgement
Browse files Browse the repository at this point in the history
The bot can acknowledge a message by reacting with ✅

This provides the caller some feedback that the bot is indeed running, and a lack of response may be down to erroneous code
  • Loading branch information
oliverbooth committed Mar 6, 2022
1 parent b849d77 commit 520033c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Hammer/Extensions/CommandContextExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using DisCatSharp.CommandsNext;

namespace Hammer.Extensions;

/// <summary>
/// Extension methods for <see cref="CommandContext" />.
/// </summary>
internal static class CommandContextExtensions
{
/// <summary>
/// Acknowledges the message provided by a <see cref="CommandContext" /> by reacting to it.
/// </summary>
/// <param name="context">The command context.</param>
public static Task AcknowledgeAsync(this CommandContext context)
{
return context.Message.AcknowledgeAsync();
}
}
18 changes: 18 additions & 0 deletions Hammer/Extensions/DiscordMessageExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using DisCatSharp.Entities;

namespace Hammer.Extensions;

/// <summary>
/// Extension methods for <see cref="DiscordMessage" />.
/// </summary>
internal static class DiscordMessageExtensions
{
/// <summary>
/// Acknowledges a message by reacting to it.
/// </summary>
/// <param name="message">The message to acknowledge.</param>
public static Task AcknowledgeAsync(this DiscordMessage message)
{
return message.CreateReactionAsync(DiscordEmoji.FromUnicode("✅"));
}
}

0 comments on commit 520033c

Please sign in to comment.