* Fix

* Fix

* Add HandleSafe
This commit is contained in:
DHR60
2026-08-14 02:20:58 +00:00
committed by GitHub
parent 9c1951178c
commit bc06a5dc21
10 changed files with 72 additions and 65 deletions
+21
View File
@@ -134,4 +134,25 @@ public static class Extension
.Replace("\r", replacement)
.Replace("\n", replacement);
}
public static async Task<TOutput> HandleSafe<TInput, TOutput>(
this Interaction<TInput, TOutput> interaction,
TInput input,
TOutput defaultValue = default!)
{
try
{
return await interaction.Handle(input);
}
catch (UnhandledInteractionException<TInput, TOutput> ex)
{
Logging.SaveLog($"Unhandled interaction exception for input: {input}", ex);
return defaultValue;
}
catch (Exception ex)
{
Logging.SaveLog($"Exception occurred while handling interaction for input: {input}", ex);
return defaultValue;
}
}
}