예제 #1
0
        public async Task Update(NixChannel channel)
        {
            if (await Store(channel))
            {
                return;
            }

            await storage.UpdateAsync(channel);
        }
예제 #2
0
        public async Task <bool> Store(NixChannel channel)
        {
            if (await storage.ExistsAsync <NixChannel>(CreateProperties(channel)))
            {
                return(false);
            }

            await storage.InsertAsync(channel);

            return(true);
        }
예제 #3
0
        public async Task <bool> Remove(NixChannel channel)
        {
            if (!await storage.ExistsAsync <NixChannel>(CreateProperties(channel)))
            {
                return(false);
            }

            await storage.DeleteAsync <NixChannel>(CreateProperties(channel));

            return(true);
        }
예제 #4
0
        public async Task <NixChannel> Get(SocketGuildChannel channel)
        {
            NixChannel nixChannel = await Get(channel.Id, channel.Guild.Id);

            if (nixChannel is null)
            {
                nixChannel = channel.GetNixChannel();
                await Store(nixChannel);

                return(nixChannel);
            }

            return(nixChannel);
        }
예제 #5
0
 private object CreateProperties(NixChannel channel)
 {
     return(new { Id = channel.Id.ToString(), GuildId = channel.GuildId.ToString() });
 }