improve get calling command

This commit is contained in:
Madpeter 2025-06-15 13:08:19 +01:00
parent 25ac5378e1
commit 7b3b0f07e5

View file

@ -14,6 +14,7 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
using Org.BouncyCastle.Utilities;
namespace SecondBotEvents.Services namespace SecondBotEvents.Services
{ {
@ -230,7 +231,22 @@ namespace SecondBotEvents.Services
protected static string GetCallingCommand() protected static string GetCallingCommand()
{ {
return (new System.Diagnostics.StackTrace()).GetFrame(2).GetMethod().Name; string commandName = "Unable to get";
try
{
int index = 2;
do
{
commandName = (new System.Diagnostics.StackTrace()).GetFrame(index).GetMethod().Name;
index++;
}
while (commandName.StartsWith("InvokeWith") == true);
}
catch (Exception)
{
commandName = "errorFetchCommandName";
}
return commandName;
} }
} }