private async Task UpdateGuildUserCountAsync(IDiscordGuild guild) { using (MikiContext context = new MikiContext()) { GuildUser g = await GuildUser.GetAsync(context, guild); g.UserCount = await guild.GetUserCountAsync(); await context.SaveChangesAsync(); } }
public static async Task <GuildUser> CreateAsync(MikiContext context, IDiscordGuild guild) { long id = guild.Id.ToDbLong(); int userCount = await guild.GetUserCountAsync(); int value = await context.LocalExperience .Where(x => x.ServerId == id) .SumAsync(x => x.Experience); var guildUser = new GuildUser(); guildUser.Name = guild.Name; guildUser.Id = id; guildUser.Experience = value; guildUser.UserCount = userCount; guildUser.LastRivalRenewed = Utils.MinDbValue; guildUser.MinimalExperienceToGetRewards = 100; GuildUser outputGuildUser = context.GuildUsers.Add(guildUser).Entity; await context.SaveChangesAsync(); return(outputGuildUser); }