53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using NLog;
|
|
using System;
|
|
using Discord;
|
|
using Discord.WebSocket;
|
|
using System.Threading.Tasks;
|
|
using ChaosBot.Discord;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
namespace ChaosBot
|
|
{
|
|
internal class Program
|
|
{
|
|
public static IConfiguration Cfg { get; set; }
|
|
public static Logger _logger;
|
|
|
|
public static void Main(string[] args)
|
|
{
|
|
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("appsettings.json", optional: false, reloadOnChange: true).Build();
|
|
|
|
/*
|
|
* Initialize the _logger for logging purposes
|
|
*/
|
|
_logger = Logging.GenLog();
|
|
|
|
/*
|
|
* Initialize the Discord Client and Login
|
|
*/
|
|
_logger.Info($"Starting Up {Cfg.GetValue<string>("Bot:Name")} v{Cfg.GetValue<string>("Bot:Version")}");
|
|
|
|
|
|
var DiscordBot = DiscordConnect.Connect();
|
|
await DiscordBot;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.Error(ex, $"Stopped program because of exception");
|
|
}
|
|
}
|
|
}
|
|
} |