diff --git a/src/Discord.Net.Core/CDN.cs b/src/Discord.Net.Core/CDN.cs
index e1e8e5e1a..b1879eebc 100644
--- a/src/Discord.Net.Core/CDN.cs
+++ b/src/Discord.Net.Core/CDN.cs
@@ -46,6 +46,24 @@ namespace Discord
string extension = FormatToExtension(format, avatarId);
return $"{DiscordConfig.CDNUrl}avatars/{userId}/{avatarId}.{extension}?size={size}";
}
+
+ ///
+ /// Returns a user banner URL.
+ ///
+ /// The user snowflake identifier.
+ /// The banner identifier.
+ /// The size of the image to return in horizontal pixels. This can be any power of two between 16 and 2048.
+ /// The format to return.
+ ///
+ /// A URL pointing to the user's banner in the specified size.
+ ///
+ public static string GetUserBannerUrl(ulong userId, string bannerId, ushort size, ImageFormat format)
+ {
+ if (bannerId == null)
+ return null;
+ string extension = FormatToExtension(format, bannerId);
+ return $"{DiscordConfig.CDNUrl}banners/{userId}/{bannerId}.{extension}?size={size}";
+ }
///
/// Returns the default user avatar URL.
///
diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml
index 0510de74a..b41bdd2f8 100644
--- a/src/Discord.Net.Core/Discord.Net.Core.xml
+++ b/src/Discord.Net.Core/Discord.Net.Core.xml
@@ -10144,6 +10144,11 @@
Gets the user that created this webhook.
+
+
+ Gets the ID of the application owning this webhook.
+
+
Modifies this webhook.
diff --git a/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs
index bb2f80a81..4027db408 100644
--- a/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs
+++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs
@@ -10,11 +10,6 @@ namespace Discord
///
public class ComponentBuilder
{
- ///
- /// The max length of a .
- ///
- public const int MaxLabelLength = 80;
-
///
/// The max length of a .
///
@@ -307,17 +302,22 @@ namespace Discord
///
public class ButtonBuilder
{
+ ///
+ /// The max length of a .
+ ///
+ public const int MaxLabelLength = 80;
+
///
/// Gets or sets the label of the current button.
///
- /// length exceeds .
+ /// length exceeds .
public string Label
{
get => _label;
set
{
- if (value != null && value.Length > ComponentBuilder.MaxLabelLength)
- throw new ArgumentException(message: $"Button label must be {ComponentBuilder.MaxLabelLength} characters or less!", paramName: nameof(Label));
+ if (value != null && value.Length > MaxLabelLength)
+ throw new ArgumentException(message: $"Button label must be {MaxLabelLength} characters or less!", paramName: nameof(Label));
_label = value;
}
@@ -539,8 +539,8 @@ namespace Discord
if (string.IsNullOrEmpty(this.Url))
throw new InvalidOperationException("Link buttons must have a link associated with them");
else
- UrlValidation.Validate(this.Url);
- }
+ UrlValidation.Validate(this.Url);
+ }
else if (string.IsNullOrEmpty(this.CustomId))
throw new InvalidOperationException("Non-link buttons must have a custom id associated with them");
@@ -831,23 +831,28 @@ namespace Discord
///
public class SelectMenuOptionBuilder
{
+ ///
+ /// The maximum length of a .
+ ///
+ public const int MaxLabelLength = 100;
+
///
/// The maximum length of a .
///
- public const int MaxDescriptionLength = 50;
+ public const int MaxDescriptionLength = 100;
///
/// Gets or sets the label of the current select menu.
///
- /// length exceeds
+ /// length exceeds
public string Label
{
get => _label;
set
{
if (value != null)
- if (value.Length > ComponentBuilder.MaxLabelLength)
- throw new ArgumentException(message: $"Button label must be {ComponentBuilder.MaxLabelLength} characters or less!", paramName: nameof(Label));
+ if (value.Length > MaxLabelLength)
+ throw new ArgumentException(message: $"Button label must be {MaxLabelLength} characters or less!", paramName: nameof(Label));
_label = value;
}
diff --git a/src/Discord.Net.Core/Entities/Roles/Color.cs b/src/Discord.Net.Core/Entities/Roles/Color.cs
index 7c2d152a4..ee50710e8 100644
--- a/src/Discord.Net.Core/Entities/Roles/Color.cs
+++ b/src/Discord.Net.Core/Entities/Roles/Color.cs
@@ -10,68 +10,70 @@ namespace Discord
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public struct Color
{
+ /// Gets the max decimal value of color.
+ public const uint MaxDecimalValue = 0xFFFFFF;
/// Gets the default user color value.
- public static readonly Color Default = new Color(0);
+ public static readonly Color Default = new(0);
/// Gets the teal color value.
/// A color struct with the hex value of 1ABC9C.
- public static readonly Color Teal = new Color(0x1ABC9C);
+ public static readonly Color Teal = new(0x1ABC9C);
/// Gets the dark teal color value.
/// A color struct with the hex value of 11806A.
- public static readonly Color DarkTeal = new Color(0x11806A);
+ public static readonly Color DarkTeal = new(0x11806A);
/// Gets the green color value.
/// A color struct with the hex value of 2ECC71.
- public static readonly Color Green = new Color(0x2ECC71);
+ public static readonly Color Green = new(0x2ECC71);
/// Gets the dark green color value.
/// A color struct with the hex value of 1F8B4C.
- public static readonly Color DarkGreen = new Color(0x1F8B4C);
+ public static readonly Color DarkGreen = new(0x1F8B4C);
/// Gets the blue color value.
/// A color struct with the hex value of 3498DB.
- public static readonly Color Blue = new Color(0x3498DB);
+ public static readonly Color Blue = new(0x3498DB);
/// Gets the dark blue color value.
/// A color struct with the hex value of 206694.
- public static readonly Color DarkBlue = new Color(0x206694);
+ public static readonly Color DarkBlue = new(0x206694);
/// Gets the purple color value.
/// A color struct with the hex value of 9B59B6.
- public static readonly Color Purple = new Color(0x9B59B6);
+ public static readonly Color Purple = new(0x9B59B6);
/// Gets the dark purple color value.
/// A color struct with the hex value of 71368A.
- public static readonly Color DarkPurple = new Color(0x71368A);
+ public static readonly Color DarkPurple = new(0x71368A);
/// Gets the magenta color value.
/// A color struct with the hex value of E91E63.
- public static readonly Color Magenta = new Color(0xE91E63);
+ public static readonly Color Magenta = new(0xE91E63);
/// Gets the dark magenta color value.
/// A color struct with the hex value of AD1457.
- public static readonly Color DarkMagenta = new Color(0xAD1457);
+ public static readonly Color DarkMagenta = new(0xAD1457);
/// Gets the gold color value.
/// A color struct with the hex value of F1C40F.
- public static readonly Color Gold = new Color(0xF1C40F);
+ public static readonly Color Gold = new(0xF1C40F);
/// Gets the light orange color value.
/// A color struct with the hex value of C27C0E.
- public static readonly Color LightOrange = new Color(0xC27C0E);
+ public static readonly Color LightOrange = new(0xC27C0E);
/// Gets the orange color value.
/// A color struct with the hex value of E67E22.
- public static readonly Color Orange = new Color(0xE67E22);
+ public static readonly Color Orange = new(0xE67E22);
/// Gets the dark orange color value.
/// A color struct with the hex value of A84300.
- public static readonly Color DarkOrange = new Color(0xA84300);
+ public static readonly Color DarkOrange = new(0xA84300);
/// Gets the red color value.
/// A color struct with the hex value of E74C3C.
- public static readonly Color Red = new Color(0xE74C3C);
+ public static readonly Color Red = new(0xE74C3C);
/// Gets the dark red color value.
/// A color struct with the hex value of 992D22.
- public static readonly Color DarkRed = new Color(0x992D22);
+ public static readonly Color DarkRed = new(0x992D22);
/// Gets the light grey color value.
/// A color struct with the hex value of 979C9F.
- public static readonly Color LightGrey = new Color(0x979C9F);
+ public static readonly Color LightGrey = new(0x979C9F);
/// Gets the lighter grey color value.
/// A color struct with the hex value of 95A5A6.
- public static readonly Color LighterGrey = new Color(0x95A5A6);
+ public static readonly Color LighterGrey = new(0x95A5A6);
/// Gets the dark grey color value.
/// A color struct with the hex value of 607D8B.
- public static readonly Color DarkGrey = new Color(0x607D8B);
+ public static readonly Color DarkGrey = new(0x607D8B);
/// Gets the darker grey color value.
/// A color struct with the hex value of 546E7A.
- public static readonly Color DarkerGrey = new Color(0x546E7A);
+ public static readonly Color DarkerGrey = new(0x546E7A);
/// Gets the encoded value for this color.
///
@@ -91,22 +93,27 @@ namespace Discord
/// Initializes a struct with the given raw value.
///
///
- /// The following will create a color that has a hex value of
+ /// The following will create a color that has a hex value of
/// #607D8B.
///
/// Color darkGrey = new Color(0x607D8B);
///
///
/// The raw value of the color (e.g. 0x607D8B).
+ /// Value exceeds .
public Color(uint rawValue)
{
+ if (rawValue > MaxDecimalValue)
+ throw new ArgumentException($"{nameof(RawValue)} of color cannot be greater than {MaxDecimalValue}!", nameof(rawValue));
+
RawValue = rawValue;
}
+
///
/// Initializes a struct with the given RGB bytes.
///
///
- /// The following will create a color that has a value of
+ /// The following will create a color that has a value of
/// #607D8B.
///
/// Color darkGrey = new Color((byte)0b_01100000, (byte)0b_01111101, (byte)0b_10001011);
@@ -115,19 +122,24 @@ namespace Discord
/// The byte that represents the red color.
/// The byte that represents the green color.
/// The byte that represents the blue color.
+ /// Value exceeds .
public Color(byte r, byte g, byte b)
{
- RawValue =
- ((uint)r << 16) |
- ((uint)g << 8) |
- (uint)b;
+ uint value = ((uint)r << 16)
+ | ((uint)g << 8)
+ | (uint)b;
+
+ if (value > MaxDecimalValue)
+ throw new ArgumentException($"{nameof(RawValue)} of color cannot be greater than {MaxDecimalValue}!");
+
+ RawValue = value;
}
///
/// Initializes a struct with the given RGB value.
///
///
- /// The following will create a color that has a value of
+ /// The following will create a color that has a value of
/// #607D8B.
///
/// Color darkGrey = new Color(96, 125, 139);
@@ -145,16 +157,15 @@ namespace Discord
throw new ArgumentOutOfRangeException(nameof(g), "Value must be within [0,255].");
if (b < 0 || b > 255)
throw new ArgumentOutOfRangeException(nameof(b), "Value must be within [0,255].");
- RawValue =
- ((uint)r << 16) |
- ((uint)g << 8) |
- (uint)b;
+ RawValue = ((uint)r << 16)
+ | ((uint)g << 8)
+ | (uint)b;
}
///
/// Initializes a struct with the given RGB float value.
///
///
- /// The following will create a color that has a value of
+ /// The following will create a color that has a value of
/// #607c8c.
///
/// Color darkGrey = new Color(0.38f, 0.49f, 0.55f);
@@ -172,10 +183,9 @@ namespace Discord
throw new ArgumentOutOfRangeException(nameof(g), "Value must be within [0,1].");
if (b < 0.0f || b > 1.0f)
throw new ArgumentOutOfRangeException(nameof(b), "Value must be within [0,1].");
- RawValue =
- ((uint)(r * 255.0f) << 16) |
- ((uint)(g * 255.0f) << 8) |
- (uint)(b * 255.0f);
+ RawValue = ((uint)(r * 255.0f) << 16)
+ | ((uint)(g * 255.0f) << 8)
+ | (uint)(b * 255.0f);
}
public static bool operator ==(Color lhs, Color rhs)
@@ -184,15 +194,22 @@ namespace Discord
public static bool operator !=(Color lhs, Color rhs)
=> lhs.RawValue != rhs.RawValue;
+ public static implicit operator Color(uint rawValue)
+ => new(rawValue);
+
+ public static implicit operator uint(Color color)
+ => color.RawValue;
+
public override bool Equals(object obj)
- => (obj is Color c && RawValue == c.RawValue);
+ => obj is Color c && RawValue == c.RawValue;
public override int GetHashCode() => RawValue.GetHashCode();
- public static implicit operator StandardColor(Color color) =>
- StandardColor.FromArgb((int)color.RawValue);
- public static explicit operator Color(StandardColor color) =>
- new Color((uint)color.ToArgb() << 8 >> 8);
+ public static implicit operator StandardColor(Color color)
+ => StandardColor.FromArgb((int)color.RawValue);
+
+ public static explicit operator Color(StandardColor color)
+ => new((uint)color.ToArgb() << 8 >> 8);
///
/// Gets the hexadecimal representation of the color (e.g. #000ccc).
diff --git a/src/Discord.Net.Core/Entities/Users/IUser.cs b/src/Discord.Net.Core/Entities/Users/IUser.cs
index 9596a8338..f265bb938 100644
--- a/src/Discord.Net.Core/Entities/Users/IUser.cs
+++ b/src/Discord.Net.Core/Entities/Users/IUser.cs
@@ -12,17 +12,29 @@ namespace Discord
///
string AvatarId { get; }
///
+ /// Gets the identifier of this user's banner.
+ ///
+ string BannerId { get; }
+ ///
+ /// Gets the user's banner color.
+ ///
+ ///
+ /// A struct representing the accent color of this user's banner.
+ ///
+ Color? AccentColor { get; }
+ ///
/// Gets the avatar URL for this user.
///
///
/// This property retrieves a URL for this user's avatar. In event that the user does not have a valid avatar
- /// (i.e. their avatar identifier is not set), this property will return null. If you wish to
+ /// (i.e. their avatar identifier is not set), this method will return null. If you wish to
/// retrieve the default avatar for this user, consider using (see
/// example).
///
///
- /// The following example attempts to retrieve the user's current avatar and send it to a channel; if one is
- /// not set, a default avatar for this user will be returned instead.
+ /// The following example attempts to retrieve the user's current avatar and send it to a channel; if one is
+ /// not set, a default avatar for this user will be returned instead.
///
///
@@ -34,6 +46,16 @@ namespace Discord
///
string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128);
///
+ /// Gets the banner URL for this user.
+ ///
+ /// The format to return.
+ /// The size of the image to return in. This can be any power of two between 16 and 2048.
+ ///
+ ///
+ /// A string representing the user's avatar URL; null if the user does not have an banner in place.
+ ///
+ string GetBannerUrl(ImageFormat format = ImageFormat.Auto, ushort size = 256);
+ ///
/// Gets the default avatar URL for this user.
///
///
@@ -93,8 +115,8 @@ namespace Discord
/// This method is used to obtain or create a channel used to send a direct message.
///
/// In event that the current user cannot send a message to the target user, a channel can and will
- /// still be created by Discord. However, attempting to send a message will yield a
- /// with a 403 as its
+ /// still be created by Discord. However, attempting to send a message will yield a
+ /// with a 403 as its
/// . There are currently no official workarounds by
/// Discord.
///
diff --git a/src/Discord.Net.Core/Entities/Webhooks/IWebhook.cs b/src/Discord.Net.Core/Entities/Webhooks/IWebhook.cs
index b2d017316..d5bc70d71 100644
--- a/src/Discord.Net.Core/Entities/Webhooks/IWebhook.cs
+++ b/src/Discord.Net.Core/Entities/Webhooks/IWebhook.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Threading.Tasks;
namespace Discord
@@ -49,6 +49,11 @@ namespace Discord
///
IUser Creator { get; }
+ ///
+ /// Gets the ID of the application owning this webhook.
+ ///
+ ulong? ApplicationId { get; }
+
///
/// Modifies this webhook.
///
diff --git a/src/Discord.Net.Rest/API/Common/User.cs b/src/Discord.Net.Rest/API/Common/User.cs
index d1f436afb..4d1b5b2b7 100644
--- a/src/Discord.Net.Rest/API/Common/User.cs
+++ b/src/Discord.Net.Rest/API/Common/User.cs
@@ -15,6 +15,10 @@ namespace Discord.API
public Optional Bot { get; set; }
[JsonProperty("avatar")]
public Optional Avatar { get; set; }
+ [JsonProperty("banner")]
+ public Optional Banner { get; set; }
+ [JsonProperty("accent_color")]
+ public Optional AccentColor { get; set; }
//CurrentUser
[JsonProperty("verified")]
diff --git a/src/Discord.Net.Rest/API/Common/Webhook.cs b/src/Discord.Net.Rest/API/Common/Webhook.cs
index cbd5fdad5..ff1dca9bd 100644
--- a/src/Discord.Net.Rest/API/Common/Webhook.cs
+++ b/src/Discord.Net.Rest/API/Common/Webhook.cs
@@ -21,5 +21,7 @@ namespace Discord.API
[JsonProperty("user")]
public Optional Creator { get; set; }
+ [JsonProperty("application_id")]
+ public Optional ApplicationId { get; set; }
}
}
diff --git a/src/Discord.Net.Rest/API/Rest/ModifyWebhookMessageParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyWebhookMessageParams.cs
index ba8fcbb4e..8298ff19c 100644
--- a/src/Discord.Net.Rest/API/Rest/ModifyWebhookMessageParams.cs
+++ b/src/Discord.Net.Rest/API/Rest/ModifyWebhookMessageParams.cs
@@ -12,5 +12,7 @@ namespace Discord.API.Rest
public Optional
-
+
Sends a message to the channel for this webhook.
Returns the ID of the created message.
@@ -99,6 +99,11 @@
Gets or sets the allowed mentions of the message.
+
+
+ Gets or sets the components that the message should display.
+
+
Could not find a webhook with the supplied credentials.
diff --git a/src/Discord.Net.Webhook/DiscordWebhookClient.cs b/src/Discord.Net.Webhook/DiscordWebhookClient.cs
index 91d077411..d4affb08b 100644
--- a/src/Discord.Net.Webhook/DiscordWebhookClient.cs
+++ b/src/Discord.Net.Webhook/DiscordWebhookClient.cs
@@ -88,8 +88,8 @@ namespace Discord.Webhook
/// Sends a message to the channel for this webhook.
/// Returns the ID of the created message.
public Task SendMessageAsync(string text = null, bool isTTS = false, IEnumerable