From 7b3b0f07e5033a182aa3fa4bdefc0c268d75c3a9 Mon Sep 17 00:00:00 2001 From: Madpeter <57852827+Madpeterz@users.noreply.github.com> Date: Sun, 15 Jun 2025 13:08:19 +0100 Subject: [PATCH] improve get calling command --- SecondBotEvents/Services/HttpService.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/SecondBotEvents/Services/HttpService.cs b/SecondBotEvents/Services/HttpService.cs index b895803..5c121a0 100644 --- a/SecondBotEvents/Services/HttpService.cs +++ b/SecondBotEvents/Services/HttpService.cs @@ -14,6 +14,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json; +using Org.BouncyCastle.Utilities; namespace SecondBotEvents.Services { @@ -230,7 +231,22 @@ namespace SecondBotEvents.Services 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; } }