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 }