init commit
This commit is contained in:
50
Program.cs
Normal file
50
Program.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
using Discord.Interactions;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TentacleBot.Services;
|
||||
using TentacleBot.Commands;
|
||||
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build();
|
||||
|
||||
var discordConfig = new DiscordSocketConfig
|
||||
{
|
||||
GatewayIntents = GatewayIntents.All,
|
||||
LogLevel = LogSeverity.Info,
|
||||
UseInteractionSnowflakeDate = false,
|
||||
};
|
||||
|
||||
var client = new DiscordSocketClient(discordConfig);
|
||||
|
||||
var services = new ServiceCollection()
|
||||
.AddLogging(builder => builder.AddConsole())
|
||||
.AddSingleton<IConfiguration>(configuration)
|
||||
.AddSingleton(client)
|
||||
.AddSingleton(new InteractionService(client, new InteractionServiceConfig
|
||||
{
|
||||
LogLevel = LogSeverity.Info,
|
||||
UseCompiledLambda = true,
|
||||
}))
|
||||
.AddSingleton<BotService>();
|
||||
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
|
||||
var botService = serviceProvider.GetRequiredService<BotService>();
|
||||
var interactionService = serviceProvider.GetRequiredService<InteractionService>();
|
||||
|
||||
// Register command modules
|
||||
await interactionService.AddModulesAsync(
|
||||
typeof(Program).Assembly,
|
||||
serviceProvider);
|
||||
|
||||
// Initialize the bot
|
||||
await botService.InitializeAsync();
|
||||
|
||||
// Keep the bot running
|
||||
await Task.Delay(Timeout.Infinite);
|
||||
Reference in New Issue
Block a user