async Task _GetSCTracks(MessageEventArgs e, string[] Args, int Number) { string temp = Args[1]; for (int i = 3; i < Args.Count(); i++) { temp += " " + Args[i]; } trackResults SCTracks = await SCClient.SearchTrack(temp); if (SCTracks.Count == 0) { await e.Channel.SendMessage("Sorry, but no Matches were found!"); } for (int i = 0; i < Number && i < SCTracks.Count; i++) { await e.Channel.SendMessage((i + 1) + "." + SCTracks[i]); Thread.Sleep(20); } }
async Task _SoundCloudStream(MessageEventArgs e, string[] Args, ulong ServerLight, Channel testout) { string temp = Args[1]; for (int i = 3; i < Args.Count(); i++) { temp += " " + Args[i]; } trackResults SCTracks = await SCClient.SearchTrack(temp); int j = 0; while (j < SCTracks.Count && SCTracks[j]?.streamable == false) { j++; } if (j < SCTracks.Count) { Stream OS = new MemoryStream(); Stream S = await SCClient.GetStream(SCTracks[j].id, _DiscordClient.GetService <AudioService>().Config.Channels); using (WaveStream waveStream = WaveFormatConversionStream.CreatePcmStream(new Mp3FileReader(S))) using (WaveFileWriter waveFileWriter = new WaveFileWriter(OS, waveStream.WaveFormat)) { byte[] bytes = new byte[waveStream.Length]; waveStream.Position = 0; waveStream.Read(bytes, 0, (int)OS.Length); waveFileWriter.Write(bytes, 0, bytes.Length); waveFileWriter.Flush(); } await SendAudioBuffer(ServerLight, testout, OS); S.Dispose(); OS.Dispose(); } }