private async Task OnGuildMemberAdd(DiscordGuildMemberPacket arg) { try { DiscordGuildPacket guild = await _discordClient.GetGuildAsync(arg.GuildId); if (guild.Members == null) { guild.Members = new List <DiscordGuildMemberPacket>(); } int index = guild.Members.FindIndex(x => x.UserId == arg.UserId); if (index != -1) { guild.Members.RemoveAt(index); } guild.Members.Add( await _discordClient.GetGuildUserAsync(arg.UserId, arg.GuildId) ); var cache = _cacheClient.Get; await cache.UpsertAsync($"discord:guild:{arg.GuildId}:user:{arg.UserId}", arg); await cache.UpsertAsync($"discord:guild:{arg.GuildId}", guild); } catch (Exception e) { Log.Trace(e.ToString()); } }
private async Task OnGuildMemberAdd(DiscordGuildMemberPacket arg) { DiscordGuildPacket guild = await _discordClient.GetGuildAsync(arg.GuildId); if (guild.Members == null) { guild.Members = new List <DiscordGuildMemberPacket>(); } int index = guild.Members.FindIndex(x => x.UserId == arg.UserId); if (index != -1) { guild.Members.RemoveAt(index); } guild.Members.Add( await _discordClient.GetGuildUserAsync(arg.UserId, arg.GuildId) ); await _cacheClient.AddAsync($"discord:guild:{arg.GuildId}:user:{arg.UserId}", arg); await _cacheClient.AddAsync($"discord:guild:{arg.GuildId}", guild); }
public async Task <IDiscordGuildUser> GetGuildUserAsync(ulong id, ulong guildId) => new DiscordGuildUser( await _apiClient.GetGuildUserAsync(id, guildId), this );