FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

(try to) improve developer experience and docs on modal submissions by akiraveliara · Pull Request #2465 · DSharpPlus/DSharpPlus · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cs  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
19 changes: 17 additions & 2 deletions DSharpPlus/EventArgs/Interaction/IModalSubmission.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,32 @@
namespace DSharpPlus.EventArgs;

/// <summary>
/// Represents the values submitted to a component from a modal.
/// Represents the values submitted to a component from a modal. Cast this object to a typed *ModalSubmission to access the submitted data.
Comment thread
akiraveliara marked this conversation as resolved.
/// The helpers <see cref="As"/> and <see cref="Is"/> are provided for checking and retrieving the exact ModalSubmission.
/// </summary>
public interface IModalSubmission
{
/// <summary>
/// The type of component this submission represents.
/// The type of component this submission represents. Use <see cref="As"/> to cast this object accordingly to access the submitted data.
/// </summary>
public DiscordComponentType ComponentType { get; }

/// <summary>
/// The custom ID of this component.
/// </summary>
public string CustomId { get; }

/// <summary>
/// Casts this modal submission to its concrete type.
/// </summary>
public T? As<T>()
where T : class, IModalSubmission
=> this as T;

/// <summary>
/// Checks whether this modal submission is of the specified concrete type.
/// </summary>
public bool Is<T>()
where T : class, IModalSubmission
=> GetType().IsAssignableTo(typeof(T));
}
Loading

Back | FazBrowse Home | New Git URL