Ejemplo n.º 1
0
        private async Task UpdateDb(string name, string code)
        {
            var info = await GetCodeInfoForName(name);

            info.Code = code;
            await _container.Upsert(info);
        }
Ejemplo n.º 2
0
        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);
                }
            }
        }
Ejemplo n.º 3
0
 private Task UpdateDb(PollInfo info) => _container.Upsert(info);