Skip to content

Commit

Permalink
Ensure vital configuration is filled.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen Heijster committed May 14, 2022
1 parent 8a2f7a4 commit e83b371
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion StatBot/Settings/BotSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ public BotSettings(IConfiguration configuration)
Application = new Application(configuration);
mIRCStats = new MIRCStats(configuration);
Discord = new Discord(configuration);
VerifySettings();
}

private void VerifySettings()
{
if (String.IsNullOrEmpty(Discord.Token))
throw new Exception("Discord bot token missing.");
if (String.IsNullOrEmpty(Application.LoggingFileName))
throw new Exception("Logging file name missing.");
}

/// <summary>
Expand Down Expand Up @@ -66,7 +75,7 @@ public class Application
public Application(IConfiguration configuration)
{
LoggingFileName = configuration.GetValue<string>("Application:LoggingFileName");
NotificationDelay = configuration.GetValue<int>("Application:NotificationDelay");
NotificationDelay = configuration.GetValue<int?>("Application:NotificationDelay") ?? 30000;
PushOver = new PushOver(configuration);
}

Expand Down

0 comments on commit e83b371

Please sign in to comment.