Browse Source

update ComponentBuilder summaries and boolean fields.

pull/1923/head
quin lynch 3 years ago
parent
commit
92da434d93
1 changed files with 29 additions and 30 deletions
  1. +29
    -30
      src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs

+ 29
- 30
src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs View File

@@ -76,7 +76,7 @@ namespace Discord
AddComponent(cmp, row); AddComponent(cmp, row);
break; break;
case SelectMenuComponent menu: case SelectMenuComponent menu:
WithSelectMenu(menu.Placeholder, menu.CustomId, menu.Options.Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.IsDefault)).ToList(), menu.Placeholder, menu.MinValues, menu.MaxValues, menu.IsDisabled, row);
WithSelectMenu(menu.CustomId, menu.Options.Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.IsDefault)).ToList(), menu.Placeholder, menu.MinValues, menu.MaxValues, menu.IsDisabled, row);
break; break;
} }
} }
@@ -85,7 +85,6 @@ namespace Discord
/// Adds a <see cref="SelectMenuBuilder"/> to the <see cref="ComponentBuilder"/> at the specific row. /// Adds a <see cref="SelectMenuBuilder"/> to the <see cref="ComponentBuilder"/> at the specific row.
/// If the row cannot accept the component then it will add it to a row that can. /// If the row cannot accept the component then it will add it to a row that can.
/// </summary> /// </summary>
/// <param name="label">The label of the menu.</param>
/// <param name="customId">The custom id of the menu.</param> /// <param name="customId">The custom id of the menu.</param>
/// <param name="options">The options of the menu.</param> /// <param name="options">The options of the menu.</param>
/// <param name="placeholder">The placeholder of the menu.</param> /// <param name="placeholder">The placeholder of the menu.</param>
@@ -94,7 +93,7 @@ namespace Discord
/// <param name="disabled">Whether or not the menu is disabled.</param> /// <param name="disabled">Whether or not the menu is disabled.</param>
/// <param name="row">The row to add the menu to.</param> /// <param name="row">The row to add the menu to.</param>
/// <returns></returns> /// <returns></returns>
public ComponentBuilder WithSelectMenu(string label, string customId, List<SelectMenuOptionBuilder> options,
public ComponentBuilder WithSelectMenu(string customId, List<SelectMenuOptionBuilder> options,
string placeholder = null, int minValues = 1, int maxValues = 1, bool disabled = false, int row = 0) string placeholder = null, int minValues = 1, int maxValues = 1, bool disabled = false, int row = 0)
{ {
return WithSelectMenu(new SelectMenuBuilder() return WithSelectMenu(new SelectMenuBuilder()
@@ -413,7 +412,7 @@ namespace Discord
/// <summary> /// <summary>
/// Gets or sets whether the current button is disabled. /// Gets or sets whether the current button is disabled.
/// </summary> /// </summary>
public bool Disabled { get; set; }
public bool IsDisabled { get; set; }




private string _label; private string _label;
@@ -432,14 +431,14 @@ namespace Discord
/// <param name="customId">The custom ID of this button.</param> /// <param name="customId">The custom ID of this button.</param>
/// <param name="style">The custom ID of this button.</param> /// <param name="style">The custom ID of this button.</param>
/// <param name="emote">The emote of this button.</param> /// <param name="emote">The emote of this button.</param>
/// <param name="disabled">Disabled this button or not.</param>
public ButtonBuilder(string label = null, string customId = null, ButtonStyle style = ButtonStyle.Primary, string url = null, IEmote emote = null, bool disabled = false)
/// <param name="isDisabled">Disabled this button or not.</param>
public ButtonBuilder(string label = null, string customId = null, ButtonStyle style = ButtonStyle.Primary, string url = null, IEmote emote = null, bool isDisabled = false)
{ {
CustomId = customId; CustomId = customId;
Style = style; Style = style;
Url = url; Url = url;
Label = label; Label = label;
Disabled = disabled;
IsDisabled = isDisabled;
Emote = emote; Emote = emote;
} }


@@ -452,7 +451,7 @@ namespace Discord
Style = button.Style; Style = button.Style;
Url = button.Url; Url = button.Url;
Label = button.Label; Label = button.Label;
Disabled = button.Disabled;
IsDisabled = button.Disabled;
Emote = button.Emote; Emote = button.Emote;
} }


@@ -566,11 +565,11 @@ namespace Discord
/// <summary> /// <summary>
/// Sets whether the current button is disabled. /// Sets whether the current button is disabled.
/// </summary> /// </summary>
/// <param name="disabled">Whether the current button is disabled or not.</param>
/// <param name="isDisabled">Whether the current button is disabled or not.</param>
/// <returns>The current builder.</returns> /// <returns>The current builder.</returns>
public ButtonBuilder WithDisabled(bool disabled)
public ButtonBuilder WithDisabled(bool isDisabled)
{ {
Disabled = disabled;
IsDisabled = isDisabled;
return this; return this;
} }


@@ -601,7 +600,7 @@ namespace Discord
else if (string.IsNullOrEmpty(CustomId)) else if (string.IsNullOrEmpty(CustomId))
throw new InvalidOperationException("Non-link buttons must have a custom id associated with them"); throw new InvalidOperationException("Non-link buttons must have a custom id associated with them");


return new ButtonComponent(Style, Label, Emote, CustomId, Url, Disabled);
return new ButtonComponent(Style, Label, Emote, CustomId, Url, IsDisabled);
} }
} }


@@ -718,7 +717,7 @@ namespace Discord
/// <summary> /// <summary>
/// Gets or sets whether the current menu is disabled. /// Gets or sets whether the current menu is disabled.
/// </summary> /// </summary>
public bool Disabled { get; set; }
public bool IsDisabled { get; set; }


private List<SelectMenuOptionBuilder> _options = new List<SelectMenuOptionBuilder>(); private List<SelectMenuOptionBuilder> _options = new List<SelectMenuOptionBuilder>();
private int _minValues = 1; private int _minValues = 1;
@@ -740,7 +739,7 @@ namespace Discord
CustomId = selectMenu.Placeholder; CustomId = selectMenu.Placeholder;
MaxValues = selectMenu.MaxValues; MaxValues = selectMenu.MaxValues;
MinValues = selectMenu.MinValues; MinValues = selectMenu.MinValues;
Disabled = selectMenu.IsDisabled;
IsDisabled = selectMenu.IsDisabled;
Options = selectMenu.Options? Options = selectMenu.Options?
.Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.IsDefault)) .Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.IsDefault))
.ToList(); .ToList();
@@ -754,13 +753,13 @@ namespace Discord
/// <param name="placeholder">The placeholder of this select menu.</param> /// <param name="placeholder">The placeholder of this select menu.</param>
/// <param name="maxValues">The max values of this select menu.</param> /// <param name="maxValues">The max values of this select menu.</param>
/// <param name="minValues">The min values of this select menu.</param> /// <param name="minValues">The min values of this select menu.</param>
/// <param name="disabled">Disabled this select menu or not.</param>
public SelectMenuBuilder(string customId, List<SelectMenuOptionBuilder> options, string placeholder = null, int maxValues = 1, int minValues = 1, bool disabled = false)
/// <param name="isDisabled">Disabled this select menu or not.</param>
public SelectMenuBuilder(string customId, List<SelectMenuOptionBuilder> options, string placeholder = null, int maxValues = 1, int minValues = 1, bool isDisabled = false)
{ {
CustomId = customId; CustomId = customId;
Options = options; Options = options;
Placeholder = placeholder; Placeholder = placeholder;
Disabled = disabled;
IsDisabled = isDisabled;
MaxValues = maxValues; MaxValues = maxValues;
MinValues = minValues; MinValues = minValues;
} }
@@ -873,13 +872,13 @@ namespace Discord
/// <summary> /// <summary>
/// Sets whether the current menu is disabled. /// Sets whether the current menu is disabled.
/// </summary> /// </summary>
/// <param name="disabled">Whether the current menu is disabled or not.</param>
/// <param name="isDisabled">Whether the current menu is disabled or not.</param>
/// <returns> /// <returns>
/// The current builder. /// The current builder.
/// </returns> /// </returns>
public SelectMenuBuilder WithDisabled(bool disabled)
public SelectMenuBuilder WithDisabled(bool isDisabled)
{ {
Disabled = disabled;
IsDisabled = isDisabled;
return this; return this;
} }


@@ -891,7 +890,7 @@ namespace Discord
{ {
var options = Options?.Select(x => x.Build()).ToList(); var options = Options?.Select(x => x.Build()).ToList();


return new SelectMenuComponent(CustomId, options, Placeholder, MinValues, MaxValues, Disabled);
return new SelectMenuComponent(CustomId, options, Placeholder, MinValues, MaxValues, IsDisabled);
} }
} }


@@ -991,7 +990,7 @@ namespace Discord
/// <summary> /// <summary>
/// Gets or sets the whether or not this option will render selected by default. /// Gets or sets the whether or not this option will render selected by default.
/// </summary> /// </summary>
public bool? Default { get; set; }
public bool? IsDefault { get; set; }


private string _label; private string _label;
private string _value; private string _value;
@@ -1009,14 +1008,14 @@ namespace Discord
/// <param name="value">The value of this option.</param> /// <param name="value">The value of this option.</param>
/// <param name="description">The description of this option.</param> /// <param name="description">The description of this option.</param>
/// <param name="emote">The emote of this option.</param> /// <param name="emote">The emote of this option.</param>
/// <param name="default">Render this option as selected by default or not.</param>
public SelectMenuOptionBuilder(string label, string value, string description = null, IEmote emote = null, bool? @default = null)
/// <param name="isDefault">Render this option as selected by default or not.</param>
public SelectMenuOptionBuilder(string label, string value, string description = null, IEmote emote = null, bool? isDefault = null)
{ {
Label = label; Label = label;
Value = value; Value = value;
Description = description; Description = description;
Emote = emote; Emote = emote;
Default = @default;
IsDefault = isDefault;
} }


/// <summary> /// <summary>
@@ -1028,7 +1027,7 @@ namespace Discord
Value = option.Value; Value = option.Value;
Description = option.Description; Description = option.Description;
Emote = option.Emote; Emote = option.Emote;
Default = option.IsDefault;
IsDefault = option.IsDefault;
} }


/// <summary> /// <summary>
@@ -1089,13 +1088,13 @@ namespace Discord
/// <summary> /// <summary>
/// Sets the field default. /// Sets the field default.
/// </summary> /// </summary>
/// <param name="defaultValue">The value to set the field default to.</param>
/// <param name="isDefault">The value to set the field default to.</param>
/// <returns> /// <returns>
/// The current builder. /// The current builder.
/// </returns> /// </returns>
public SelectMenuOptionBuilder WithDefault(bool defaultValue)
public SelectMenuOptionBuilder WithDefault(bool isDefault)
{ {
Default = defaultValue;
IsDefault = isDefault;
return this; return this;
} }


@@ -1105,7 +1104,7 @@ namespace Discord
/// <returns>The newly built <see cref="SelectMenuOption"/>.</returns> /// <returns>The newly built <see cref="SelectMenuOption"/>.</returns>
public SelectMenuOption Build() public SelectMenuOption Build()
{ {
return new SelectMenuOption(Label, Value, Description, Emote, Default);
return new SelectMenuOption(Label, Value, Description, Emote, IsDefault);
} }
} }
} }

Loading…
Cancel
Save