add couple of stuff

This commit is contained in:
2023-02-02 12:50:33 -03:00
parent ae9c3cfa35
commit 5146f47c30
4 changed files with 115 additions and 52 deletions

View File

@@ -28,6 +28,8 @@ namespace TextCommandFramework
var client = services.GetRequiredService<DiscordSocketClient>();
client.Log += LogAsync;
client.LoggedIn += () => Client_LoggedIn(client);
client.Ready += () => Client_Ready(client);
services.GetRequiredService<CommandService>().Log += LogAsync;
await client.LoginAsync(TokenType.Bot, token);
@@ -39,6 +41,34 @@ namespace TextCommandFramework
}
}
private async Task Client_Ready(DiscordSocketClient client)
{
var announceLoginGuild = ulong.Parse(Environment.GetEnvironmentVariable("ANNOUNCE_LOGIN_GUILD") ?? "0");
var announceLoginChannel = ulong.Parse(Environment.GetEnvironmentVariable("ANNOUNCE_LOGIN_CHANNEL") ?? "0");
if (announceLoginGuild == 0 || announceLoginChannel == 0)
{
return;
}
var channel = client.GetGuild(announceLoginGuild).GetTextChannel(announceLoginChannel);
if (channel == null)
{
Console.WriteLine("Announce channel not found.");
return;
}
await channel.SendMessageAsync("@everyone LIVE!");
}
private Task Client_LoggedIn(DiscordSocketClient client)
{
Console.WriteLine("Successfully logged in!");
return Task.CompletedTask;
}
private Task LogAsync(LogMessage log)
{
Console.WriteLine(log.ToString());