Skip to content

Commit

Permalink
OnReady: throw fatal error and exit program if log unpack fails
Browse files Browse the repository at this point in the history
Fixes #215
  • Loading branch information
Erisa committed Aug 11, 2024
1 parent d4a11cd commit 58f1d69
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Events/ReadyEvent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using static Cliptok.Program;
using System.Runtime.ExceptionServices;
using static Cliptok.Program;

namespace Cliptok.Events
{
Expand All @@ -9,8 +10,15 @@ public static async Task OnReady(DiscordClient client, SessionCreatedEventArgs _

homeGuild = await discord.GetGuildAsync(cfgjson.ServerID);

if (!LogChannelHelper.ready)
await LogChannelHelper.UnpackLogConfigAsync(cfgjson);
try
{
if (!LogChannelHelper.ready)
await LogChannelHelper.UnpackLogConfigAsync(cfgjson);
} catch (Exception e)
{
client.Logger.LogCritical(e, "Fatal error unpacking log config!");
Environment.Exit(1);
}

var fetchResult = await APIs.ServerAPI.FetchMaliciousServersList();
if (fetchResult is not null)
Expand Down

0 comments on commit 58f1d69

Please sign in to comment.