Browse Source

Null or empty fix (#176)

* Add components and stickers to ReplyAsync extension

* Fixed null or empty

* Changed Label to Description

* -||-

Co-authored-by: quin lynch <lynchquin@gmail.com>
pull/1923/head
Simon Hjorthøj GitHub 4 years ago
parent
commit
96af3cc937
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 15 deletions
  1. +1
    -13
      src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs
  2. +2
    -2
      src/Discord.Net.Core/Extensions/MessageExtensions.cs

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

@@ -367,8 +367,6 @@ namespace Discord
if (value.Length < 1) if (value.Length < 1)
throw new ArgumentException("Button label must be 1 character or more!", paramName: nameof(Label)); throw new ArgumentException("Button label must be 1 character or more!", paramName: nameof(Label));
} }
else
throw new ArgumentException("Button label must not be null or empty!", paramName: nameof(Label));


_label = value; _label = value;
} }
@@ -391,8 +389,6 @@ namespace Discord
if (value.Length < 1) if (value.Length < 1)
throw new ArgumentException("Custom Id must be 1 character or more!", paramName: nameof(CustomId)); throw new ArgumentException("Custom Id must be 1 character or more!", paramName: nameof(CustomId));
} }
else
throw new ArgumentException("Custom Id must not be null or empty!", paramName: nameof(CustomId));
_customId = value; _customId = value;
} }
} }
@@ -644,8 +640,6 @@ namespace Discord
if (value.Length < 1) if (value.Length < 1)
throw new ArgumentException("Custom Id must be 1 character or more!", paramName: nameof(CustomId)); throw new ArgumentException("Custom Id must be 1 character or more!", paramName: nameof(CustomId));
} }
else
throw new ArgumentException("Custom Id must not be null or empty!", paramName: nameof(CustomId));
_customId = value; _customId = value;
} }
} }
@@ -667,8 +661,6 @@ namespace Discord
if (value.Length < 1) if (value.Length < 1)
throw new ArgumentException("The placeholder must be 1 character or more!", paramName: nameof(Placeholder)); throw new ArgumentException("The placeholder must be 1 character or more!", paramName: nameof(Placeholder));
} }
else
throw new ArgumentException("The placeholder must not be null or empty!", paramName: nameof(Placeholder));


_placeholder = value; _placeholder = value;
} }
@@ -938,8 +930,6 @@ namespace Discord
if (value.Length < 1) if (value.Length < 1)
throw new ArgumentException("Select option label must be 1 character or more!", paramName: nameof(Label)); throw new ArgumentException("Select option label must be 1 character or more!", paramName: nameof(Label));
} }
else
throw new ArgumentException("Select option label must not be null or empty!", paramName: nameof(Label));


_label = value; _label = value;
} }
@@ -973,7 +963,7 @@ namespace Discord
/// Gets or sets this menu options description. /// Gets or sets this menu options description.
/// </summary> /// </summary>
/// <exception cref="ArgumentException" accessor="set"><see cref="Description"/> length exceeds <see cref="MaxDescriptionLength"/>.</exception> /// <exception cref="ArgumentException" accessor="set"><see cref="Description"/> length exceeds <see cref="MaxDescriptionLength"/>.</exception>
/// <exception cref="ArgumentException" accessor="set"><see cref="Label"/> length subceeds 1.</exception>
/// <exception cref="ArgumentException" accessor="set"><see cref="Description"/> length subceeds 1.</exception>
public string Description public string Description
{ {
get => _description; get => _description;
@@ -986,8 +976,6 @@ namespace Discord
if (value.Length < 1) if (value.Length < 1)
throw new ArgumentException("The description must be 1 character or more!", paramName: nameof(Label)); throw new ArgumentException("The description must be 1 character or more!", paramName: nameof(Label));
} }
else
throw new ArgumentException("The description must not be null or empty!", paramName: nameof(Label));


_description = value; _description = value;
} }


+ 2
- 2
src/Discord.Net.Core/Extensions/MessageExtensions.cs View File

@@ -87,9 +87,9 @@ namespace Discord
/// A task that represents an asynchronous send operation for delivering the message. The task result /// A task that represents an asynchronous send operation for delivering the message. The task result
/// contains the sent message. /// contains the sent message.
/// </returns> /// </returns>
public static async Task<IUserMessage> ReplyAsync(this IUserMessage msg, string text = null, bool isTTS = false, Embed embed = null, AllowedMentions allowedMentions = null, RequestOptions options = null)
public static async Task<IUserMessage> ReplyAsync(this IUserMessage msg, string text = null, bool isTTS = false, Embed embed = null, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, ISticker[] stickers = null)
{ {
return await msg.Channel.SendMessageAsync(text, isTTS, embed, options, allowedMentions, new MessageReference(messageId: msg.Id)).ConfigureAwait(false);
return await msg.Channel.SendMessageAsync(text, isTTS, embed, options, allowedMentions, new MessageReference(messageId: msg.Id), components, stickers).ConfigureAwait(false);
} }
} }
} }

Loading…
Cancel
Save