* Refactor emojis/emotes & SelectMenu * Update Emoji.cs * Continue emoji refactor * Remove WithLabel from example of SelectMenuBuilder * Remove EmojiUtils and move it stuff to Emoji * Revertpull/1923/head0fbf1000da* Revert "Update Emoji.cs" and add Parse method This reverts commitf297dcfc43. * Partial revert3c27ab36c9
| @@ -96,7 +96,6 @@ Theres a new field in all `SendMessageAsync` functions that takes in a `MessageC | |||
| var builder = new ComponentBuilder() | |||
| .WithSelectMenu(new SelectMenuBuilder() | |||
| .WithCustomId("id_2") | |||
| .WithLabel("Select menu!") | |||
| .WithPlaceholder("This is a placeholder") | |||
| .WithOptions(new List<SelectMenuOptionBuilder>() | |||
| { | |||
| @@ -2106,7 +2106,7 @@ | |||
| </member> | |||
| <member name="M:Discord.Emoji.ToString"> | |||
| <summary> | |||
| Gets the Unicode representation of this emote. | |||
| Gets the Unicode representation of this emoji. | |||
| </summary> | |||
| <returns> | |||
| A string that resolves to <see cref="P:Discord.Emoji.Name"/>. | |||
| @@ -2124,6 +2124,17 @@ | |||
| </summary> | |||
| <param name="other">The object to compare with the current object.</param> | |||
| </member> | |||
| <member name="M:Discord.Emoji.TryParse(System.String,Discord.Emoji@)"> | |||
| <summary> Tries to parse an <see cref="T:Discord.Emoji"/> from its raw format. </summary> | |||
| <param name="text">The raw encoding of an emoji. For example: <code>:heart: or ❤</code></param> | |||
| <param name="result">An emoji.</param> | |||
| </member> | |||
| <member name="M:Discord.Emoji.Parse(System.String)"> | |||
| <summary> Parse an <see cref="T:Discord.Emoji"/> from its raw format. </summary> | |||
| <param name="text">The raw encoding of an emoji. For example: <c>:heart: or ❤</c></param> | |||
| <param name="result">An emoji.</param> | |||
| <exception cref="T:System.FormatException">String is not emoji or unicode!</exception> | |||
| </member> | |||
| <member name="M:Discord.Emoji.GetHashCode"> | |||
| <inheritdoc /> | |||
| </member> | |||
| @@ -4361,7 +4372,7 @@ | |||
| Gets or sets the Action Rows for this Component Builder. | |||
| </summary> | |||
| </member> | |||
| <member name="M:Discord.ComponentBuilder.WithSelectMenu(System.String,System.String,System.Collections.Generic.List{Discord.SelectMenuOptionBuilder},System.String,System.Int32,System.Int32,System.Int32)"> | |||
| <member name="M:Discord.ComponentBuilder.WithSelectMenu(System.String,System.String,System.Collections.Generic.List{Discord.SelectMenuOptionBuilder},System.String,System.Int32,System.Int32,System.Boolean,System.Int32)"> | |||
| <summary> | |||
| Adds a <see cref="T:Discord.SelectMenuBuilder"/> to the first row, if the first row cannot | |||
| accept the component then it will add it to a row that can | |||
| @@ -4372,6 +4383,7 @@ | |||
| <param name="placeholder">The placeholder of the menu.</param> | |||
| <param name="minValues">The min values of the placeholder.</param> | |||
| <param name="maxValues">The max values of the placeholder.</param> | |||
| <param name="disabled">Whether or not the menu is disabled.</param> | |||
| <param name="row">The row to add the menu to.</param> | |||
| <returns></returns> | |||
| </member> | |||
| @@ -4607,11 +4619,6 @@ | |||
| The maximum number of options a <see cref="T:Discord.SelectMenu"/> can have. | |||
| </summary> | |||
| </member> | |||
| <member name="P:Discord.SelectMenuBuilder.Label"> | |||
| <summary> | |||
| Gets or sets the label of the current select menu. | |||
| </summary> | |||
| </member> | |||
| <member name="P:Discord.SelectMenuBuilder.CustomId"> | |||
| <summary> | |||
| Gets or sets the custom id of the current select menu. | |||
| @@ -4637,6 +4644,11 @@ | |||
| Gets or sets a collection of <see cref="T:Discord.SelectMenuOptionBuilder"/> for this current select menu. | |||
| </summary> | |||
| </member> | |||
| <member name="P:Discord.SelectMenuBuilder.Disabled"> | |||
| <summary> | |||
| Gets or sets whether the current menu is disabled. | |||
| </summary> | |||
| </member> | |||
| <member name="M:Discord.SelectMenuBuilder.#ctor"> | |||
| <summary> | |||
| Creates a new instance of a <see cref="T:Discord.SelectMenuBuilder"/>. | |||
| @@ -4649,15 +4661,6 @@ | |||
| <param name="customId">The custom id of this select menu.</param> | |||
| <param name="options">The options for this select menu.</param> | |||
| </member> | |||
| <member name="M:Discord.SelectMenuBuilder.WithLabel(System.String)"> | |||
| <summary> | |||
| Sets the field label. | |||
| </summary> | |||
| <param name="label">The value to set the field label to.</param> | |||
| <returns> | |||
| The current builder. | |||
| </returns> | |||
| </member> | |||
| <member name="M:Discord.SelectMenuBuilder.WithCustomId(System.String)"> | |||
| <summary> | |||
| Sets the field CustomId. | |||
| @@ -4703,6 +4706,15 @@ | |||
| The current builder. | |||
| </returns> | |||
| </member> | |||
| <member name="M:Discord.SelectMenuBuilder.WithDisabled(System.Boolean)"> | |||
| <summary> | |||
| Sets whether the current menu is disabled. | |||
| </summary> | |||
| <param name="disabled">Whether the current menu is disabled or not.</param> | |||
| <returns> | |||
| The current builder. | |||
| </returns> | |||
| </member> | |||
| <member name="M:Discord.SelectMenuBuilder.Build"> | |||
| <summary> | |||
| Builds a <see cref="T:Discord.SelectMenu"/> | |||
| @@ -4880,6 +4892,11 @@ | |||
| The maximum number of items that can be chosen; default 1, max 25 | |||
| </summary> | |||
| </member> | |||
| <member name="P:Discord.SelectMenu.Disabled"> | |||
| <summary> | |||
| Whether this menu is disabled or not. | |||
| </summary> | |||
| </member> | |||
| <member name="T:Discord.SelectMenuOption"> | |||
| <summary> | |||
| Represents a choice for a <see cref="T:Discord.SelectMenu"/>. | |||
| @@ -1,8 +1,6 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| @@ -54,18 +52,19 @@ namespace Discord | |||
| /// <param name="placeholder">The placeholder of the menu.</param> | |||
| /// <param name="minValues">The min values of the placeholder.</param> | |||
| /// <param name="maxValues">The max values of the placeholder.</param> | |||
| /// <param name="disabled">Whether or not the menu is disabled.</param> | |||
| /// <param name="row">The row to add the menu to.</param> | |||
| /// <returns></returns> | |||
| public ComponentBuilder WithSelectMenu(string label, string customId, List<SelectMenuOptionBuilder> options, | |||
| string placeholder = null, int minValues = 1, int maxValues = 1, int row = 0) | |||
| string placeholder = null, int minValues = 1, int maxValues = 1, bool disabled = false, int row = 0) | |||
| { | |||
| return WithSelectMenu(new SelectMenuBuilder() | |||
| .WithLabel(label) | |||
| .WithCustomId(customId) | |||
| .WithOptions(options) | |||
| .WithPlaceholder(placeholder) | |||
| .WithMaxValues(maxValues) | |||
| .WithMinValues(minValues), | |||
| .WithMinValues(minValues) | |||
| .WithDisabled(disabled), | |||
| row); | |||
| } | |||
| @@ -557,22 +556,6 @@ namespace Discord | |||
| /// </summary> | |||
| public const int MaxOptionCount = 25; | |||
| /// <summary> | |||
| /// Gets or sets the label of the current select menu. | |||
| /// </summary> | |||
| 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)); | |||
| _label = value; | |||
| } | |||
| } | |||
| /// <summary> | |||
| /// Gets or sets the custom id of the current select menu. | |||
| /// </summary> | |||
| @@ -608,11 +591,11 @@ namespace Discord | |||
| /// </summary> | |||
| public int MinValues | |||
| { | |||
| get => _minvalues; | |||
| get => _minValues; | |||
| set | |||
| { | |||
| Preconditions.LessThan(value, MaxValuesCount, nameof(MinValues)); | |||
| _minvalues = value; | |||
| _minValues = value; | |||
| } | |||
| } | |||
| @@ -621,11 +604,11 @@ namespace Discord | |||
| /// </summary> | |||
| public int MaxValues | |||
| { | |||
| get => _maxvalues; | |||
| get => _maxValues; | |||
| set | |||
| { | |||
| Preconditions.LessThan(value, MaxValuesCount, nameof(MaxValues)); | |||
| _maxvalues = value; | |||
| _maxValues = value; | |||
| } | |||
| } | |||
| @@ -644,11 +627,15 @@ namespace Discord | |||
| } | |||
| } | |||
| /// <summary> | |||
| /// Gets or sets whether the current menu is disabled. | |||
| /// </summary> | |||
| public bool Disabled { get; set; } | |||
| private List<SelectMenuOptionBuilder> _options; | |||
| private int _minvalues = 1; | |||
| private int _maxvalues = 1; | |||
| private int _minValues = 1; | |||
| private int _maxValues = 1; | |||
| private string _placeholder; | |||
| private string _label; | |||
| private string _customId; | |||
| /// <summary> | |||
| @@ -667,19 +654,6 @@ namespace Discord | |||
| this.Options = options; | |||
| } | |||
| /// <summary> | |||
| /// Sets the field label. | |||
| /// </summary> | |||
| /// <param name="label">The value to set the field label to.</param> | |||
| /// <returns> | |||
| /// The current builder. | |||
| /// </returns> | |||
| public SelectMenuBuilder WithLabel(string label) | |||
| { | |||
| this.Label = label; | |||
| return this; | |||
| } | |||
| /// <summary> | |||
| /// Sets the field CustomId. | |||
| /// </summary> | |||
| @@ -745,15 +719,28 @@ namespace Discord | |||
| return this; | |||
| } | |||
| /// <summary> | |||
| /// Sets whether the current menu is disabled. | |||
| /// </summary> | |||
| /// <param name="disabled">Whether the current menu is disabled or not.</param> | |||
| /// <returns> | |||
| /// The current builder. | |||
| /// </returns> | |||
| public SelectMenuBuilder WithDisabled(bool disabled) | |||
| { | |||
| this.Disabled = disabled; | |||
| return this; | |||
| } | |||
| /// <summary> | |||
| /// Builds a <see cref="SelectMenu"/> | |||
| /// </summary> | |||
| /// <returns>The newly built <see cref="SelectMenu"/></returns> | |||
| public SelectMenu Build() | |||
| { | |||
| var opt = this.Options?.Select(x => x.Build()).ToList(); | |||
| var options = this.Options?.Select(x => x.Build()).ToList(); | |||
| return new SelectMenu(this.CustomId, opt, this.Placeholder, this.MinValues, this.MaxValues); | |||
| return new SelectMenu(this.CustomId, options, this.Placeholder, this.MinValues, this.MaxValues, this.Disabled); | |||
| } | |||
| } | |||
| @@ -39,13 +39,19 @@ namespace Discord | |||
| /// </summary> | |||
| public int MaxValues { get; } | |||
| internal SelectMenu(string customId, List<SelectMenuOption> options, string placeholder, int minValues, int maxValues) | |||
| /// <summary> | |||
| /// Whether this menu is disabled or not. | |||
| /// </summary> | |||
| public bool Disabled { get; } | |||
| internal SelectMenu(string customId, List<SelectMenuOption> options, string placeholder, int minValues, int maxValues, bool disabled) | |||
| { | |||
| this.CustomId = customId; | |||
| this.Options = options; | |||
| this.Placeholder = placeholder; | |||
| this.MinValues = minValues; | |||
| this.MaxValues = maxValues; | |||
| this.Disabled = disabled; | |||
| } | |||
| } | |||
| } | |||
| @@ -27,6 +27,9 @@ namespace Discord.API | |||
| [JsonProperty("max_values")] | |||
| public int MaxValues { get; set; } | |||
| [JsonProperty("disabled")] | |||
| public bool Disabled { get; set; } | |||
| public SelectMenuComponent() { } | |||
| public SelectMenuComponent(Discord.SelectMenu component) | |||
| @@ -37,6 +40,7 @@ namespace Discord.API | |||
| this.Placeholder = component.Placeholder; | |||
| this.MinValues = component.MinValues; | |||
| this.MaxValues = component.MaxValues; | |||
| this.Disabled = component.Disabled; | |||
| } | |||
| } | |||
| } | |||
| @@ -174,7 +174,8 @@ namespace Discord.Rest | |||
| z.Default.ToNullable())).ToList(), | |||
| parsed.Placeholder.GetValueOrDefault(), | |||
| parsed.MinValues, | |||
| parsed.MaxValues | |||
| parsed.MaxValues, | |||
| parsed.Disabled | |||
| ); | |||
| } | |||
| default: | |||
| @@ -230,7 +231,7 @@ namespace Discord.Rest | |||
| IReadOnlyCollection<IEmbed> IMessage.Embeds => Embeds; | |||
| /// <inheritdoc /> | |||
| IReadOnlyCollection<ulong> IMessage.MentionedUserIds => MentionedUsers.Select(x => x.Id).ToImmutableArray(); | |||
| /// <inheritdoc/> | |||
| IReadOnlyCollection<IMessageComponent> IMessage.Components => Components; | |||
| @@ -209,7 +209,8 @@ namespace Discord.WebSocket | |||
| z.Default.ToNullable())).ToList(), | |||
| parsed.Placeholder.GetValueOrDefault(), | |||
| parsed.MinValues, | |||
| parsed.MaxValues | |||
| parsed.MaxValues, | |||
| parsed.Disabled | |||
| ); | |||
| } | |||
| default: | |||
| @@ -252,7 +253,7 @@ namespace Discord.WebSocket | |||
| IReadOnlyCollection<ulong> IMessage.MentionedRoleIds => MentionedRoles.Select(x => x.Id).ToImmutableArray(); | |||
| /// <inheritdoc /> | |||
| IReadOnlyCollection<ulong> IMessage.MentionedUserIds => MentionedUsers.Select(x => x.Id).ToImmutableArray(); | |||
| /// <inheritdoc/> | |||
| IReadOnlyCollection<IMessageComponent> IMessage.Components => Components; | |||