public async Task AddAnimeSubscription(ITextChannel chan) { string guildIdStr = chan.GuildId.ToString(); string channelIdStr = chan.Id.ToString(); await R.Db(dbName).Table("Guilds").Update(R.HashMap("id", guildIdStr) .With("animeSubscription", channelIdStr) ).RunAsync(conn); if (AnimeSubscription.Any(x => x.Item1.Id == chan.Id)) { AnimeSubscription.Remove(AnimeSubscription.Where(x => x.Item1.Id == chan.Id).ElementAt(0)); } AnimeSubscription.Add((chan, null)); }
public async Task <bool> RemoveAnimeSubscription(IGuild guild) { string guildIdStr = guild.Id.ToString(); dynamic json = await R.Db(dbName).Table("Guilds").Get(guildIdStr).RunAsync(conn); string anime = (string)json.animeSubscription; if (anime == null || anime == "0") { return(false); } await R.Db(dbName).Table("Guilds").Update(R.HashMap("id", guildIdStr) .With("animeSubscription", "0") ).RunAsync(conn); var id = ulong.Parse(anime); AnimeSubscription.Remove(AnimeSubscription.Where(x => x.Item1.Id == id).ElementAt(0)); return(true); }