Skip to content

Commit d2118f0

Browse files
authored
Adds a action delegate parameter to RespondWithModalAsync<T>() for modifying the modal (#2226)
* add modifyModal deleagate parameter to RespondWithModalAsync extension method * change the position of the new parameter to avoid introducing a breaking change
1 parent 1c680db commit d2118f0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Discord.Net.Interactions/Extensions/IDiscordInteractionExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ public static class IDiscordInteractionExtentions
1010
/// </summary>
1111
/// <typeparam name="T">Type of the <see cref="IModal"/> implementation.</typeparam>
1212
/// <param name="interaction">The interaction to respond to.</param>
13+
/// <param name="modifyModal">Delegate that can be used to modify the modal.</param>
1314
/// <param name="options">The request options for this <see langword="async"/> request.</param>
1415
/// <returns>A task that represents the asynchronous operation of responding to the interaction.</returns>
15-
public static async Task RespondWithModalAsync<T>(this IDiscordInteraction interaction, string customId, RequestOptions options = null)
16+
public static async Task RespondWithModalAsync<T>(this IDiscordInteraction interaction, string customId, RequestOptions options = null, Action<ModalBuilder> modifyModal = null)
1617
where T : class, IModal
1718
{
1819
if (!ModalUtils.TryGet<T>(out var modalInfo))
@@ -31,6 +32,9 @@ public static async Task RespondWithModalAsync<T>(this IDiscordInteraction inter
3132
throw new InvalidOperationException($"{input.GetType().FullName} isn't a valid component info class");
3233
}
3334

35+
if (modifyModal is not null)
36+
modifyModal(builder);
37+
3438
await interaction.RespondWithModalAsync(builder.Build(), options).ConfigureAwait(false);
3539
}
3640
}

0 commit comments

Comments
 (0)