-
Notifications
You must be signed in to change notification settings - Fork 33
Simple Voice Echo Client
Voice now almost works. To test, you can do a simple voice Echo Client one on one with your bot.
It's necessary to first connect to a voice channel in Discord. In the test program, I do the following.
string[] split = e.message.content.Split(new char[] { ' ' }, 2);
if(split.Length > 1)
{
DiscordChannel voiceToJoin = e.Channel.parent.channels.Find(x => x.name.ToLower() == split[1].ToLower() && x.type == "voice");
if (voiceToJoin != null)
client.ConnectToVoiceChannel(voiceToJoin);
}
The following snippet will is triggered inside of the client.OnMessageReceived
event and finds a DiscordChannel
based on the given name as an argument.
After client.ConnectToVoiceChannel
is run, your bot should be connected to voice. There is a new event called AudioPacketReceived
that is triggered well, whenever an audio packet is received. The DiscordAudioPacketEventArgs
class houses 3 objects.
DiscordAudioPacket
DiscordChannel
DiscordMember
All we really care about for right now is the DiscordAudioPacket
. From here, echoing is super easy. client.EchoPacket
wraps the voice client's internal packet echoing function and you just need to call that and pass the EventArgs
's audio packet. Voila! Your bot should echo your voice back at you!