public async Task JoinAudio(IGuild guild, IVoiceChannel channel) { try { if (ConnectedChannels.TryGetValue(guild.Id, out client)) { Console.WriteLine("1"); return; } if (channel.Guild.Id != guild.Id) { Console.WriteLine("2"); return; } if (channel == null) { Console.WriteLine("Aucune chaîne n'a été trouvée"); return; } IAudioClient audioClient = await channel.ConnectAsync(); if (ConnectedChannels.TryAdd(guild.Id, audioClient)) { Console.WriteLine(" La connexion été effectuée sur " + guild.Name); } else { await ReplyAsync("Connexion echouée"); } Console.WriteLine("\n------------------------CONNEXION CHANNEL AUDIO-----------------------------------------\n"); PropertyInfo[] infos = audioClient.GetType().GetProperties(); foreach (var i in infos) { Console.WriteLine(i.Name + " : " + i.GetValue(audioClient, null)); } } catch (Exception ex) { Console.WriteLine(ex); } }
public async Task JoinAudio(IGuild guild, IVoiceChannel channel) { try { if (ConnectedChannels.TryGetValue(guild.Id, out client)) { Console.WriteLine("1"); return; } if (channel.Guild.Id != guild.Id) { Console.WriteLine("2"); return; } if (channel == null) { Console.WriteLine("You need to be in a voice channel, or pass one as an argument."); return; } IAudioClient audioClient = await channel.ConnectAsync(); if (ConnectedChannels.TryAdd(guild.Id, audioClient)) { // If you add a method to log happenings from this service, // you can uncomment these commented lines to make use of that. //Console.WriteLine("Connected to voice on {0}.", guild.Name); Console.WriteLine(" La connexion été effectuée sur " + guild.Name); } Console.WriteLine("\n------------------------CONNEXION CHANNEL AUDIO-----------------------------------------\n"); PropertyInfo[] infos = audioClient.GetType().GetProperties(); foreach (var i in infos) { Console.WriteLine(i.Name + " : " + i.GetValue(audioClient, null)); } } catch (Exception ex) { Console.WriteLine(ex); } }