Skip to content

Commit e690e50

Browse files
committed
fix: bad error for send message
1 parent 5f9a2f1 commit e690e50

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎DiscordLab.Bot/API/Extensions/DiscordExtensions.cs‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
namespace DiscordLab.Bot.API.Extensions;
22

3+
using System.Diagnostics;
4+
using System.Reflection;
35
using Discord;
46
using Discord.WebSocket;
7+
using DiscordLab.Bot.API.Utilities;
58

69
/// <summary>
710
/// Extension methods to help with Discord based tasks.
@@ -17,8 +20,13 @@ public static class DiscordExtensions
1720
/// <param name="embed">The embed.</param>
1821
/// <param name="embeds">The embeds.</param>
1922
/// <remarks>Text, embed or embeds is required here.</remarks>
20-
public static void SendMessage(this SocketTextChannel channel, string? text = null, bool isTts = false, Embed? embed = null, Embed[]? embeds = null) =>
21-
Task.RunAndLog(async () => await channel.SendMessageAsync(text, isTts, embed, embeds: embeds).ConfigureAwait(false));
23+
public static void SendMessage(this SocketTextChannel channel, string? text = null, bool isTts = false, Embed? embed = null, Embed[]? embeds = null)
24+
{
25+
MethodBase method = new StackFrame(1).GetMethod();
26+
Task.RunAndLog(
27+
async () => await channel.SendMessageAsync(text, isTts, embed, embeds: embeds).ConfigureAwait(false),
28+
ex => LoggingUtils.LogMethodError(ex, method));
29+
}
2230

2331
/// <summary>
2432
/// Gets an option from a list of slash command options.

0 commit comments

Comments
 (0)