From 46ce2220e4b9cbc8d13e8065dccfad988b95b824 Mon Sep 17 00:00:00 2001 From: HopeBaron Date: Tue, 11 May 2021 16:11:58 +0300 Subject: [PATCH 1/2] Expose the creation of application commands behavior --- core/src/main/kotlin/Unsafe.kt | 17 ++++++++++ .../GlobalApplicationCommandBehavior.kt | 33 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/core/src/main/kotlin/Unsafe.kt b/core/src/main/kotlin/Unsafe.kt index dc3edb0017e0..b09c1e206ba3 100644 --- a/core/src/main/kotlin/Unsafe.kt +++ b/core/src/main/kotlin/Unsafe.kt @@ -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. @@ -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) + + } \ No newline at end of file diff --git a/core/src/main/kotlin/behavior/GlobalApplicationCommandBehavior.kt b/core/src/main/kotlin/behavior/GlobalApplicationCommandBehavior.kt index 9c3168ed4a0d..72a0d953b6e5 100644 --- a/core/src/main/kotlin/behavior/GlobalApplicationCommandBehavior.kt +++ b/core/src/main/kotlin/behavior/GlobalApplicationCommandBehavior.kt @@ -79,4 +79,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 +} \ No newline at end of file From c1a0fb839ebabbe8658d71033986e79a6e004897 Mon Sep 17 00:00:00 2001 From: HopeBaron Date: Wed, 12 May 2021 21:37:18 +0300 Subject: [PATCH 2/2] Fix type of emitted event --- core/src/main/kotlin/gateway/handler/GuildEventHandler.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/kotlin/gateway/handler/GuildEventHandler.kt b/core/src/main/kotlin/gateway/handler/GuildEventHandler.kt index 78c7dbb2deee..6fa5709330c4 100644 --- a/core/src/main/kotlin/gateway/handler/GuildEventHandler.kt +++ b/core/src/main/kotlin/gateway/handler/GuildEventHandler.kt @@ -90,7 +90,7 @@ internal class GuildEventHandler( cache.put(data) event.guild.cache() - coreFlow.emit(GuildCreateEvent(Guild(data, kord), shard)) + coreFlow.emit(GuildUpdateEvent(Guild(data, kord), shard)) } private suspend fun handle(event: GuildDelete, shard: Int) = with(event.guild) {