public async Task YoutubeAsync([Remainder] string query = "") { Utilities utilities = new Utilities(Context.Guild); string avatar = Context.Message.Author.GetAvatarUrl() ?? Context.Message.Author.GetDefaultAvatarUrl(); if (query == "") { await ReplyAsync(Utilities.GetAlert("PLAY_NULL_QUERY")); return; } var searchList = AudioService.GetYoutubeAsync(query, Context.Guild.Id, (Context.User as IVoiceState).VoiceChannel); YoutubeVideo video = new YoutubeVideo(); video.SetMultipleVideosInfo(Context.Guild, video, searchList); EmbedBuilder builder = new EmbedBuilder(); builder .WithAuthor(Context.Message.Author.Username, avatar) .WithThumbnailUrl("http://i65.tinypic.com/2uqk3yr.png") .WithTitle(Utilities.GetAlert("YOUTUBE_FILMEMBED")) .WithDescription($"{string.Join("\n", video.videosList)}") .WithColor(Color.Red); await ReplyAsync("", false, builder.Build()); var response = await NextMessageAsync(true, true, timeout : TimeSpan.FromSeconds(30)); string answer = response.ToString(); string[] wholeMsg = answer.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); int choose = InteractiveUtil.ConvertToInt(answer); if (Utilities.GetAlert("answerCancel").Contains(wholeMsg[0])) { await ReplyAsync(Utilities.GetAlert("PLAY_CANCEL")); return; } if (choose == 0) { return; } choose = choose - 1; string song = $"https://www.youtube.com/watch?v={video.link[choose]}"; await AudioService.PlayAsync(Context, song, choose, video); return; }
public async Task EggplantAsync() { Utilities utilities = new Utilities(Context.Guild); string avatar = Context.Message.Author.GetAvatarUrl() ?? Context.Message.Author.GetDefaultAvatarUrl(); EmbedBuilder builderConfirm = new EmbedBuilder(); builderConfirm .WithAuthor(Context.Message.Author.Username, avatar) .WithDescription(Utilities.GetAlert("EGGPLANT_CONFIRM")) .WithFooter(Utilities.GetAlert("INTERACTIVE_CONFIRM_YES_OR_NO")); await ReplyAsync("", false, builderConfirm.Build()); DateTime timeStart = DateTime.Now; SocketMessage response = await NextMessageAsync(true, true, timeout : TimeSpan.FromSeconds(40)); bool completed = await InteractiveUtil.CheckAnswerAsync(Context.Guild, response, Context.Channel); if (completed == true) { return; } else { TimeSpan timePassed; do { // In case that a bot doesn't receive a response within 30 seconds, // it stops awaiting it and responseSecond takes the value null var responseSecond = await NextMessageAsync(true, true, timeout : TimeSpan.FromSeconds(30)); if (responseSecond == null) { await ReplyAsync(Utilities.GetAlert("INTERACTIVE_TIMEOUT")); return; } // SocketMessage to string string answerSecond = responseSecond.ToString(); answerSecond = answerSecond.ToLower(); string[] wholeMsg = answerSecond.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); wholeMsg[0] = Regex.Replace(wholeMsg[0], "[*]", string.Empty); if (GlobalVar.allCommandsEng.Contains(wholeMsg[0]) || GlobalVar.allCommandsPl.Contains(wholeMsg[0]) || answerSecond.Contains("send") && answerSecond.Contains("nudes") || answerSecond.Contains("set") && answerSecond.Contains("game")) { return; } if (Utilities.GetAlert("answerTrue").Contains(wholeMsg[0])) { EmbedBuilder builderYes = new EmbedBuilder(); builderYes .WithImageUrl("https://cdn.discordapp.com/attachments/374222963999768578/469830447254339586/EggplantHand_Animated.gif"); await ReplyAsync("", false, builderYes.Build()); return; } else if (Utilities.GetAlert("answerFalse").Contains(wholeMsg[0])) { await ReplyAsync(Utilities.GetAlert("EGGPLANT_NO")); return; } else { DateTime timeEnd = DateTime.Now; timePassed = timeEnd - timeStart; } } while (timePassed.TotalSeconds < 30); await ReplyAsync(Utilities.GetAlert("INTERACTIVE_TIMEOUT")); return; } }