discord-jda / JDA

Java wrapper for the popular chat & VOIP service: Discord https://discord.com
Apache License 2.0
4.28k stars 737 forks source link

Add `DeferrableInteractionCallbackAction` #2631

Open freya022 opened 6 months ago

freya022 commented 6 months ago

Pull Request Etiquette

Changes

Closes Issue: NaN

Description

This PR adds DeferrableInteractionCallbackAction, which is extended by ReplyCallbackAction and MessageEditCallbackAction, allowing to retrieve the InteractionHook when replying/editing a message with an interaction.

My use case is to create extensions such as:

fun <R> DeferrableInteractionCallbackAction<R>.deleteAfter(duration: Duration): RestAction<R> =
    delay(duration).onSuccess { hook.deleteOriginal() }
MinnDevelopment commented 5 months ago

Is this not enough?

fun RestAction<InteractionHook>.deleteAfter(duration: Duration): RestAction<InteractionHook>
    = delay(duration.toJavaDuration())
        .flatMap { hook -> hook.deleteOriginal().map { hook } }
freya022 commented 5 months ago

Is this not enough?

fun RestAction<InteractionHook>.deleteAfter(duration: Duration): RestAction<InteractionHook>
    = delay(duration.toJavaDuration())
        .flatMap { hook -> hook.deleteOriginal().map { hook } }

I think it is enough, but wouldn't using onSuccess be simpler?