Example #1
0
        public async Task AddNHentaiSubscription(ITextChannel chan, Subscription.SubscriptionTags tags)
        {
            string guildIdStr   = chan.GuildId.ToString();
            string channelIdStr = chan.Id.ToString();
            await R.Db(dbName).Table("Guilds").Update(R.HashMap("id", guildIdStr)
                                                      .With("nhentaiSubscription", channelIdStr)
                                                      .With("nhentaiSubscriptionTags", tags.ToStringArray())
                                                      ).RunAsync(conn);

            if (NHentaiSubscription.Any(x => x.Item1.Id == chan.Id))
            {
                NHentaiSubscription.Remove(NHentaiSubscription.Where(x => x.Item1.Id == chan.Id).ElementAt(0));
            }
            NHentaiSubscription.Add((chan, tags));
        }
Example #2
0
        public async Task <bool> RemoveNHentaiSubscription(IGuild guild)
        {
            string  guildIdStr = guild.Id.ToString();
            dynamic json       = await R.Db(dbName).Table("Guilds").Get(guildIdStr).RunAsync(conn);

            string hentai = (string)json.nhentaiSubscription;

            if (hentai == null || hentai == "0")
            {
                return(false);
            }
            await R.Db(dbName).Table("Guilds").Update(R.HashMap("id", guildIdStr)
                                                      .With("nhentaiSubscription", "0")
                                                      ).RunAsync(conn);

            var id = ulong.Parse(hentai);

            NHentaiSubscription.Remove(NHentaiSubscription.Where(x => x.Item1.Id == id).ElementAt(0));
            return(true);
        }