Solves Issue 342, but there might be a cleaner way to do this that doesnt make you end up with a IGuild in the RestRole.
This commit is contained in:
@@ -142,7 +142,7 @@ namespace Discord.Rest
|
|||||||
if (name == null) throw new ArgumentNullException(nameof(name));
|
if (name == null) throw new ArgumentNullException(nameof(name));
|
||||||
|
|
||||||
var model = await client.ApiClient.CreateGuildRoleAsync(guild.Id, options).ConfigureAwait(false);
|
var model = await client.ApiClient.CreateGuildRoleAsync(guild.Id, options).ConfigureAwait(false);
|
||||||
var role = RestRole.Create(client, model);
|
var role = RestRole.Create(guild, client, model);
|
||||||
|
|
||||||
await role.ModifyAsync(x =>
|
await role.ModifyAsync(x =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ namespace Discord.Rest
|
|||||||
if (model.Roles != null)
|
if (model.Roles != null)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < model.Roles.Length; i++)
|
for (int i = 0; i < model.Roles.Length; i++)
|
||||||
roles[model.Roles[i].Id] = RestRole.Create(Discord, model.Roles[i]);
|
roles[model.Roles[i].Id] = RestRole.Create(this, Discord, model.Roles[i]);
|
||||||
}
|
}
|
||||||
_roles = roles.ToImmutable();
|
_roles = roles.ToImmutable();
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace Discord.Rest
|
|||||||
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
|
||||||
public class RestRole : RestEntity<ulong>, IRole
|
public class RestRole : RestEntity<ulong>, IRole
|
||||||
{
|
{
|
||||||
public RestGuild Guild { get; }
|
public IGuild Guild { get; }
|
||||||
public Color Color { get; private set; }
|
public Color Color { get; private set; }
|
||||||
public bool IsHoisted { get; private set; }
|
public bool IsHoisted { get; private set; }
|
||||||
public bool IsManaged { get; private set; }
|
public bool IsManaged { get; private set; }
|
||||||
@@ -22,13 +22,14 @@ namespace Discord.Rest
|
|||||||
public bool IsEveryone => Id == Guild.Id;
|
public bool IsEveryone => Id == Guild.Id;
|
||||||
public string Mention => MentionUtils.MentionRole(Id);
|
public string Mention => MentionUtils.MentionRole(Id);
|
||||||
|
|
||||||
internal RestRole(BaseDiscordClient discord, ulong id)
|
internal RestRole(IGuild guild, BaseDiscordClient discord, ulong id)
|
||||||
: base(discord, id)
|
: base(discord, id)
|
||||||
{
|
{
|
||||||
|
Guild = guild;
|
||||||
}
|
}
|
||||||
internal static RestRole Create(BaseDiscordClient discord, Model model)
|
internal static RestRole Create(IGuild guild, BaseDiscordClient discord, Model model)
|
||||||
{
|
{
|
||||||
var entity = new RestRole(discord, model.Id);
|
var entity = new RestRole(guild, discord, model.Id);
|
||||||
entity.Update(model);
|
entity.Update(model);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user