80 lines
3.0 KiB
C#
80 lines
3.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using DSharpPlus;
|
|
using DSharpPlus.Commands;
|
|
using DSharpPlus.Commands.Processors.SlashCommands;
|
|
using DSharpPlus.Commands.Processors.TextCommands;
|
|
using DSharpPlus.Commands.Processors.TextCommands.Parsing;
|
|
using DSharpPlus.Entities;
|
|
using DSharpPlus.Interactivity;
|
|
using DSharpPlus.EventArgs;
|
|
using DSharpPlus.Interactivity.Extensions;
|
|
//using DSharpPlus.SlashCommands;
|
|
//using DSharpPlus.SlashCommands.Attributes;
|
|
using LaDOSE.DiscordBot.Command;
|
|
using LaDOSE.DiscordBot.Service;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace LaDOSE.DiscordBot
|
|
{
|
|
class Program
|
|
{
|
|
|
|
//static InteractivityModule Interactivity { get; set; }
|
|
static void Main(string[] args)
|
|
{
|
|
MainAsync(args).ConfigureAwait(false).GetAwaiter().GetResult();
|
|
}
|
|
|
|
|
|
|
|
static async Task MainAsync(string[] args)
|
|
{
|
|
Console.WriteLine(Directory.GetCurrentDirectory());
|
|
var builder = new ConfigurationBuilder()
|
|
.SetBasePath(Directory.GetCurrentDirectory())
|
|
.AddJsonFile("settings.json", optional: true, reloadOnChange: true).Build();
|
|
|
|
var discordToken = builder["Discord:Token"].ToString();
|
|
var challongeToken = builder["Challonge:Token"].ToString();
|
|
var restUrl = builder["REST:Url"].ToString();
|
|
var restUser = builder["REST:User"].ToString();
|
|
var restPassword = builder["REST:Password"].ToString();
|
|
|
|
Console.WriteLine($"LaDOSE.Net Discord Bot");
|
|
|
|
DiscordClientBuilder builder2 = DiscordClientBuilder.CreateDefault(discordToken, TextCommandProcessor.RequiredIntents | SlashCommandProcessor.RequiredIntents);
|
|
|
|
var cts = new CancellationTokenSource();
|
|
|
|
// Setup the commands extension
|
|
builder2.UseCommands((IServiceProvider serviceProvider, CommandsExtension extension) =>
|
|
{
|
|
extension.AddCommands([typeof(Hokuto), typeof(Public)]);
|
|
TextCommandProcessor textCommandProcessor = new();
|
|
extension.AddProcessor(textCommandProcessor);
|
|
}, new CommandsConfiguration()
|
|
{
|
|
// The default value is true, however it's shown here for clarity
|
|
RegisterDefaultCommandProcessors = true,
|
|
UseDefaultCommandErrorHandler = false
|
|
// DebugGuildId = Environment.GetEnvironmentVariable("DEBUG_GUILD_ID") ?? 0,
|
|
});
|
|
|
|
DiscordClient client = builder2.Build();
|
|
|
|
// We can specify a status for our bot. Let's set it to "playing" and set the activity to "with fire".
|
|
DiscordActivity status = new("Street Fighter", DiscordActivityType.Playing);
|
|
await client.ConnectAsync(status,DiscordUserStatus.Online);
|
|
|
|
|
|
await Task.Delay(Timeout.Infinite);
|
|
|
|
}
|
|
}
|
|
} |