Skip to content

Commit

Permalink
Move openActivity to the correct interface
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Oct 25, 2024
1 parent 0436913 commit 718206c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.kord.core.behavior.interaction

import dev.kord.common.entity.InteractionResponseType
import dev.kord.common.entity.Snowflake
import dev.kord.core.behavior.channel.MessageChannelBehavior
import dev.kord.core.entity.KordEntity
Expand All @@ -9,6 +10,7 @@ import dev.kord.core.entity.interaction.Interaction
import dev.kord.core.supplier.EntitySupplyStrategy
import dev.kord.core.supplier.getChannelOf
import dev.kord.core.supplier.getChannelOfOrNull
import dev.kord.rest.json.request.InteractionResponseCreateRequest

/** The behavior of an [Interaction]. */
public interface InteractionBehavior : KordEntity, Strategizable {
Expand All @@ -25,6 +27,17 @@ public interface InteractionBehavior : KordEntity, Strategizable {
/** The behavior of the channel the interaction was sent from. */
public val channel: MessageChannelBehavior get() = MessageChannelBehavior(channelId, kord)

/**
* Opens the [Activity](https://discord.com/developers/docs/activities/overview) of this application.
* **Note:** This requires activities to be enabled for this application
*/
public suspend fun openActivity() {
kord.rest.interaction.createInteractionResponse(
applicationId, token,
InteractionResponseCreateRequest(InteractionResponseType.LaunchActivity)
)
}

public suspend fun getChannelOrNull(): MessageChannel? = supplier.getChannelOfOrNull(channelId)

public suspend fun getChannel(): MessageChannel = supplier.getChannelOf(channelId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,5 @@ public sealed interface InteractionResponseBehavior : KordObject, Strategizable
public suspend fun getFollowupMessage(messageId: Snowflake): FollowupMessage =
supplier.getFollowupMessage(applicationId, token, messageId)

/**
* Opens the [Activity](https://discord.com/developers/docs/activities/overview) of this application.
* **Note:** This requires activities to be enabled for this application
*/
public suspend fun openActivity() {
kord.rest.interaction.createInteractionResponse(
applicationId, token,
InteractionResponseCreateRequest(InteractionResponseType.LaunchActivity)
)
}

override fun withStrategy(strategy: EntitySupplyStrategy<*>): InteractionResponseBehavior
}

0 comments on commit 718206c

Please sign in to comment.