Skip to content

Commit

Permalink
Removes paginator after five minutes to prevent broken buttons after …
Browse files Browse the repository at this point in the history
…restarts.
  • Loading branch information
ShindouMihou committed Jul 21, 2022
1 parent 0ac1fc5 commit 1623b09
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/pw/mihou/amelia/commands/FeedsCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import org.javacord.api.event.interaction.ButtonClickEvent
import org.javacord.api.interaction.callback.InteractionOriginalResponseUpdater
import pw.mihou.amelia.db.FeedDatabase
import pw.mihou.amelia.models.FeedModel
import pw.mihou.amelia.scheduledExecutorService
import pw.mihou.nexus.features.command.facade.NexusCommandEvent
import pw.mihou.nexus.features.command.facade.NexusHandler
import pw.mihou.nexus.features.paginator.NexusPaginatorBuilder
import pw.mihou.nexus.features.paginator.enums.NexusPaginatorButtonAssignment
import pw.mihou.nexus.features.paginator.facade.NexusPaginatorCursor
import pw.mihou.nexus.features.paginator.facade.NexusPaginatorEvents
import java.awt.Color
import java.util.concurrent.TimeUnit

@Suppress("UNUSED")
object FeedsCommand: NexusHandler {
Expand Down Expand Up @@ -51,6 +53,14 @@ object FeedsCommand: NexusHandler {
})
.build()
.send(event.baseEvent.interaction, event.respondLater().join())
.thenAccept { instance ->
scheduledExecutorService.schedule({
instance.parent.destroy(instance.uuid)
instance.parent.destroy()

instance.message.thenAccept { message -> message.createUpdater().removeAllComponents().replaceMessage() }
}, 5, TimeUnit.MINUTES)
}
}

private fun embed(server: Server, cursor: NexusPaginatorCursor<List<FeedModel>>): EmbedBuilder {
Expand Down

0 comments on commit 1623b09

Please sign in to comment.