private async Task UpdateDb(string name, string code) { var info = await GetCodeInfoForName(name); info.Code = code; await _container.Upsert(info); }
private async Task <IWebhook> GetWebhook(ITextChannel channel, IGuildUser user) { EmojiWebhook found = (await _container.Query($"SELECT * FROM db WHERE db.UserId = {user.Id}")).FirstOrDefault(); if (found == null) { var webhook = await channel.CreateWebhookAsync(user.Nickname ?? user.Username); EmojiWebhook entry = new EmojiWebhook() { UserId = user.Id, ChannelsAndWebhooks = new Dictionary <ulong, ulong>() { [channel.Id] = webhook.Id } }; await _container.Insert(entry); return(webhook); } else { if (found.ChannelsAndWebhooks.TryGetValue(channel.Id, out var value)) { return(await channel.GetWebhookAsync(value)); } else { var webhook = await channel.CreateWebhookAsync(user.Nickname ?? user.Username); found.ChannelsAndWebhooks.Add(channel.Id, webhook.Id); await _container.Upsert(found); return(webhook); } } }
private Task UpdateDb(PollInfo info) => _container.Upsert(info);