add game activity

This commit is contained in:
sim1222 2023-07-26 22:35:40 +09:00
parent 08c6373012
commit 219cf0da88

View File

@ -77,7 +77,24 @@ public class Program
await _voicevoxAPI.Setup("http://localhost:50021"); await _voicevoxAPI.Setup("http://localhost:50021");
await _client.LoginAsync(TokenType.Bot, configuration.AppSettings.DiscordSettings.Token); await _client.LoginAsync(TokenType.Bot, configuration.AppSettings.DiscordSettings.Token);
await _client.StartAsync(); 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<AudioManager>().JoinChannel(after.VoiceChannel);
}
};
await Task.Delay(-1); //keep the program running await Task.Delay(-1); //keep the program running
} }