Cleaned up PR
This commit is contained in:
@@ -142,7 +142,7 @@ namespace Discord.Rest
|
||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||
|
||||
var model = await client.ApiClient.CreateGuildRoleAsync(guild.Id, options).ConfigureAwait(false);
|
||||
var role = RestRole.Create(guild, client, model);
|
||||
var role = RestRole.Create(client, guild, model);
|
||||
|
||||
await role.ModifyAsync(x =>
|
||||
{
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace Discord.Rest
|
||||
if (model.Roles != null)
|
||||
{
|
||||
for (int i = 0; i < model.Roles.Length; i++)
|
||||
roles[model.Roles[i].Id] = RestRole.Create(this, Discord, model.Roles[i]);
|
||||
roles[model.Roles[i].Id] = RestRole.Create(Discord, this, model.Roles[i]);
|
||||
}
|
||||
_roles = roles.ToImmutable();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Discord.Rest
|
||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||
public class RestRole : RestEntity<ulong>, IRole
|
||||
{
|
||||
public IGuild Guild { get; }
|
||||
internal IGuild Guild { get; }
|
||||
public Color Color { get; private set; }
|
||||
public bool IsHoisted { get; private set; }
|
||||
public bool IsManaged { get; private set; }
|
||||
@@ -22,14 +22,14 @@ namespace Discord.Rest
|
||||
public bool IsEveryone => Id == Guild.Id;
|
||||
public string Mention => MentionUtils.MentionRole(Id);
|
||||
|
||||
internal RestRole(IGuild guild, BaseDiscordClient discord, ulong id)
|
||||
internal RestRole(BaseDiscordClient discord, IGuild guild, ulong id)
|
||||
: base(discord, id)
|
||||
{
|
||||
Guild = guild;
|
||||
}
|
||||
internal static RestRole Create(IGuild guild, BaseDiscordClient discord, Model model)
|
||||
internal static RestRole Create(BaseDiscordClient discord, IGuild guild, Model model)
|
||||
{
|
||||
var entity = new RestRole(guild, discord, model.Id);
|
||||
var entity = new RestRole(discord, guild, model.Id);
|
||||
entity.Update(model);
|
||||
return entity;
|
||||
}
|
||||
@@ -56,6 +56,14 @@ namespace Discord.Rest
|
||||
private string DebuggerDisplay => $"{Name} ({Id})";
|
||||
|
||||
//IRole
|
||||
IGuild IRole.Guild => Guild;
|
||||
IGuild IRole.Guild
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Guild != null)
|
||||
return Guild;
|
||||
throw new InvalidOperationException("Unable to return this entity's parent unless it was fetched through that object.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user