-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
273 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
core/src/main/kotlin/behavior/interaction/followup/EphemeralFollowupMessageBehavior.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
core/src/main/kotlin/behavior/interaction/followup/PublicFollowupMessageBehavior.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 2 additions & 28 deletions
30
core/src/main/kotlin/behavior/interaction/response/EphemeralInteractionResponseBehavior.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,7 @@ | ||
package behavior.interaction.response | ||
|
||
import dev.kord.common.entity.Snowflake | ||
import dev.kord.core.Kord | ||
import dev.kord.core.supplier.EntitySupplier | ||
import dev.kord.core.supplier.EntitySupplyStrategy | ||
package dev.kord.core.behavior.interaction.response | ||
|
||
/** | ||
* The behavior of an ephemeral [Discord ActionInteraction Response](https://discord.com/developers/docs/interactions/slash-commands#interaction-response) | ||
* This response is visible to *only* to the user who made the interaction. | ||
*/ | ||
public interface EphemeralInteractionResponseBehavior : InteractionResponseBehavior { | ||
|
||
override fun withStrategy(strategy: EntitySupplyStrategy<*>): EphemeralInteractionResponseBehavior = | ||
EphemeralInteractionResponseBehavior(applicationId, token, kord, strategy) | ||
} | ||
|
||
|
||
public fun EphemeralInteractionResponseBehavior( | ||
applicationId: Snowflake, | ||
token: String, | ||
kord: Kord, | ||
strategy: EntitySupplyStrategy<*> = kord.resources.defaultStrategy, | ||
): EphemeralInteractionResponseBehavior = | ||
object : EphemeralInteractionResponseBehavior { | ||
override val applicationId: Snowflake = applicationId | ||
|
||
override val token: String = token | ||
|
||
override val kord: Kord = kord | ||
|
||
override val supplier: EntitySupplier = strategy.supply(kord) | ||
} | ||
public sealed interface EphemeralInteractionResponseBehavior : InteractionResponseBehavior |
31 changes: 31 additions & 0 deletions
31
.../main/kotlin/behavior/interaction/response/EphemeralMessageInteractionResponseBehavior.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package dev.kord.core.behavior.interaction.response | ||
|
||
|
||
import dev.kord.common.entity.Snowflake | ||
import dev.kord.core.Kord | ||
import dev.kord.core.supplier.EntitySupplier | ||
import dev.kord.core.supplier.EntitySupplyStrategy | ||
|
||
public interface EphemeralMessageInteractionResponseBehavior : EphemeralInteractionResponseBehavior, | ||
MessageInteractionResponseBehavior { | ||
override fun withStrategy(strategy: EntitySupplyStrategy<*>): EphemeralMessageInteractionResponseBehavior { | ||
return EphemeralMessageInteractionResponseBehavior(applicationId, token, kord, strategy.supply(kord)) | ||
} | ||
} | ||
|
||
|
||
public fun EphemeralMessageInteractionResponseBehavior( | ||
applicationId: Snowflake, | ||
token: String, | ||
kord: Kord, | ||
supplier: EntitySupplier = kord.defaultSupplier, | ||
): EphemeralMessageInteractionResponseBehavior = | ||
object : EphemeralMessageInteractionResponseBehavior { | ||
override val applicationId: Snowflake = applicationId | ||
|
||
override val token: String = token | ||
|
||
override val kord: Kord = kord | ||
|
||
override val supplier: EntitySupplier = supplier | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
core/src/main/kotlin/behavior/interaction/response/MessageInteractionResponseBehavior.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package dev.kord.core.behavior.interaction.response | ||
|
||
import dev.kord.core.cache.data.toData | ||
import dev.kord.core.entity.Message | ||
import dev.kord.rest.builder.message.modify.InteractionResponseModifyBuilder | ||
import dev.kord.rest.request.RestRequestException | ||
import kotlin.contracts.InvocationKind | ||
import kotlin.contracts.contract | ||
|
||
public sealed interface MessageInteractionResponseBehavior : InteractionResponseBehavior | ||
/** | ||
* Requests to edit this interaction response. | ||
* | ||
* @return The edited [Message] of the interaction response. | ||
* | ||
* @throws RestRequestException if something went wrong during the request. | ||
*/ | ||
public suspend inline fun MessageInteractionResponseBehavior.edit( | ||
builder: InteractionResponseModifyBuilder.() -> Unit, | ||
): Message { | ||
contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) } | ||
val message = kord.rest.interaction.modifyInteractionResponse(applicationId, token, builder) | ||
return Message(message.toData(), kord) | ||
} | ||
|
32 changes: 32 additions & 0 deletions
32
core/src/main/kotlin/behavior/interaction/response/PopupInteractionResponseBehavior.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package dev.kord.core.behavior.interaction.response | ||
|
||
import dev.kord.common.entity.Snowflake | ||
import dev.kord.core.Kord | ||
import dev.kord.core.behavior.interaction.ActionInteractionBehavior | ||
import dev.kord.core.entity.Strategizable | ||
import dev.kord.core.supplier.EntitySupplier | ||
import dev.kord.core.supplier.EntitySupplyStrategy | ||
|
||
public interface PopupInteractionResponseBehavior : InteractionResponseBehavior { | ||
|
||
override fun withStrategy(strategy: EntitySupplyStrategy<*>): PopupInteractionResponseBehavior { | ||
return PopupInteractionResponseBehavior(applicationId, token, kord, strategy.supply(kord)) | ||
} | ||
} | ||
|
||
|
||
public fun PopupInteractionResponseBehavior( | ||
applicationId: Snowflake, | ||
token: String, | ||
kord: Kord, | ||
supplier: EntitySupplier = kord.defaultSupplier, | ||
): PopupInteractionResponseBehavior = | ||
object : PopupInteractionResponseBehavior { | ||
override val applicationId: Snowflake = applicationId | ||
|
||
override val token: String = token | ||
|
||
override val kord: Kord = kord | ||
|
||
override val supplier: EntitySupplier = supplier | ||
} |
Oops, something went wrong.