53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using NetCord.Hosting.Gateway;
|
|
using NetCord.Hosting.Services;
|
|
using NetCord.Hosting.Services.ApplicationCommands;
|
|
using NetCord.Hosting.Services.ComponentInteractions;
|
|
using NetCord.Services.ComponentInteractions;
|
|
|
|
namespace FluxPose.DiscordBot;
|
|
|
|
internal static class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
var builder = Host.CreateApplicationBuilder(args);
|
|
|
|
builder.Services
|
|
.AddDiscordGateway(options =>
|
|
{
|
|
options.Intents = GatewayIntents.Guilds | GatewayIntents.GuildUsers | GatewayIntents.GuildEmojisAndStickers;
|
|
})
|
|
.AddApplicationCommands()
|
|
.AddComponentInteractions<ButtonInteraction, ButtonInteractionContext>();
|
|
|
|
AddActions(builder.Services);
|
|
|
|
var host = builder.Build();
|
|
|
|
var configuration = host.Services.GetRequiredService<IConfiguration>();
|
|
|
|
var token = Environment.GetEnvironmentVariable("BOT_TOKEN");
|
|
if (token != null)
|
|
{
|
|
configuration["Discord:Token"] = token;
|
|
}
|
|
|
|
host.AddModules(typeof(Program).Assembly);
|
|
|
|
host.RunAsync().GetAwaiter().GetResult();
|
|
}
|
|
|
|
private static void AddActions(IServiceCollection services)
|
|
{
|
|
services.AddScoped<IInteractionContext, ButtonInteractionContext>();
|
|
services.AddScoped<IInteractionContext, ApplicationCommandContext>();
|
|
|
|
services.AddScoped<Experimenting.Actions>();
|
|
services.AddScoped<Roles.Actions>();
|
|
services.AddScoped<Users.Actions>();
|
|
}
|
|
}
|