private async Task OnConnected() { var recordedGuilds = await DynamoSystem.ScanItemAsync <GuildInfo>(); var guildsToUpdate = new List <GuildInfo>(); foreach (var rGuild in recordedGuilds) { var match = this._discord.Guilds.SingleOrDefault(x => x.Id.ToString() == rGuild.GuildGuid); if (match == null) { await DynamoSystem.DeleteItemAsync(rGuild); continue; } rGuild.GuildName = match.Name; guildsToUpdate.Add(rGuild); } foreach (var uGuild in guildsToUpdate) { await DynamoSystem.UpdateItemAsync(uGuild); } }
private async Task OnGuildUpdate(SocketGuild arg1, SocketGuild arg2) { var guildInfo = await DynamoSystem.GetItemAsync <GuildInfo>(arg1.Id); guildInfo.GuildName = arg2.Name; await DynamoSystem.UpdateItemAsync(guildInfo); }
private static async Task OnGuildUpdatedAsync([NotNull] SocketGuild arg1, [NotNull] SocketGuild arg2) { var origGuildId = arg1.Id; var guild = await DynamoSystem.GetItemAsync <GuildInfo>(origGuildId).ConfigureAwait(false); if (guild != null) { guild.GuildGuid = arg2.Id.ToString(); guild.GuildName = arg2.Name; await DynamoSystem.UpdateItemAsync(guild).ConfigureAwait(false); } }