Browse Source

Enforce valid button styles (#2157)

Co-authored-by: CottageDwellingCat <80918250+CottageDwellingCat@users.noreply.github.com>
tags/3.4.0
Quin Lynch GitHub 3 years ago
parent
commit
507a18d389
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions
  1. +3
    -0
      src/Discord.Net.Core/Entities/Interactions/MessageComponents/ComponentBuilder.cs

+ 3
- 0
src/Discord.Net.Core/Entities/Interactions/MessageComponents/ComponentBuilder.cs View File

@@ -613,6 +613,9 @@ namespace Discord
if (!(string.IsNullOrEmpty(Url) ^ string.IsNullOrEmpty(CustomId)))
throw new InvalidOperationException("A button must contain either a URL or a CustomId, but not both!");

if (Style == 0)
throw new ArgumentException("A button must have a style.", nameof(Style));

if (Style == ButtonStyle.Link)
{
if (string.IsNullOrEmpty(Url))


Loading…
Cancel
Save