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