[Feature] RespondWithModal() which accepts an IModal instance as template (#2564)

* introduce overload for responding to an interaction with an instatiated IModal obj

* add inline docs to ModalInfo.PropertyInfo

* Apply suggestions from code review

Co-authored-by: Casmir <68127614+csmir@users.noreply.github.com>

---------

Co-authored-by: Casmir <68127614+csmir@users.noreply.github.com>
This commit is contained in:
Cenk Ergen
2023-02-06 13:52:16 +03:00
committed by GitHub
parent 91e208474d
commit e7bda0f8a5
7 changed files with 79 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Discord.Interactions.Builders
{
@@ -38,6 +39,11 @@ namespace Discord.Interactions.Builders
/// </summary>
Type Type { get; }
/// <summary>
/// Get the <see cref="PropertyInfo"/> of this component's property.
/// </summary>
PropertyInfo PropertyInfo { get; }
/// <summary>
/// Get the <see cref="ComponentTypeConverter"/> assigned to this input.
/// </summary>

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Discord.Interactions.Builders
{
@@ -33,6 +34,9 @@ namespace Discord.Interactions.Builders
/// <inheritdoc/>
public Type Type { get; private set; }
/// <inheritdoc/>
public PropertyInfo PropertyInfo { get; internal set; }
/// <inheritdoc/>
public ComponentTypeConverter TypeConverter { get; private set; }

View File

@@ -37,6 +37,8 @@ namespace Discord.Interactions.Builders
if (!typeof(IModal).IsAssignableFrom(type))
throw new ArgumentException($"Must be an implementation of {nameof(IModal)}", nameof(type));
Type = type;
_interactionService = interactionService;
_components = new();
}