private void button2_Click(object sender, EventArgs e)
{
CancellationTokenSource source = new CancellationTokenSource();
string music = "C:/Users/actex/Downloads/untitled.wav";
ulong channelId = 1162394653845377129; // Replace with the actual channel ID
voiceClient = new DiscordVoiceClient(client, 1162394653312696400);
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Audio files (*.ogg;*.mp3;*.wav)|*.ogg;*.mp3;*.wav|All files (*.*)|*.*";
openFileDialog.FilterIndex = 1;
openFileDialog.RestoreDirectory = true;
voiceClient.Connect(channelId, new VoiceConnectionProperties() { Muted = true });
{
try
{
while (voiceClient.State == MediaConnectionState.Ready && !source.IsCancellationRequested)
voiceClient.Microphone.Bitrate = 510000;
voiceClient.Microphone.SetSpeakingState(DiscordSpeakingFlags.Soundshare);
voiceClient.Microphone.CopyFrom(DiscordVoiceUtils.GetAudioStream(music), source.Token);
}
catch (InvalidOperationException ex) {
MessageBox.Show($"An error occurred: {ex.Message}");
}
}
}