49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
using System.Text.Json.Serialization;
|
|
using NetCord;
|
|
using NetCord.Gateway;
|
|
using NetCord.Hosting.Gateway;
|
|
using NetCord.Hosting.Rest;
|
|
using SquadBot.Handlers;
|
|
using SquadBot.StateMangers;
|
|
|
|
namespace SquadBot;
|
|
|
|
public class Program
|
|
{
|
|
|
|
public static async Task Main(string[] args)
|
|
{
|
|
var token = "";
|
|
var pubkey = "";
|
|
if (args.Length == 2)
|
|
{
|
|
token = args[0];
|
|
pubkey = args[1];
|
|
}
|
|
else
|
|
{
|
|
Console.Error.WriteLine("Usage: squadbot <token> <pubkey>");
|
|
}
|
|
|
|
var builder = Host.CreateApplicationBuilder(args);
|
|
builder.Services.AddLogging();
|
|
builder.Services.AddDiscordRest(options =>
|
|
{
|
|
options.PublicKey = pubkey;
|
|
options.Token = token;
|
|
});
|
|
builder.Services.AddSingleton<VoiceStateManager>();
|
|
builder.Services.AddSingleton<VoiceStatesHandler>();
|
|
builder.Services.AddDiscordGateway(options =>
|
|
{
|
|
options.Intents = GatewayIntents.GuildMessages
|
|
| GatewayIntents.GuildVoiceStates;
|
|
options.Token = token;
|
|
})
|
|
.AddGatewayHandlers(typeof(Program).Assembly);
|
|
|
|
var host = builder.Build()
|
|
.UseGatewayHandlers();
|
|
await host.RunAsync();
|
|
}
|
|
} |