Modal Components v2 Single-select Typeconverters, Rest, and Patches (#3209)
* implement modal v2 components to rest interaction extensions * update rest extensions inline docs * rename respondwithmodal to respondwithmodalasync * add type converters for single user, role, channel, mentionable selects and file-uploads * update rest interaction module base with new async methods * code cleanup and bug fixes in default snowflake modal typeconverter * add default snowflake typeconverters to interaction service * fix nre in respondwithmodal extension method
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Discord.Interactions
|
||||
{
|
||||
@@ -337,26 +338,6 @@ namespace Discord.Interactions
|
||||
MinLength = commandOption.MinLength,
|
||||
};
|
||||
|
||||
public static Modal ToModal(this ModalInfo modalInfo, string customId, Action<ModalBuilder> modifyModal = null)
|
||||
{
|
||||
var builder = new ModalBuilder(modalInfo.Title, customId);
|
||||
|
||||
foreach (var input in modalInfo.Components)
|
||||
switch (input)
|
||||
{
|
||||
case TextInputComponentInfo textComponent:
|
||||
builder.AddTextInput(textComponent.Label, textComponent.CustomId, textComponent.Style, textComponent.Placeholder, textComponent.IsRequired ? textComponent.MinLength : null,
|
||||
textComponent.MaxLength, textComponent.IsRequired, textComponent.InitialValue);
|
||||
break;
|
||||
default:
|
||||
throw new InvalidOperationException($"{input.GetType().FullName} isn't a valid component info class");
|
||||
}
|
||||
|
||||
modifyModal?.Invoke(builder);
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
public static GuildPermission? SanitizeGuildPermissions(this GuildPermission permissions) =>
|
||||
permissions == 0 ? null : permissions;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user