Beispiel #1
0
        private async Task <bool> PlayUrl(Uri url, string name)
        {
            var user    = Context.Message.Author as IGuildUser;
            var channel = user?.VoiceChannel;

            if (channel == null)
            {
                await ReplyAsync("Can't find voice channel.");

                return(false);
            }

            if (url == null)
            {
                await ReplyAsync("Can't find url for episode.");

                return(false);
            }

            if (!await _speaker.IsPlayingAsync())
            {
                var audio = await channel.ConnectAsync();

                await _client.SetGameAsync(name);

                await _client.SetStatusAsync(UserStatus.Online);

                await _speaker.PlayUrlAsync(url, audio);

                return(true);
            }

            return(false);
        }