From 219cf0da8833524f84860705278d54fd3d9da953 Mon Sep 17 00:00:00 2001 From: sim1222 Date: Wed, 26 Jul 2023 22:35:40 +0900 Subject: [PATCH] add game activity --- Elementary/Program.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Elementary/Program.cs b/Elementary/Program.cs index 15101a9..257914c 100644 --- a/Elementary/Program.cs +++ b/Elementary/Program.cs @@ -77,7 +77,24 @@ public class Program await _voicevoxAPI.Setup("http://localhost:50021"); await _client.LoginAsync(TokenType.Bot, configuration.AppSettings.DiscordSettings.Token); await _client.StartAsync(); + await _client.SetActivityAsync(new Game("!join")); + // _client.Disconnected += async (exception) => + // { + // await _client.StopAsync(); + // await _client.StartAsync(); + // }; + + _client.UserVoiceStateUpdated += async (user, before, after) => + { + if (user.Id != _client.CurrentUser.Id) return; + if (before.VoiceChannel.Id == after.VoiceChannel.Id) return; + + if (after.VoiceChannel is not null) + { + _services.GetRequiredService().JoinChannel(after.VoiceChannel); + } + }; await Task.Delay(-1); //keep the program running }