* General cleanup
* Add Async suffix to SendAutocompleteResult
* Fix more formatting
* Fix unused RequestOptions in GetActiveThreadsAsync
* Add message to ArgumentNullException
/// <param name="options">The request options for this response.</param>
/// <param name="component">A <see cref="MessageComponent"/> to be sent with this response.</param>
/// <param name="embed">A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.</param>
/// After receiving an interaction, you must respond to acknowledge it. You can choose to respond with a message immediately using <see cref="ChannelMessageWithSource"/>
/// or you can choose to send a deferred response with <see cref="DeferredChannelMessageWithSource"/>. If choosing a deferred response, the user will see a loading state for the interaction,
/// and you'll have up to 15 minutes to edit the original deferred response using Edit Original Interaction Response.
/// You can read more about Response types <see href="https://discord.com/developers/docs/interactions/slash-commands#interaction-response">Here</see>
/// You can read more about Response types <see href="https://discord.com/developers/docs/interactions/slash-commands#interaction-response">Here</see>.
/// </remarks>
public enum InteractionResponseType : byte
{
@@ -45,17 +41,17 @@ namespace Discord
DeferredChannelMessageWithSource = 5,
/// <summary>
/// For components: ACK an interaction and edit the original message later; the user does not see a loading state
/// For components: ACK an interaction and edit the original message later; the user does not see a loading state.
/// </summary>
DeferredUpdateMessage = 6,
/// <summary>
/// For components: edit the message the component was attached to
/// For components: edit the message the component was attached to.
/// </summary>
UpdateMessage = 7,
/// <summary>
/// Respond with a set of choices to a autocomplete interaction
/// Respond with a set of choices to a autocomplete interaction.
public ComponentType Type { get; } = ComponentType.Button;
public ComponentType Type => ComponentType.Button;
/// <summary>
/// Gets the <see cref="ButtonStyle"/> of this button, example buttons with each style can be found <see href="https://discord.com/assets/7bb017ce52cfd6575e21c058feb3883b.png">Here</see>.
@@ -34,7 +27,7 @@ namespace Discord
public string CustomId { get; }
/// <summary>
/// Gets the URL for a <see cref="ButtonStyle.Link"/> button.
/// Gets the URL for a <see cref="ButtonStyle.Link"/> button.
/// </summary>
/// <remarks>
/// You cannot have a button with a <b>URL</b> and a <b>CustomId</b>.
if (menu.Options.Distinct().Count() != menu.Options.Count())
if (menu.Options.Distinct().Count() != menu.Options.Count)
throw new InvalidOperationException("Please make sure that there is no duplicates values.");
var builtMenu = menu.Build();
@@ -218,7 +218,7 @@ namespace Discord
else
{
ActionRowBuilder actionRow;
if(_actionRows.Count > row)
if(_actionRows.Count > row)
actionRow = _actionRows.ElementAt(row);
else
{
@@ -244,10 +244,9 @@ namespace Discord
/// <returns>A <see cref="MessageComponent"/> that can be sent with <see cref="IMessageChannel.SendMessageAsync"/>.</returns>
public MessageComponent Build()
{
if (_actionRows != null)
return new MessageComponent(_actionRows.Select(x => x.Build()).ToList());
else
return MessageComponent.Empty;
return _actionRows != null
? new MessageComponent(_actionRows.Select(x => x.Build()).ToList())
: MessageComponent.Empty;
}
}
@@ -272,19 +271,18 @@ namespace Discord
set
{
if (value == null)
throw new ArgumentNullException(message: "Action row components cannot be null!", paramName: nameof(Components));
if (value.Count <= 0)
throw new ArgumentException(message: "There must be at least 1 component in a row", paramName: nameof(Components));
if (value.Count > MaxChildCount)
throw new ArgumentException(message: $"Action row can only contain {MaxChildCount} child components!", paramName: nameof(Components));
throw new ArgumentNullException(nameof(value), $"{nameof(Components)} cannot be null.");
_components = value;
_components = value.Count switch
{
0 => throw new ArgumentOutOfRangeException(nameof(value), "There must be at least 1 component in a row."),
> MaxChildCount => throw new ArgumentOutOfRangeException(nameof(value), $"Action row can only contain {MaxChildCount} child components!"),
_ => value
};
}
}
private List<IMessageComponent> _components { get; set; } = new List<IMessageComponent>();
private List<IMessageComponent> _components = new List<IMessageComponent>();
/// <summary>
/// Adds a list of components to the current row.
@@ -359,18 +357,12 @@ namespace Discord
public string Label
{
get => _label;
set
set => _label = value?.Length switch
{
if (value != null)
{
if (value.Length > MaxButtonLabelLength)
throw new ArgumentException($"Button label must be {MaxButtonLabelLength} characters or less!", paramName: nameof(Label));
if (value.Length < 1)
throw new ArgumentException("Button label must be 1 character or more!", paramName: nameof(Label));
}
_label = value;
}
> MaxButtonLabelLength => throw new ArgumentOutOfRangeException(nameof(value), $"Label length must be less or equal to {MaxButtonLabelLength}."),
0 => throw new ArgumentOutOfRangeException(nameof(value), "Label length must be at least 1."),
_ => value
};
}
/// <summary>
@@ -381,17 +373,12 @@ namespace Discord
public string CustomId
{
get => _customId;
set
set => _customId = value?.Length switch
{
if (value != null)
{
if (value.Length > ComponentBuilder.MaxCustomIdLength)
throw new ArgumentException($"Custom Id must be {ComponentBuilder.MaxCustomIdLength} characters or less!", paramName: nameof(CustomId));
if (value.Length < 1)
throw new ArgumentException("Custom Id must be 1 character or more!", paramName: nameof(CustomId));
}
_customId = value;
}
> ComponentBuilder.MaxCustomIdLength => throw new ArgumentOutOfRangeException(nameof(value), $"Custom Id length must be less or equal to {ComponentBuilder.MaxCustomIdLength}."),
0 => throw new ArgumentOutOfRangeException(nameof(value), "Custom Id length must be at least 1."),
_ => value
};
}
/// <summary>
@@ -414,7 +401,6 @@ namespace Discord
/// </summary>
public bool IsDisabled { get; set; }
private string _label;
private string _customId;
@@ -594,8 +580,7 @@ namespace Discord
{
if (string.IsNullOrEmpty(Url))
throw new InvalidOperationException("Link buttons must have a link associated with them");
else
UrlValidation.ValidateButton(Url);
UrlValidation.ValidateButton(Url);
}
else if (string.IsNullOrEmpty(CustomId))
throw new InvalidOperationException("Non-link buttons must have a custom id associated with them");
@@ -632,17 +617,12 @@ namespace Discord
public string CustomId
{
get => _customId;
set
set => _customId = value?.Length switch
{
if (value != null)
{
if (value.Length > ComponentBuilder.MaxCustomIdLength)
throw new ArgumentException($"Custom Id must be {ComponentBuilder.MaxCustomIdLength} characters or less!", paramName: nameof(CustomId));
if (value.Length < 1)
throw new ArgumentException("Custom Id must be 1 character or more!", paramName: nameof(CustomId));
}
_customId = value;
}
> ComponentBuilder.MaxCustomIdLength => throw new ArgumentOutOfRangeException(nameof(value), $"Custom Id length must be less or equal to {ComponentBuilder.MaxCustomIdLength}."),
0 => throw new ArgumentOutOfRangeException(nameof(value), "Custom Id length must be at least 1."),
_ => value
};
}
/// <summary>
@@ -653,18 +633,12 @@ namespace Discord
public string Placeholder
{
get => _placeholder;
set
set => _placeholder = value?.Length switch
{
if (value != null)
{
if (value.Length > MaxPlaceholderLength)
throw new ArgumentException($"The placeholder must be {MaxPlaceholderLength} characters or less!", paramName: nameof(Placeholder));
if (value.Length < 1)
throw new ArgumentException("The placeholder must be 1 character or more!", paramName: nameof(Placeholder));
}
_placeholder = value;
}
> MaxPlaceholderLength => throw new ArgumentOutOfRangeException(nameof(value), $"Placeholder length must be less or equal to {MaxPlaceholderLength}."),
0 => throw new ArgumentOutOfRangeException(nameof(value), "Placeholder length must be at least 1."),
throw new ArgumentException($"Select option value must be {MaxSelectValueLength} characters or less!", paramName: nameof(Label));
if (value.Length < 1)
throw new ArgumentException("Select option value must be 1 character or more!", paramName: nameof(Label));
}
else
throw new ArgumentException("Select option value must not be null or empty!", paramName: nameof(Label));
_value = value;
}
> MaxSelectValueLength => throw new ArgumentOutOfRangeException(nameof(value), $"Value length must be less or equal to {MaxSelectValueLength}."),
0 => throw new ArgumentOutOfRangeException(nameof(value), "Value length must be at least 1."),
_ => value
};
}
/// <summary>
@@ -968,18 +928,12 @@ namespace Discord
public string Description
{
get => _description;
set
set => _description = value?.Length switch
{
if (value != null)
{
if (value.Length > MaxDescriptionLength)
throw new ArgumentException($"The description must be {MaxDescriptionLength} characters or less!", paramName: nameof(Label));
if (value.Length < 1)
throw new ArgumentException("The description must be 1 character or more!", paramName: nameof(Label));
}
_description = value;
}
> MaxDescriptionLength => throw new ArgumentOutOfRangeException(nameof(value), $"Description length must be less or equal to {MaxDescriptionLength}."),
0 => throw new ArgumentOutOfRangeException(nameof(value), "Description length must be at least 1."),
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.