Make changes per feedback, remove invocations of GuildMemberUpdated

Nickname changes/role changes are no longer sent over PRESENCE_UPDATE, making it obsolete to check for changes there.
This commit is contained in:
Christopher F
2016-12-03 21:11:47 -05:00
parent deafa3d755
commit 8db026c0fe
2 changed files with 3 additions and 14 deletions

View File

@@ -1439,15 +1439,12 @@ namespace Discord.WebSocket
}
SocketPresence beforePresence;
SocketGuildUser beforeGuild;
SocketGlobalUser beforeGlobal;
var user = guild.GetUser(data.User.Id);
if (user != null)
{
beforePresence = user.Presence.Clone();
beforeGlobal = user.GlobalUser.Clone();
beforeGuild = user.Clone();
user.Update(State, data);
}
else
@@ -1455,19 +1452,14 @@ namespace Discord.WebSocket
beforePresence = new SocketPresence(UserStatus.Offline, null);
user = guild.AddOrUpdateUser(data);
beforeGlobal = user.GlobalUser.Clone();
beforeGuild = user.Clone();
}
await _userPresenceUpdatedEvent.InvokeAsync(guild, user, beforePresence, user.Presence).ConfigureAwait(false);
if (data.Roles.IsSpecified || data.Nick.IsSpecified)
{
await _guildMemberUpdatedEvent.InvokeAsync(beforeGuild, user).ConfigureAwait(false);
}
if (data.User.Username.IsSpecified || data.User.Avatar.IsSpecified)
{
await _userUpdatedEvent.InvokeAsync(beforeGlobal, user).ConfigureAwait(false);
return;
}
await _userPresenceUpdatedEvent.InvokeAsync(guild, user, beforePresence, user.Presence).ConfigureAwait(false);
}
else
{

View File

@@ -88,14 +88,11 @@ namespace Discord.WebSocket
internal override void Update(ClientState state, PresenceModel model)
{
base.Update(state, model);
GlobalUser.Update(state, model.User);
if (model.Roles.IsSpecified)
UpdateRoles(model.Roles.Value);
if (model.Nick.IsSpecified)
Nickname = model.Nick.Value;
if (model.User.Username.IsSpecified)
GlobalUser.Username = model.User.Username.Value;
if (model.User.Avatar.IsSpecified)
GlobalUser.AvatarId = model.User.Avatar.Value;
}
private void UpdateRoles(ulong[] roleIds)
{