Beispiel #1
0
        public async Task Stream(string url)
        {
            try
            {
                if (SongService.GetChannel() != (Context.Message.Author as IGuildUser).VoiceChannel)
                {
                    SongService.SetVoiceChannel((Context.Message.Author as IGuildUser).VoiceChannel);
                }
                var downloadAnnouncement = await ReplyAsync($"{Context.User.Mention} attempting to stream {url}");

                var stream = await YoutubeDownloadService.GetLivestreamData(url);

                await downloadAnnouncement.DeleteAsync();

                if (stream == null)
                {
                    await ReplyAsync($"{Context.User.Mention} unable to stream");

                    return;
                }

                stream.Requester = Context.User.Mention;
                stream.Url       = url;


                await ReplyAsync($"{Context.User.Mention} queued **{stream.Title}** | `{stream.DurationString}` | {url}");

                SongService.Queue(stream);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error while processing song requet: {e}");
            }
        }
Beispiel #2
0
        private async Task PlayMusic(string url, int speedModifier)
        {
            try
            {
                if (SongService.GetChannel() != (Context.Message.Author as IGuildUser).VoiceChannel)
                {
                    SongService.SetVoiceChannel((Context.Message.Author as IGuildUser).VoiceChannel);
                }
                var downloadAnnouncement = await ReplyAsync($"{Context.User.Mention} attempting to download {url}");

                var video = await YoutubeDownloadService.DownloadVideo(url);

                await downloadAnnouncement.DeleteAsync();

                if (video == null)
                {
                    await ReplyAsync($"{Context.User.Mention} unable to queue song");

                    return;
                }

                video.Requester = Context.User.Mention;
                video.Speed     = speedModifier;

                await ReplyAsync($"{Context.User.Mention} queued **{video.Title}** | `{TimeSpan.FromSeconds(video.Duration)}` | {url}");

                SongService.Queue(video);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error while processing song request: {e}");
            }
        }