private async Task <bool> UnsubscribeWaiter(SocketMessage socketMessage, object o) { string content = socketMessage.Content; if (!int.TryParse(content, out int n)) { return(false); } if (!(o is List <AnimeGuildModel> subscribedAnime)) { return(false); } if (n < 1 || n > subscribedAnime.Count + 1) { return(false); } n--; var a = subscribedAnime[n]; if (!DatabaseSubscriber.UnsubscribeFromAnime(ref a, socketMessage.Author.Id)) { await ReplyAsync($"{Context.User.Mention}, oh no! Something went wrong."); return(false); } await ReplyAsync( $"{Context.User.Mention}. You have unsubscribed from {a.AnimeTitle.EnglishTitle ?? a.AnimeTitle.RomajiTitle}!"); return(true); }
private async Task <bool> WaiterFunction(SocketMessage message, object @params) { string content = message.Content; int n; if (!int.TryParse(content, out n)) { return(false); } if (!(@params is AniListModel[] animeList)) { return(false); } if (n < 1 || n > animeList.Length + 1) { return(false); } n--; var anim = new AnimeGuildModel() { AnimeID = animeList[n].ID, Anime = animeList[n], AnimeTitle = animeList[n].Title, Guild = ((IGuildChannel)message.Channel).GuildId, Channel = message.Channel.Id, MinAnnounceQuality = Quality.SevenTwentyP, LastAnnouncedEpisode = 0, WantedSubgroupTitle = new [] { "horriblesubs", "erai-raws" } }; if (DatabaseSubscriber.SubscribeToAnime(ref anim, message.Author.Id)) { Embed embed = CreateEmbed(anim, message); var succeedMessage = await ReplyAsync("", embed : embed); await succeedMessage.AddReactionAsync(new Emoji("❤")); var guildUserWaiter = new GuildUserWaiter(Context.Guild.Id, Context.User.Id, async(messageId, reaction, anime) => { if (reaction.Emote.Name != "❤") { return(false); } var a = anim; DatabaseSubscriber.SubscribeToAnime(ref a, reaction.UserId); try { var e = CreateEmbed(a, message); await succeedMessage.ModifyAsync(x => x.Embed = e); } catch (Exception e) { Console.WriteLine(e); } return(false); }, anim, false); guildUserWaiter.ParentMessage = succeedMessage; ResponseModule.ResponseModule.AddWaiter(guildUserWaiter); } else { await ReplyAsync($"{message.Author.Mention} ばか! (´-ω-`). You already subscribed to {anim.AnimeTitle.EnglishTitle ?? anim.AnimeTitle.RomajiTitle}."); } return(true); }