Added role updates via PRESENCE_UPDATE
This commit is contained in:
@@ -48,6 +48,8 @@ namespace Discord.API
|
||||
public string GameId;
|
||||
[JsonProperty("status")]
|
||||
public string Status;
|
||||
[JsonProperty("roles")] //TODO: Might be temporary
|
||||
public string[] Roles;
|
||||
}
|
||||
public class VoiceMemberInfo : MemberReference
|
||||
{
|
||||
|
||||
@@ -621,13 +621,7 @@ namespace Discord
|
||||
case "PRESENCE_UPDATE":
|
||||
{
|
||||
var data = e.Payload.ToObject<PresenceUpdateEvent>(_serializer);
|
||||
var member = _members[data.User.Id, data.GuildId];
|
||||
/*if (_config.TrackActivity)
|
||||
{
|
||||
var user = _users[data.User.Id];
|
||||
if (user != null)
|
||||
user.UpdateActivity(DateTime.UtcNow);
|
||||
}*/
|
||||
var member = _members.GetOrAdd(data.User.Id, data.GuildId);
|
||||
if (member != null)
|
||||
{
|
||||
member.Update(data);
|
||||
|
||||
@@ -95,13 +95,8 @@ namespace Discord
|
||||
Update(model.User);
|
||||
if (model.JoinedAt.HasValue)
|
||||
JoinedAt = model.JoinedAt.Value;
|
||||
|
||||
//Set roles, with the everyone role added too
|
||||
string[] newRoles = new string[model.Roles.Length + 1];
|
||||
newRoles[0] = Server.EveryoneRoleId;
|
||||
for (int i = 0; i < model.Roles.Length; i++)
|
||||
newRoles[i + 1] = model.Roles[i];
|
||||
RoleIds = newRoles;
|
||||
if (model.Roles != null)
|
||||
UpdateRoles(model.Roles);
|
||||
|
||||
UpdatePermissions();
|
||||
}
|
||||
@@ -118,6 +113,8 @@ namespace Discord
|
||||
if (model.User != null)
|
||||
Update(model.User as UserReference);
|
||||
|
||||
if (model.Roles != null)
|
||||
UpdateRoles(model.Roles);
|
||||
if (model.Status != null && Status != model.Status)
|
||||
{
|
||||
Status = model.Status;
|
||||
@@ -148,6 +145,15 @@ namespace Discord
|
||||
if (model.IsServerSuppressed != null)
|
||||
IsServerSuppressed = model.IsServerSuppressed.Value;
|
||||
}
|
||||
private void UpdateRoles(string[] roleIds)
|
||||
{
|
||||
//Set roles, with the everyone role added too
|
||||
string[] newRoles = new string[roleIds.Length + 1];
|
||||
newRoles[0] = Server.EveryoneRoleId;
|
||||
for (int i = 0; i < roleIds.Length; i++)
|
||||
newRoles[i + 1] = roleIds[i];
|
||||
RoleIds = newRoles;
|
||||
}
|
||||
|
||||
internal void UpdateActivity(DateTime? activity = null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user