mirror of
https://github.com/Jetsparrow/jetherald.git
synced 2026-01-20 23:56:08 +03:00
40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using System.Threading.Tasks;
|
|
using DSharpPlus;
|
|
using DSharpPlus.CommandsNext;
|
|
using JetHerald.Commands;
|
|
|
|
namespace JetHerald
|
|
{
|
|
public partial class JetHeraldBot
|
|
{
|
|
DiscordClient DiscordBot { get; set; }
|
|
|
|
async Task InitDiscord()
|
|
{
|
|
DiscordBot = new DiscordClient(new()
|
|
{
|
|
Token = DiscordConfig.Token,
|
|
TokenType = TokenType.Bot,
|
|
Intents = DiscordIntents.AllUnprivileged,
|
|
LoggerFactory = LoggerFactory
|
|
});
|
|
|
|
var commands = DiscordBot.UseCommandsNext(new CommandsNextConfiguration()
|
|
{
|
|
StringPrefixes = new[] { "!" },
|
|
Services = ServiceProvider
|
|
});
|
|
|
|
commands.RegisterCommands<DiscordCommands>();
|
|
|
|
await DiscordBot.ConnectAsync();
|
|
}
|
|
|
|
|
|
async Task SendMessageToDiscordChannel(NamespacedId chat, string formatted)
|
|
{
|
|
var id = ulong.Parse(chat.Id);
|
|
await DiscordBot.SendMessageAsync(await DiscordBot.GetChannelAsync(id), formatted);
|
|
}
|
|
}
|
|
} |