Fix incoming users not getting cached

This commit is contained in:
Noikoio 2017-12-08 13:52:32 -08:00
parent 9cfdeba8be
commit 33e893e278

View file

@ -31,7 +31,7 @@ namespace Noikoio.RegexBot.Module.EntityCache
client.GuildAvailable += Client_GuildAvailable; client.GuildAvailable += Client_GuildAvailable;
client.GuildUpdated += Client_GuildUpdated; client.GuildUpdated += Client_GuildUpdated;
client.GuildMemberUpdated += Client_GuildMemberUpdated; client.GuildMemberUpdated += Client_GuildMemberUpdated;
// it may not be necessary to handle JoinedGuild, as GuildAvailable provides this info client.UserJoined += Client_UserJoined;
} }
else else
{ {
@ -42,7 +42,8 @@ namespace Noikoio.RegexBot.Module.EntityCache
public override Task<object> ProcessConfiguration(JToken configSection) => Task.FromResult<object>(null); public override Task<object> ProcessConfiguration(JToken configSection) => Task.FromResult<object>(null);
#region Event handling #region Event handling
// Guild _and_ guild member information has become available // Guild and guild member information has become available.
// This is a very expensive operation, when joining larger guilds for the first time.
private async Task Client_GuildAvailable(SocketGuild arg) private async Task Client_GuildAvailable(SocketGuild arg)
{ {
await Task.Run(async () => await Task.Run(async () =>
@ -64,10 +65,12 @@ namespace Noikoio.RegexBot.Module.EntityCache
{ {
await Task.Run(() => UpdateGuildMember(arg2)); await Task.Run(() => UpdateGuildMember(arg2));
} }
#endregion
#region Table setup
// A new guild member has appeared
private async Task Client_UserJoined(SocketGuildUser arg)
{
await UpdateGuildMember(arg);
}
#endregion #endregion
private async Task UpdateGuild(SocketGuild g) private async Task UpdateGuild(SocketGuild g)