Merged UserPresenceUpdated into UserUpdated
This commit is contained in:
@@ -297,7 +297,7 @@ namespace Discord.WebSocket
|
|||||||
client.UserBanned += (user, guild) => _userBannedEvent.InvokeAsync(user, guild);
|
client.UserBanned += (user, guild) => _userBannedEvent.InvokeAsync(user, guild);
|
||||||
client.UserUnbanned += (user, guild) => _userUnbannedEvent.InvokeAsync(user, guild);
|
client.UserUnbanned += (user, guild) => _userUnbannedEvent.InvokeAsync(user, guild);
|
||||||
client.UserUpdated += (oldUser, newUser) => _userUpdatedEvent.InvokeAsync(oldUser, newUser);
|
client.UserUpdated += (oldUser, newUser) => _userUpdatedEvent.InvokeAsync(oldUser, newUser);
|
||||||
client.UserPresenceUpdated += (guild, user, oldPresence, newPresence) => _userPresenceUpdatedEvent.InvokeAsync(guild, user, oldPresence, newPresence);
|
client.GuildMemberUpdated += (oldUser, newUser) => _guildMemberUpdatedEvent.InvokeAsync(oldUser, newUser);
|
||||||
client.UserVoiceStateUpdated += (user, oldVoiceState, newVoiceState) => _userVoiceStateUpdatedEvent.InvokeAsync(user, oldVoiceState, newVoiceState);
|
client.UserVoiceStateUpdated += (user, oldVoiceState, newVoiceState) => _userVoiceStateUpdatedEvent.InvokeAsync(user, oldVoiceState, newVoiceState);
|
||||||
client.CurrentUserUpdated += (oldUser, newUser) => _selfUpdatedEvent.InvokeAsync(oldUser, newUser);
|
client.CurrentUserUpdated += (oldUser, newUser) => _selfUpdatedEvent.InvokeAsync(oldUser, newUser);
|
||||||
client.UserIsTyping += (oldUser, newUser) => _userIsTypingEvent.InvokeAsync(oldUser, newUser);
|
client.UserIsTyping += (oldUser, newUser) => _userIsTypingEvent.InvokeAsync(oldUser, newUser);
|
||||||
|
|||||||
@@ -185,12 +185,6 @@ namespace Discord.WebSocket
|
|||||||
remove { _guildMemberUpdatedEvent.Remove(value); }
|
remove { _guildMemberUpdatedEvent.Remove(value); }
|
||||||
}
|
}
|
||||||
private readonly AsyncEvent<Func<SocketGuildUser, SocketGuildUser, Task>> _guildMemberUpdatedEvent = new AsyncEvent<Func<SocketGuildUser, SocketGuildUser, Task>>();
|
private readonly AsyncEvent<Func<SocketGuildUser, SocketGuildUser, Task>> _guildMemberUpdatedEvent = new AsyncEvent<Func<SocketGuildUser, SocketGuildUser, Task>>();
|
||||||
public event Func<Optional<SocketGuild>, SocketUser, SocketPresence, SocketPresence, Task> UserPresenceUpdated
|
|
||||||
{
|
|
||||||
add { _userPresenceUpdatedEvent.Add(value); }
|
|
||||||
remove { _userPresenceUpdatedEvent.Remove(value); }
|
|
||||||
}
|
|
||||||
private readonly AsyncEvent<Func<Optional<SocketGuild>, SocketUser, SocketPresence, SocketPresence, Task>> _userPresenceUpdatedEvent = new AsyncEvent<Func<Optional<SocketGuild>, SocketUser, SocketPresence, SocketPresence, Task>>();
|
|
||||||
public event Func<SocketUser, SocketVoiceState, SocketVoiceState, Task> UserVoiceStateUpdated
|
public event Func<SocketUser, SocketVoiceState, SocketVoiceState, Task> UserVoiceStateUpdated
|
||||||
{
|
{
|
||||||
add { _userVoiceStateUpdatedEvent.Add(value); }
|
add { _userVoiceStateUpdatedEvent.Add(value); }
|
||||||
|
|||||||
@@ -1318,46 +1318,16 @@ namespace Discord.WebSocket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketPresence beforePresence;
|
|
||||||
SocketGlobalUser beforeGlobal;
|
|
||||||
var user = guild.GetUser(data.User.Id);
|
var user = guild.GetUser(data.User.Id);
|
||||||
if (user != null)
|
if (user == null)
|
||||||
{
|
guild.AddOrUpdateUser(data);
|
||||||
beforePresence = user.Presence.Clone();
|
|
||||||
beforeGlobal = user.GlobalUser.Clone();
|
|
||||||
user.Update(State, data);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
beforePresence = new SocketPresence(UserStatus.Offline, null);
|
|
||||||
user = guild.AddOrUpdateUser(data);
|
|
||||||
beforeGlobal = user.GlobalUser.Clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
{
|
|
||||||
var channel = State.GetChannel(data.User.Id);
|
|
||||||
if (channel != null)
|
|
||||||
{
|
|
||||||
var user = channel.GetUser(data.User.Id);
|
|
||||||
var beforePresence = user.Presence.Clone();
|
|
||||||
var before = user.GlobalUser.Clone();
|
|
||||||
user.Update(State, data);
|
|
||||||
|
|
||||||
await _userPresenceUpdatedEvent.InvokeAsync(Optional.Create<SocketGuild>(), user, beforePresence, user.Presence).ConfigureAwait(false);
|
var globalUser = State.GetUser(data.User.Id);
|
||||||
if (data.User.Username.IsSpecified || data.User.Avatar.IsSpecified)
|
var before = globalUser.Clone();
|
||||||
{
|
globalUser.Update(State, data);
|
||||||
await _userUpdatedEvent.InvokeAsync(before, user).ConfigureAwait(false);
|
|
||||||
}
|
await _userUpdatedEvent.InvokeAsync(before, globalUser).ConfigureAwait(false);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "TYPING_START":
|
case "TYPING_START":
|
||||||
|
|||||||
Reference in New Issue
Block a user