Skip to content

Commit

Permalink
Expose the creation of application commands behavior (kordlib#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
HopeBaron authored and DRSchlaubi committed Jun 7, 2021
1 parent cbd752b commit 71fe9c1
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
17 changes: 17 additions & 0 deletions core/src/main/kotlin/Unsafe.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import dev.kord.common.annotation.KordUnsafe
import dev.kord.common.entity.Snowflake
import dev.kord.core.behavior.*
import dev.kord.core.behavior.channel.*
import dev.kord.rest.service.InteractionService

/**
* A class that exposes the creation of `{Entity}Behavior` classes.
Expand Down Expand Up @@ -71,4 +72,20 @@ class Unsafe(private val kord: Kord) {
return "Unsafe"
}

fun guildApplicationCommand(
guildId: Snowflake,
applicationId: Snowflake,
commandId: Snowflake,
service: InteractionService = kord.rest.interaction
): GuildApplicationCommandBehavior =
GuildApplicationCommandBehavior(guildId, applicationId, commandId, service)

fun globalApplicationCommand(
applicationId: Snowflake,
commandId: Snowflake,
service: InteractionService = kord.rest.interaction
): GlobalApplicationCommandBehavior =
GlobalApplicationCommandBehavior(applicationId, commandId, service)


}
33 changes: 33 additions & 0 deletions core/src/main/kotlin/behavior/GlobalApplicationCommandBehavior.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,37 @@ interface GuildApplicationCommandBehavior : ApplicationCommandBehavior {
override suspend fun delete() {
service.deleteGuildApplicationCommand(applicationId, guildId, id)
}

}

@KordPreview
fun GuildApplicationCommandBehavior(
guildId: Snowflake,
applicationId: Snowflake,
id: Snowflake,
service: InteractionService
): GuildApplicationCommandBehavior = object : GuildApplicationCommandBehavior {
override val guildId: Snowflake
get() = guildId
override val applicationId: Snowflake
get() = applicationId
override val service: InteractionService
get() = service
override val id: Snowflake
get() = id
}


@KordPreview
fun GlobalApplicationCommandBehavior(
applicationId: Snowflake,
id: Snowflake,
service: InteractionService
): GlobalApplicationCommandBehavior = object : GlobalApplicationCommandBehavior {
override val applicationId: Snowflake
get() = applicationId
override val service: InteractionService
get() = service
override val id: Snowflake
get() = id
}

0 comments on commit 71fe9c1

Please sign in to comment.