diff --git a/docs/guides/dependency_injection/injection.md b/docs/guides/dependency_injection/injection.md
index c7d40c479..85a77476f 100644
--- a/docs/guides/dependency_injection/injection.md
+++ b/docs/guides/dependency_injection/injection.md
@@ -16,7 +16,7 @@ This can be done through property or constructor.
Services can be injected from the constructor of the class.
This is the preferred approach, because it automatically locks the readonly field in place with the provided service and isn't accessible outside of the class.
-[!code-csharp[Property Injection(samples/property-injecting.cs)]]
+[!code-csharp[Constructor Injection](samples/ctor-injecting.cs)]
## Injecting through properties
diff --git a/docs/guides/int_framework/intro.md b/docs/guides/int_framework/intro.md
index 5cf38bff1..37c579159 100644
--- a/docs/guides/int_framework/intro.md
+++ b/docs/guides/int_framework/intro.md
@@ -294,7 +294,7 @@ By nesting commands inside a module that is tagged with [GroupAttribute] you can
> [!NOTE]
> To not use the command group's name as a prefix for component or modal interaction's custom id set `ignoreGroupNames` parameter to `true` in classes with [GroupAttribute]
>
-> However, you have to be careful to prevent overlapping ids of buttons and modals
+> However, you have to be careful to prevent overlapping ids of buttons and modals.
[!code-csharp[Command Group Example](samples/intro/groupmodule.cs)]
@@ -346,10 +346,13 @@ Command registration methods can only be used after the gateway client is ready
Methods like `AddModulesToGuildAsync()`, `AddCommandsToGuildAsync()`, `AddModulesGloballyAsync()` and `AddCommandsGloballyAsync()`
can be used to register cherry picked modules or commands to global/guild scopes.
+> [!NOTE]
+> [DontAutoRegisterAttribute] can be used on module classes to prevent `RegisterCommandsGloballyAsync()` and `RegisterCommandsToGuildAsync()` from registering them to the Discord.
+
> [!NOTE]
> In debug environment, since Global commands can take up to 1 hour to register/update,
> it is adviced to register your commands to a test guild for your changes to take effect immediately.
-> You can use preprocessor directives to create a simple logic for registering commands as seen above
+> You can use preprocessor directives to create a simple logic for registering commands as seen above.
## Interaction Utility
@@ -377,6 +380,7 @@ delegate can be used to create HTTP responses from a deserialized json object st
[DependencyInjection]: xref:Guides.DI.Intro
[GroupAttribute]: xref:Discord.Interactions.GroupAttribute
+[DontAutoRegisterAttribute]: xref:Discord.Interactions.DontAutoRegisterAttribute
[InteractionService]: xref:Discord.Interactions.InteractionService
[InteractionServiceConfig]: xref:Discord.Interactions.InteractionServiceConfig
[InteractionModuleBase]: xref:Discord.Interactions.InteractionModuleBase
diff --git a/src/Discord.Net.Core/Discord.Net.Core.csproj b/src/Discord.Net.Core/Discord.Net.Core.csproj
index 41d83bbc8..005280c4d 100644
--- a/src/Discord.Net.Core/Discord.Net.Core.csproj
+++ b/src/Discord.Net.Core/Discord.Net.Core.csproj
@@ -16,7 +16,6 @@
all
-
@@ -27,4 +26,7 @@
+
+
+
\ No newline at end of file
diff --git a/src/Discord.Net.Core/Entities/Messages/Embed.cs b/src/Discord.Net.Core/Entities/Messages/Embed.cs
index 7fa6f6f36..c1478f56c 100644
--- a/src/Discord.Net.Core/Entities/Messages/Embed.cs
+++ b/src/Discord.Net.Core/Entities/Messages/Embed.cs
@@ -94,5 +94,44 @@ namespace Discord
///
public override string ToString() => Title;
private string DebuggerDisplay => $"{Title} ({Type})";
+
+ public static bool operator ==(Embed left, Embed right)
+ => left is null ? right is null
+ : left.Equals(right);
+
+ public static bool operator !=(Embed left, Embed right)
+ => !(left == right);
+
+ ///
+ /// Determines whether the specified object is equal to the current .
+ ///
+ ///
+ /// If the object passes is an , will be called to compare the 2 instances
+ ///
+ /// The object to compare with the current
+ ///
+ public override bool Equals(object obj)
+ => obj is Embed embed && Equals(embed);
+
+ ///
+ /// Determines whether the specified is equal to the current
+ ///
+ /// The to compare with the current
+ ///
+ public bool Equals(Embed embed)
+ => GetHashCode() == embed?.GetHashCode();
+
+ ///
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ var hash = 17;
+ hash = hash * 23 + (Type, Title, Description, Timestamp, Color, Image, Video, Author, Footer, Provider, Thumbnail).GetHashCode();
+ foreach(var field in Fields)
+ hash = hash * 23 + field.GetHashCode();
+ return hash;
+ }
+ }
}
}
diff --git a/src/Discord.Net.Core/Entities/Messages/EmbedAuthor.cs b/src/Discord.Net.Core/Entities/Messages/EmbedAuthor.cs
index 3b11f6a8b..fdd51e6c9 100644
--- a/src/Discord.Net.Core/Entities/Messages/EmbedAuthor.cs
+++ b/src/Discord.Net.Core/Entities/Messages/EmbedAuthor.cs
@@ -1,3 +1,4 @@
+using System;
using System.Diagnostics;
namespace Discord
@@ -41,5 +42,35 @@ namespace Discord
///
///
public override string ToString() => Name;
+
+ public static bool operator ==(EmbedAuthor? left, EmbedAuthor? right)
+ => left is null ? right is null
+ : left.Equals(right);
+
+ public static bool operator !=(EmbedAuthor? left, EmbedAuthor? right)
+ => !(left == right);
+
+ ///
+ /// Determines whether the specified object is equal to the current .
+ ///
+ ///
+ /// If the object passes is an , will be called to compare the 2 instances
+ ///
+ /// The object to compare with the current
+ ///
+ public override bool Equals(object obj)
+ => obj is EmbedAuthor embedAuthor && Equals(embedAuthor);
+
+ ///
+ /// Determines whether the specified is equal to the current
+ ///
+ /// The to compare with the current
+ ///
+ public bool Equals(EmbedAuthor? embedAuthor)
+ => GetHashCode() == embedAuthor?.GetHashCode();
+
+ ///
+ public override int GetHashCode()
+ => (Name, Url, IconUrl).GetHashCode();
}
}
diff --git a/src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs b/src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs
index 1e2a7b0d7..db38b9fb7 100644
--- a/src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs
+++ b/src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs
@@ -481,6 +481,55 @@ namespace Discord
return new Embed(EmbedType.Rich, Title, Description, Url, Timestamp, Color, _image, null, Author?.Build(), Footer?.Build(), null, _thumbnail, fields.ToImmutable());
}
+
+ public static bool operator ==(EmbedBuilder left, EmbedBuilder right)
+ => left is null ? right is null
+ : left.Equals(right);
+
+ public static bool operator !=(EmbedBuilder left, EmbedBuilder right)
+ => !(left == right);
+
+ ///
+ /// Determines whether the specified object is equal to the current .
+ ///
+ ///
+ /// If the object passes is an , will be called to compare the 2 instances
+ ///
+ /// The object to compare with the current
+ ///
+ public override bool Equals(object obj)
+ => obj is EmbedBuilder embedBuilder && Equals(embedBuilder);
+
+ ///
+ /// Determines whether the specified is equal to the current
+ ///
+ /// The to compare with the current
+ ///
+ public bool Equals(EmbedBuilder embedBuilder)
+ {
+ if (embedBuilder is null)
+ return false;
+
+ if (Fields.Count != embedBuilder.Fields.Count)
+ return false;
+
+ for (var i = 0; i < _fields.Count; i++)
+ if (_fields[i] != embedBuilder._fields[i])
+ return false;
+
+ return _title == embedBuilder?._title
+ && _description == embedBuilder?._description
+ && _image == embedBuilder?._image
+ && _thumbnail == embedBuilder?._thumbnail
+ && Timestamp == embedBuilder?.Timestamp
+ && Color == embedBuilder?.Color
+ && Author == embedBuilder?.Author
+ && Footer == embedBuilder?.Footer
+ && Url == embedBuilder?.Url;
+ }
+
+ ///
+ public override int GetHashCode() => base.GetHashCode();
}
///
@@ -597,6 +646,37 @@ namespace Discord
///
public EmbedField Build()
=> new EmbedField(Name, Value.ToString(), IsInline);
+
+ public static bool operator ==(EmbedFieldBuilder left, EmbedFieldBuilder right)
+ => left is null ? right is null
+ : left.Equals(right);
+
+ public static bool operator !=(EmbedFieldBuilder left, EmbedFieldBuilder right)
+ => !(left == right);
+
+ ///
+ /// Determines whether the specified object is equal to the current .
+ ///
+ ///
+ /// If the object passes is an , will be called to compare the 2 instances
+ ///
+ /// The object to compare with the current
+ ///
+ public override bool Equals(object obj)
+ => obj is EmbedFieldBuilder embedFieldBuilder && Equals(embedFieldBuilder);
+
+ ///
+ /// Determines whether the specified is equal to the current
+ ///
+ /// The to compare with the current
+ ///
+ public bool Equals(EmbedFieldBuilder embedFieldBuilder)
+ => _name == embedFieldBuilder?._name
+ && _value == embedFieldBuilder?._value
+ && IsInline == embedFieldBuilder?.IsInline;
+
+ ///
+ public override int GetHashCode() => base.GetHashCode();
}
///
@@ -697,6 +777,37 @@ namespace Discord
///
public EmbedAuthor Build()
=> new EmbedAuthor(Name, Url, IconUrl, null);
+
+ public static bool operator ==(EmbedAuthorBuilder left, EmbedAuthorBuilder right)
+ => left is null ? right is null
+ : left.Equals(right);
+
+ public static bool operator !=(EmbedAuthorBuilder left, EmbedAuthorBuilder right)
+ => !(left == right);
+
+ ///
+ /// Determines whether the specified object is equal to the current .
+ ///
+ ///
+ /// If the object passes is an , will be called to compare the 2 instances
+ ///
+ /// The object to compare with the current
+ ///
+ public override bool Equals(object obj)
+ => obj is EmbedAuthorBuilder embedAuthorBuilder && Equals(embedAuthorBuilder);
+
+ ///
+ /// Determines whether the specified is equals to the current
+ ///
+ /// The to compare with the current
+ ///
+ public bool Equals(EmbedAuthorBuilder embedAuthorBuilder)
+ => _name == embedAuthorBuilder?._name
+ && Url == embedAuthorBuilder?.Url
+ && IconUrl == embedAuthorBuilder?.IconUrl;
+
+ ///
+ public override int GetHashCode() => base.GetHashCode();
}
///
@@ -777,5 +888,35 @@ namespace Discord
///
public EmbedFooter Build()
=> new EmbedFooter(Text, IconUrl, null);
+
+ public static bool operator ==(EmbedFooterBuilder left, EmbedFooterBuilder right)
+ => left is null ? right is null
+ : left.Equals(right);
+
+ public static bool operator !=(EmbedFooterBuilder left, EmbedFooterBuilder right)
+ => !(left == right);
+
+ ///
+ /// Determines whether the specified object is equal to the current .
+ ///
+ ///
+ /// If the object passes is an , will be called to compare the 2 instances
+ ///
+ /// The object to compare with the current
+ ///
+ public override bool Equals(object obj)
+ => obj is EmbedFooterBuilder embedFooterBuilder && Equals(embedFooterBuilder);
+
+ ///
+ /// Determines whether the specified is equal to the current
+ ///
+ /// The to compare with the current
+ ///
+ public bool Equals(EmbedFooterBuilder embedFooterBuilder)
+ => _text == embedFooterBuilder?._text
+ && IconUrl == embedFooterBuilder?.IconUrl;
+
+ ///
+ public override int GetHashCode() => base.GetHashCode();
}
}
diff --git a/src/Discord.Net.Core/Entities/Messages/EmbedField.cs b/src/Discord.Net.Core/Entities/Messages/EmbedField.cs
index f6aa2af3b..1196869fe 100644
--- a/src/Discord.Net.Core/Entities/Messages/EmbedField.cs
+++ b/src/Discord.Net.Core/Entities/Messages/EmbedField.cs
@@ -1,3 +1,4 @@
+using System;
using System.Diagnostics;
namespace Discord
@@ -36,5 +37,35 @@ namespace Discord
/// A string that resolves to .
///
public override string ToString() => Name;
+
+ public static bool operator ==(EmbedField? left, EmbedField? right)
+ => left is null ? right is null
+ : left.Equals(right);
+
+ public static bool operator !=(EmbedField? left, EmbedField? right)
+ => !(left == right);
+
+ ///
+ /// Determines whether the specified object is equal to the current .
+ ///
+ ///
+ /// If the object passes is an , will be called to compare the 2 instances
+ ///
+ /// The object to compare with the current object
+ ///
+ public override bool Equals(object obj)
+ => obj is EmbedField embedField && Equals(embedField);
+
+ ///
+ /// Determines whether the specified is equal to the current
+ ///
+ ///
+ ///
+ public bool Equals(EmbedField? embedField)
+ => GetHashCode() == embedField?.GetHashCode();
+
+ ///
+ public override int GetHashCode()
+ => (Name, Value, Inline).GetHashCode();
}
}
diff --git a/src/Discord.Net.Core/Entities/Messages/EmbedFooter.cs b/src/Discord.Net.Core/Entities/Messages/EmbedFooter.cs
index 4c507d017..5a1f13158 100644
--- a/src/Discord.Net.Core/Entities/Messages/EmbedFooter.cs
+++ b/src/Discord.Net.Core/Entities/Messages/EmbedFooter.cs
@@ -1,3 +1,4 @@
+using System;
using System.Diagnostics;
namespace Discord
@@ -43,5 +44,35 @@ namespace Discord
/// A string that resolves to .
///
public override string ToString() => Text;
+
+ public static bool operator ==(EmbedFooter? left, EmbedFooter? right)
+ => left is null ? right is null
+ : left.Equals(right);
+
+ public static bool operator !=(EmbedFooter? left, EmbedFooter? right)
+ => !(left == right);
+
+ ///
+ /// Determines whether the specified object is equal to the current .
+ ///
+ ///
+ /// If the object passes is an , will be called to compare the 2 instances
+ ///
+ /// The object to compare with the current
+ ///
+ public override bool Equals(object obj)
+ => obj is EmbedFooter embedFooter && Equals(embedFooter);
+
+ ///
+ /// Determines whether the specified is equal to the current
+ ///
+ /// The to compare with the current
+ ///
+ public bool Equals(EmbedFooter? embedFooter)
+ => GetHashCode() == embedFooter?.GetHashCode();
+
+ ///
+ public override int GetHashCode()
+ => (Text, IconUrl, ProxyUrl).GetHashCode();
}
}
diff --git a/src/Discord.Net.Core/Entities/Messages/EmbedImage.cs b/src/Discord.Net.Core/Entities/Messages/EmbedImage.cs
index 9ce2bfe73..85a638dc8 100644
--- a/src/Discord.Net.Core/Entities/Messages/EmbedImage.cs
+++ b/src/Discord.Net.Core/Entities/Messages/EmbedImage.cs
@@ -1,3 +1,4 @@
+using System;
using System.Diagnostics;
namespace Discord
@@ -53,5 +54,35 @@ namespace Discord
/// A string that resolves to .
///
public override string ToString() => Url;
+
+ public static bool operator ==(EmbedImage? left, EmbedImage? right)
+ => left is null ? right is null
+ : left.Equals(right);
+
+ public static bool operator !=(EmbedImage? left, EmbedImage? right)
+ => !(left == right);
+
+ ///
+ /// Determines whether the specified object is equal to the current .
+ ///
+ ///
+ /// If the object passes is an , will be called to compare the 2 instances
+ ///
+ /// The object to compare with the current
+ ///
+ public override bool Equals(object obj)
+ => obj is EmbedImage embedImage && Equals(embedImage);
+
+ ///
+ /// Determines whether the specified is equal to the current
+ ///
+ /// The to compare with the current
+ ///
+ public bool Equals(EmbedImage? embedImage)
+ => GetHashCode() == embedImage?.GetHashCode();
+
+ ///
+ public override int GetHashCode()
+ => (Height, Width, Url, ProxyUrl).GetHashCode();
}
}
diff --git a/src/Discord.Net.Core/Entities/Messages/EmbedProvider.cs b/src/Discord.Net.Core/Entities/Messages/EmbedProvider.cs
index 960fb3d78..f2ee74613 100644
--- a/src/Discord.Net.Core/Entities/Messages/EmbedProvider.cs
+++ b/src/Discord.Net.Core/Entities/Messages/EmbedProvider.cs
@@ -1,3 +1,4 @@
+using System;
using System.Diagnostics;
namespace Discord
@@ -35,5 +36,35 @@ namespace Discord
/// A string that resolves to .
///
public override string ToString() => Name;
+
+ public static bool operator ==(EmbedProvider? left, EmbedProvider? right)
+ => left is null ? right is null
+ : left.Equals(right);
+
+ public static bool operator !=(EmbedProvider? left, EmbedProvider? right)
+ => !(left == right);
+
+ ///
+ /// Determines whether the specified object is equal to the current .
+ ///
+ ///
+ /// If the object passes is an , will be called to compare the 2 instances
+ ///
+ /// The object to compare with the current
+ ///
+ public override bool Equals(object obj)
+ => obj is EmbedProvider embedProvider && Equals(embedProvider);
+
+ ///
+ /// Determines whether the specified is equal to the current
+ ///
+ /// The to compare with the current
+ ///
+ public bool Equals(EmbedProvider? embedProvider)
+ => GetHashCode() == embedProvider?.GetHashCode();
+
+ ///
+ public override int GetHashCode()
+ => (Name, Url).GetHashCode();
}
}
diff --git a/src/Discord.Net.Core/Entities/Messages/EmbedThumbnail.cs b/src/Discord.Net.Core/Entities/Messages/EmbedThumbnail.cs
index 7f7b582dc..65c8139c3 100644
--- a/src/Discord.Net.Core/Entities/Messages/EmbedThumbnail.cs
+++ b/src/Discord.Net.Core/Entities/Messages/EmbedThumbnail.cs
@@ -1,3 +1,4 @@
+using System;
using System.Diagnostics;
namespace Discord
@@ -53,5 +54,35 @@ namespace Discord
/// A string that resolves to .
///
public override string ToString() => Url;
+
+ public static bool operator ==(EmbedThumbnail? left, EmbedThumbnail? right)
+ => left is null ? right is null
+ : left.Equals(right);
+
+ public static bool operator !=(EmbedThumbnail? left, EmbedThumbnail? right)
+ => !(left == right);
+
+ ///
+ /// Determines whether the specified object is equal to the current .
+ ///
+ ///
+ /// If the object passes is an , will be called to compare the 2 instances
+ ///
+ /// The object to compare with the current
+ ///
+ public override bool Equals(object obj)
+ => obj is EmbedThumbnail embedThumbnail && Equals(embedThumbnail);
+
+ ///
+ /// Determines whether the specified is equal to the current
+ ///
+ /// The to compare with the current
+ ///
+ public bool Equals(EmbedThumbnail? embedThumbnail)
+ => GetHashCode() == embedThumbnail?.GetHashCode();
+
+ ///
+ public override int GetHashCode()
+ => (Width, Height, Url, ProxyUrl).GetHashCode();
}
}
diff --git a/src/Discord.Net.Core/Entities/Messages/EmbedVideo.cs b/src/Discord.Net.Core/Entities/Messages/EmbedVideo.cs
index ca0300e80..0762ed8e7 100644
--- a/src/Discord.Net.Core/Entities/Messages/EmbedVideo.cs
+++ b/src/Discord.Net.Core/Entities/Messages/EmbedVideo.cs
@@ -1,3 +1,4 @@
+using System;
using System.Diagnostics;
namespace Discord
@@ -47,5 +48,35 @@ namespace Discord
/// A string that resolves to .
///
public override string ToString() => Url;
+
+ public static bool operator ==(EmbedVideo? left, EmbedVideo? right)
+ => left is null ? right is null
+ : left.Equals(right);
+
+ public static bool operator !=(EmbedVideo? left, EmbedVideo? right)
+ => !(left == right);
+
+ ///
+ /// Determines whether the specified object is equal to the current .
+ ///
+ ///
+ /// If the object passes is an , will be called to compare the 2 instances
+ ///
+ /// The object to compare with the current
+ ///
+ public override bool Equals(object obj)
+ => obj is EmbedVideo embedVideo && Equals(embedVideo);
+
+ ///
+ /// Determines whether the specified is equal to the current
+ ///
+ /// The to compare with the current
+ ///
+ public bool Equals(EmbedVideo? embedVideo)
+ => GetHashCode() == embedVideo?.GetHashCode();
+
+ ///
+ public override int GetHashCode()
+ => (Width, Height, Url).GetHashCode();
}
}
diff --git a/src/Discord.Net.Rest/API/Rest/CreateStickerParams.cs b/src/Discord.Net.Rest/API/Rest/CreateStickerParams.cs
index b330a0111..a0871bc64 100644
--- a/src/Discord.Net.Rest/API/Rest/CreateStickerParams.cs
+++ b/src/Discord.Net.Rest/API/Rest/CreateStickerParams.cs
@@ -1,4 +1,5 @@
using Discord.Net.Rest;
+
using System.Collections.Generic;
using System.IO;
namespace Discord.API.Rest
@@ -20,14 +21,21 @@ namespace Discord.API.Rest
["tags"] = Tags
};
- string contentType = "image/png";
-
+ string contentType;
if (File is FileStream fileStream)
- contentType = $"image/{Path.GetExtension(fileStream.Name)}";
+ {
+ var extension = Path.GetExtension(fileStream.Name).TrimStart('.');
+ contentType = extension == "json" ? "application/json" : $"image/{extension}";
+ }
else if (FileName != null)
- contentType = $"image/{Path.GetExtension(FileName)}";
+ {
+ var extension = Path.GetExtension(FileName).TrimStart('.');
+ contentType = extension == "json" ? "application/json" : $"image/{extension}";
+ }
+ else
+ contentType = "image/png";
- d["file"] = new MultipartFile(File, FileName ?? "image", contentType.Replace(".", ""));
+ d["file"] = new MultipartFile(File, FileName ?? "image", contentType);
return d;
}
diff --git a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
index 1dbbd4bd6..c4e3764d1 100644
--- a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
@@ -180,7 +180,7 @@ namespace Discord.Rest
},
nextPage: (info, lastPage) =>
{
- if (lastPage.Count != DiscordConfig.MaxMessagesPerBatch)
+ if (lastPage.Count != DiscordConfig.MaxBansPerBatch)
return false;
if (dir == Direction.Before)
info.Position = lastPage.Min(x => x.User.Id);
diff --git a/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs b/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs
index 3b2946a0d..2f6d1f062 100644
--- a/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs
@@ -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(),
- Icon = args.Icon.IsSpecified ? args.Icon.Value.Value.ToModel() : Optional.Unspecified,
- Emoji = args.Emoji.GetValueOrDefault()?.Name ?? Optional.Unspecified
+ Icon = args.Icon.IsSpecified ? args.Icon.Value?.ToModel() ?? null : Optional.Unspecified,
+ Emoji = args.Emoji.IsSpecified ? args.Emoji.Value?.Name ?? "" : Optional.Create(),
};
- 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.Unspecified;
}
var model = await client.ApiClient.ModifyGuildRoleAsync(role.Guild.Id, role.Id, apiArgs, options).ConfigureAwait(false);
diff --git a/test/Discord.Net.Tests.Unit/ColorTests.cs b/test/Discord.Net.Tests.Unit/ColorTests.cs
index 46d8feabb..48a6041e5 100644
--- a/test/Discord.Net.Tests.Unit/ColorTests.cs
+++ b/test/Discord.Net.Tests.Unit/ColorTests.cs
@@ -10,6 +10,7 @@ namespace Discord
///
public class ColorTests
{
+ [Fact]
public void Color_New()
{
Assert.Equal(0u, new Color().RawValue);