[Fix] ButtonBuilder validations(#2943)
This commit is contained in:
@@ -267,9 +267,6 @@ public class ButtonBuilder
|
|||||||
/// <exception cref="InvalidOperationException">A non-link button must contain a custom id</exception>
|
/// <exception cref="InvalidOperationException">A non-link button must contain a custom id</exception>
|
||||||
public ButtonComponent Build()
|
public ButtonComponent Build()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(Label) && Emote is null)
|
|
||||||
throw new InvalidOperationException("A button must have an Emote or a label!");
|
|
||||||
|
|
||||||
var a = 0;
|
var a = 0;
|
||||||
if (!string.IsNullOrWhiteSpace(Url))
|
if (!string.IsNullOrWhiteSpace(Url))
|
||||||
a++;
|
a++;
|
||||||
@@ -293,6 +290,8 @@ public class ButtonBuilder
|
|||||||
case ButtonStyle.Success:
|
case ButtonStyle.Success:
|
||||||
case ButtonStyle.Danger:
|
case ButtonStyle.Danger:
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(Label) && Emote is null)
|
||||||
|
throw new InvalidOperationException("A button must have an Emote or a label!");
|
||||||
if (string.IsNullOrWhiteSpace(CustomId))
|
if (string.IsNullOrWhiteSpace(CustomId))
|
||||||
throw new InvalidOperationException("Non-link and non-premium buttons must have a custom id associated with them");
|
throw new InvalidOperationException("Non-link and non-premium buttons must have a custom id associated with them");
|
||||||
|
|
||||||
@@ -301,6 +300,8 @@ public class ButtonBuilder
|
|||||||
|
|
||||||
case ButtonStyle.Link:
|
case ButtonStyle.Link:
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(Label) && Emote is null)
|
||||||
|
throw new InvalidOperationException("A button must have an Emote or a label!");
|
||||||
if (string.IsNullOrWhiteSpace(Url))
|
if (string.IsNullOrWhiteSpace(Url))
|
||||||
throw new InvalidOperationException("Link buttons must have a link associated with them");
|
throw new InvalidOperationException("Link buttons must have a link associated with them");
|
||||||
UrlValidation.ValidateButton(Url);
|
UrlValidation.ValidateButton(Url);
|
||||||
|
|||||||
Reference in New Issue
Block a user