Browse Source

Fix role icon & emoji assignment. (#2416)

tags/3.8.0
Armano den Boef GitHub 2 years ago
parent
commit
b6b5e95f48
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions
  1. +7
    -7
      src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs

+ 7
- 7
src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs View File

@@ -23,7 +23,7 @@ namespace Discord.Rest
{
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.");
}
@@ -36,18 +36,18 @@ namespace Discord.Rest
Mentionable = args.Mentionable,
Name = args.Name,
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,
Emoji = args.Emoji.GetValueOrDefault()?.Name ?? Optional<string>.Unspecified
Icon = args.Icon.IsSpecified ? args.Icon.Value?.ToModel() ?? null : Optional<API.Image?>.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);


Loading…
Cancel
Save