Browse Source

Cleaned up PR

tags/1.0-rc
RogueException 8 years ago
parent
commit
c037865b28
3 changed files with 15 additions and 7 deletions
  1. +1
    -1
      src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
  2. +1
    -1
      src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
  3. +13
    -5
      src/Discord.Net.Rest/Entities/Roles/RestRole.cs

+ 1
- 1
src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs View File

@@ -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 =>
{


+ 1
- 1
src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs View File

@@ -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();



+ 13
- 5
src/Discord.Net.Rest/Entities/Roles/RestRole.cs View File

@@ -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.");
}
}
}
}

Loading…
Cancel
Save