2018-03-28 23:34:48 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
2018-03-29 13:35:00 +00:00
|
|
|
|
using DeukBot4.Database;
|
2018-03-28 23:34:48 +00:00
|
|
|
|
using DeukBot4.MessageHandlers;
|
|
|
|
|
using DeukBot4.MessageHandlers.CommandHandler;
|
|
|
|
|
using Discord;
|
|
|
|
|
using Discord.Commands.Builders;
|
|
|
|
|
using Discord.WebSocket;
|
|
|
|
|
|
|
|
|
|
namespace DeukBot4
|
|
|
|
|
{
|
|
|
|
|
class Program
|
|
|
|
|
{
|
|
|
|
|
public static DiscordSocketClient Client { get; private set; }
|
|
|
|
|
public static Settings Settings { get; private set; }
|
|
|
|
|
|
|
|
|
|
private static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
MainAsync().GetAwaiter().GetResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static async Task MainAsync()
|
|
|
|
|
{
|
|
|
|
|
Settings = Settings.FromJsonFile("settings.json");
|
2018-03-29 13:35:00 +00:00
|
|
|
|
DatabaseConnection.ConnectionString = Settings.DatabaseConnectionString;
|
|
|
|
|
|
|
|
|
|
DatabaseInitializer.Initialize();
|
2018-03-28 23:34:48 +00:00
|
|
|
|
CommandHandler.Build();
|
|
|
|
|
Client = new DiscordSocketClient();
|
|
|
|
|
|
|
|
|
|
Client.Log += Logger.LogDiscord;
|
|
|
|
|
Client.Ready += OnReady;
|
|
|
|
|
Client.MessageReceived += MainHandler.HandleMessage;
|
|
|
|
|
|
|
|
|
|
await Client.LoginAsync(TokenType.Bot, Settings.Token);
|
|
|
|
|
await Client.StartAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Block this task until the program is closed.
|
|
|
|
|
await Task.Delay(-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static async Task OnReady()
|
|
|
|
|
{
|
|
|
|
|
await Client.CurrentUser.ModifyAsync(properties =>
|
|
|
|
|
{
|
|
|
|
|
properties.Username = Settings.Username;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|