A few role color fixes
This commit is contained in:
@@ -652,15 +652,18 @@ namespace Discord
|
||||
return _api.CreateRole(serverId);
|
||||
}
|
||||
|
||||
public Task EditRole(Role role, string newName)
|
||||
=> EditRole(role?.ServerId, role?.Id, newName);
|
||||
public Task EditRole(string serverId, string roleId, string name = null, PackedServerPermissions permissions = null, PackedColor color = null, bool? hoist = null)
|
||||
public Task EditRole(string roleId, string name = null, PackedServerPermissions permissions = null, PackedColor color = null, bool? hoist = null)
|
||||
=> EditRole(_roles[roleId], name: name, permissions: permissions, color: color, hoist: hoist);
|
||||
public Task EditRole(Role role, string name = null, PackedServerPermissions permissions = null, PackedColor color = null, bool? hoist = null)
|
||||
{
|
||||
CheckReady();
|
||||
if (serverId == null) throw new NullReferenceException(nameof(serverId));
|
||||
if (roleId == null) throw new NullReferenceException(nameof(roleId));
|
||||
if (role == null) throw new NullReferenceException(nameof(role));
|
||||
|
||||
return _api.EditRole(serverId, roleId, name: name, permissions: permissions?.RawValue, color: color?.RawValue, hoist: hoist);
|
||||
return _api.EditRole(role.ServerId, role.Id,
|
||||
name: name ?? role.Name,
|
||||
permissions: permissions?.RawValue ?? role.Permissions.RawValue,
|
||||
color: color?.RawValue ?? role.Color.RawValue,
|
||||
hoist: hoist ?? role.Hoist);
|
||||
}
|
||||
|
||||
public Task DeleteRole(Role role)
|
||||
|
||||
@@ -38,9 +38,10 @@ namespace Discord
|
||||
if (_isLocked)
|
||||
throw new InvalidOperationException("Unable to edit cached permissions directly, use Copy() to make an editable copy.");
|
||||
|
||||
uint original = _rawValue;
|
||||
int bit = 8 * (pos - 1);
|
||||
uint mask = (uint)((1 << bit) - 1);
|
||||
_rawValue = ((uint)value << bit) | (_rawValue & mask);
|
||||
uint mask = (uint)~(0xFF << bit);
|
||||
_rawValue = (_rawValue & mask) | ((uint)value << bit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user