Fix role icon & emoji assignment. (#2416)
This commit is contained in:
@@ -23,7 +23,7 @@ namespace Discord.Rest
|
|||||||
{
|
{
|
||||||
role.Guild.Features.EnsureFeature(GuildFeature.RoleIcons);
|
role.Guild.Features.EnsureFeature(GuildFeature.RoleIcons);
|
||||||
|
|
||||||
if (args.Icon.IsSpecified && args.Emoji.IsSpecified)
|
if ((args.Icon.IsSpecified && args.Icon.Value != null) && (args.Emoji.IsSpecified && args.Emoji.Value != null))
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Emoji and Icon properties cannot be present on a role at the same time.");
|
throw new ArgumentException("Emoji and Icon properties cannot be present on a role at the same time.");
|
||||||
}
|
}
|
||||||
@@ -36,18 +36,18 @@ namespace Discord.Rest
|
|||||||
Mentionable = args.Mentionable,
|
Mentionable = args.Mentionable,
|
||||||
Name = args.Name,
|
Name = args.Name,
|
||||||
Permissions = args.Permissions.IsSpecified ? args.Permissions.Value.RawValue.ToString() : Optional.Create<string>(),
|
Permissions = args.Permissions.IsSpecified ? args.Permissions.Value.RawValue.ToString() : Optional.Create<string>(),
|
||||||
Icon = args.Icon.IsSpecified ? args.Icon.Value.Value.ToModel() : Optional<API.Image?>.Unspecified,
|
Icon = args.Icon.IsSpecified ? args.Icon.Value?.ToModel() ?? null : Optional<API.Image?>.Unspecified,
|
||||||
Emoji = args.Emoji.GetValueOrDefault()?.Name ?? Optional<string>.Unspecified
|
Emoji = args.Emoji.IsSpecified ? args.Emoji.Value?.Name ?? "" : Optional.Create<string>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (args.Icon.IsSpecified && role.Emoji != null)
|
if ((args.Icon.IsSpecified && args.Icon.Value != null) && role.Emoji != null)
|
||||||
{
|
{
|
||||||
apiArgs.Emoji = null;
|
apiArgs.Emoji = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.Emoji.IsSpecified && !string.IsNullOrEmpty(role.Icon))
|
if ((args.Emoji.IsSpecified && args.Emoji.Value != null) && !string.IsNullOrEmpty(role.Icon))
|
||||||
{
|
{
|
||||||
apiArgs.Icon = null;
|
apiArgs.Icon = Optional<API.Image?>.Unspecified;
|
||||||
}
|
}
|
||||||
|
|
||||||
var model = await client.ApiClient.ModifyGuildRoleAsync(role.Guild.Id, role.Id, apiArgs, options).ConfigureAwait(false);
|
var model = await client.ApiClient.ModifyGuildRoleAsync(role.Guild.Id, role.Id, apiArgs, options).ConfigureAwait(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user