/// <summary> /// Build the <see cref="ReactionSelectionBuilder{T}"/> to a immutable <see cref="ReactionSelection{T}"/>. /// </summary> /// <returns></returns> public override Selection <T, SocketReaction> Build() { if (Emotes.Count < Values.Count) { throw new InvalidOperationException("Value count larger than emote count! Please add more Emotes to the selection!"); } if (Emotes.Contains(CancelEmote) == true) { throw new InvalidOperationException("Please remove the cancel emote from the selection emotes!"); } if (EnableDefaultSelectionDescription == true) { var builder = new StringBuilder(); for (int i = 0; i < Values.Count; i++) { string possibility = StringConverter.Invoke(Values[i]); builder.AppendLine($"{Emotes[i]} - {possibility}"); } SelectionEmbed.AddField(Title, builder.ToString()); } return(new ReactionSelection <T>( Values?.AsReadOnlyCollection() ?? throw new ArgumentNullException(nameof(Values)), Users?.AsReadOnlyCollection() ?? throw new ArgumentNullException(nameof(Users)), SelectionEmbed?.Build() ?? throw new ArgumentNullException(nameof(SelectionEmbed)), CancelledEmbed?.Build() ?? throw new ArgumentNullException(nameof(CancelledEmbed)), TimeoutedEmbed?.Build() ?? throw new ArgumentNullException(nameof(TimeoutedEmbed)), Deletion, Emotes?.AsReadOnlyCollection() ?? throw new ArgumentNullException(nameof(Emotes)), CancelEmote ?? throw new ArgumentNullException(nameof(CancelEmote)), AllowCancel)); }