59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
using NLog;
|
|
using System;
|
|
using ChaosBot.Discord;
|
|
using System.Threading.Tasks;
|
|
using ChaosBot.Attribute;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
namespace ChaosBot
|
|
{
|
|
internal class Program
|
|
{
|
|
public static IConfiguration Cfg { get; set; }
|
|
public static Logger _logger;
|
|
private static string appsettingsPath;
|
|
|
|
private static void Main(string[] args)
|
|
{
|
|
appsettingsPath = args.Length > 0 ? args[0] : "./appsettings.json";
|
|
new Program().MainFunction().GetAwaiter().GetResult();
|
|
}
|
|
|
|
private async Task MainFunction()
|
|
{
|
|
try
|
|
{
|
|
/*
|
|
* Load configuration from AppSettings.Json and save as Cfg
|
|
*/
|
|
Cfg = new ConfigurationBuilder()
|
|
.SetBasePath(System.IO.Directory.GetCurrentDirectory())
|
|
.AddJsonFile(appsettingsPath, optional: false, reloadOnChange: true).Build();
|
|
|
|
/*
|
|
* Initialize the _logger for logging purposes
|
|
*/
|
|
_logger = Logging.GenLog();
|
|
|
|
|
|
/*
|
|
* Attempt to load our custom assemblies
|
|
*/
|
|
AssemblyController.Register();
|
|
|
|
/*
|
|
* Initialize the Discord Client and Login
|
|
*/
|
|
_logger.Info($"Starting Up {Cfg.GetValue<string>("Bot:Name")} v{Cfg.GetValue<string>("Bot:Version")}");
|
|
|
|
var discordBot = DiscordConnect.StartUp();
|
|
await discordBot;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.Error(ex, $"Program.MainFunction: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
|
}
|
|
}
|
|
}
|
|
} |