Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DeferrableInteractionCallbackAction #2631

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

freya022
Copy link
Contributor

@freya022 freya022 commented Mar 16, 2024

Pull Request Etiquette

Changes

  • Internal code
  • Library interface (affecting end-user code)
  • Documentation
  • Other: _____

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() }

Extend ReplyCallbackAction and MessageEditCallbackAction with it
@MinnDevelopment
Copy link
Member

Is this not enough?

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

@freya022
Copy link
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants