cs-codex-dist-tests/Tools/BiblioTech/Program.cs

50 lines
1.4 KiB
C#
Raw Normal View History

2023-10-18 09:01:24 +00:00
using ArgsUniform;
using Discord;
2023-10-18 07:10:04 +00:00
using Discord.WebSocket;
2023-10-18 09:01:24 +00:00
namespace BiblioTech
2023-10-18 06:57:59 +00:00
{
2023-10-18 09:01:24 +00:00
public class Program
{
private DiscordSocketClient client = null!;
2023-10-18 07:10:04 +00:00
2023-10-18 09:01:24 +00:00
public static Configuration Config { get; private set; } = null!;
2023-10-18 07:10:04 +00:00
2023-10-18 09:01:24 +00:00
public static Task Main(string[] args)
{
var uniformArgs = new ArgsUniform<Configuration>(PrintHelp, args);
Config = uniformArgs.Parse(true);
2023-10-18 07:10:04 +00:00
2023-10-18 09:01:24 +00:00
return new Program().MainAsync();
}
2023-10-18 06:57:59 +00:00
2023-10-18 09:01:24 +00:00
public async Task MainAsync()
{
Console.WriteLine("Starting Codex Discord Bot...");
client = new DiscordSocketClient();
2023-10-18 07:10:04 +00:00
2023-10-18 09:01:24 +00:00
client.Log += Log;
// You can assign your bot token to a string, and pass that in to connect.
// This is, however, insecure, particularly if you plan to have your code hosted in a public repository.
var token = "token";
await client.LoginAsync(TokenType.Bot, token);
await client.StartAsync();
Console.WriteLine("Running...");
await Task.Delay(-1);
}
private static void PrintHelp()
{
Console.WriteLine("BiblioTech - Codex Discord Bot");
}
private Task Log(LogMessage msg)
{
Console.WriteLine(msg.ToString());
return Task.CompletedTask;
}
2023-10-18 06:57:59 +00:00
}
2023-10-18 09:01:24 +00:00
}