K
Kord4mo ago
Solaris

User installed command events not being received.

My application has User Install enabled in the developer portal and both integration_types and contexts are also added to the commands that should be used by users and the types of channels they can be used in. Kord doesn't official support User Apps but I modified the outgoing payload to add the two fields which does work, and some checks once an interaction is received to determine if it's an user app or server app integration type. The issue is I only receive events if the bot was installed to the guild. Previously (several hours ago), I did receive events for user installed apps in other guilds, DMs, and Group DMs. I've tried deleting the commands and adding them back, tried unauthorising the app and authorising them again, and removing the two fields above to add them back. Nothing seems to fix this issue. If code is useful:
val serializedCommands = Json.encodeToJsonElement(globalCommandBuilder.build())
val updatedCommands = ArrayList<JsonElement>()

for (serializedCommand in serializedCommands.jsonArray) {
val obj = serializedCommand.jsonObject.toMutableMap()
obj["integration_types"] = JsonArray(listOf(JsonPrimitive(0), JsonPrimitive(1)))
obj["contexts"] = JsonArray(listOf(JsonPrimitive(0), JsonPrimitive(1), JsonPrimitive(2)))
updatedCommands.add(JsonObject(obj))
}

kord.rest.unsafe(Route.GlobalApplicationCommandsCreate) {
keys[Route.ApplicationId] = kord.rest.application.getCurrentApplicationInfo().id
body(JsonElement.serializer(), JsonArray(updatedCommands))
}

// ...

kord.on<ChatInputCommandInteractionCreateEvent> {
println(interaction) // only receives guild install interactions, not user install interactions
}
val serializedCommands = Json.encodeToJsonElement(globalCommandBuilder.build())
val updatedCommands = ArrayList<JsonElement>()

for (serializedCommand in serializedCommands.jsonArray) {
val obj = serializedCommand.jsonObject.toMutableMap()
obj["integration_types"] = JsonArray(listOf(JsonPrimitive(0), JsonPrimitive(1)))
obj["contexts"] = JsonArray(listOf(JsonPrimitive(0), JsonPrimitive(1), JsonPrimitive(2)))
updatedCommands.add(JsonObject(obj))
}

kord.rest.unsafe(Route.GlobalApplicationCommandsCreate) {
keys[Route.ApplicationId] = kord.rest.application.getCurrentApplicationInfo().id
body(JsonElement.serializer(), JsonArray(updatedCommands))
}

// ...

kord.on<ChatInputCommandInteractionCreateEvent> {
println(interaction) // only receives guild install interactions, not user install interactions
}
Why might this be happening?
11 Replies
LustigerLurch
LustigerLurch4mo ago
i haven't yet looked into user-installed apps, but let me know if you figure it out
SchlaubiBus
SchlaubiBus4mo ago
I receive user installed app interactions just fine
Solaris
SolarisOP4mo ago
I did previously, but now I don't receive them at all. I tested it with a node.js app and I do receive them so it's something with Kord that isn't working
Solaris
SolarisOP4mo ago
I even wrote some code to limit sub commands to guilds while others can be used everywhere. User apps worked then since I had to test the code after writing it, but now I just don't receive events
No description
Solaris
SolarisOP4mo ago
Is there something different with your listeners that might point me in the right direction?
SchlaubiBus
SchlaubiBus4mo ago
I use kordex
Solaris
SolarisOP4mo ago
ah, i setup a custom system because i prefer this method of defining commands is there a generic InteractionCreateEvent i can listen to? or even a raw event?
SchlaubiBus
SchlaubiBus4mo ago
It's called InteractionCreateEvent You can also turn the log level to trace That way you can see whether the event comes in
Solaris
SolarisOP4mo ago
I do receive the user app interaaction by the generic InteractionCreateEvent I'm not sure how to do that exactly
SchlaubiBus
SchlaubiBus4mo ago
I am in bed rn, so simply Google how to setup an slf4j impl and how to configure that Can't give a detailed explanation rn
Solaris
SolarisOP4mo ago
That's all good, I can figure that out. At least I know I'm receiving the event but Kord isn't processing it anymore Ah I found the issue, apparently you can't call ChatInputCommandInteraction#getChannel() as a user app, it throws a 403. Since I use reflection in my system it silently went by when using Callable#callSuspendBy(). I thought the JVM would still throw an error but I suppose not. I thought of allowing the user to enable/disable other users from using interactions with them but it appears you can't get the channel to see if it's a DM channel or the members in it. It makes sense since it's ran by the user but it also respects the permissions the user has, so if they can see the channel, then the user app interaction should be able to as well? Talking to advaith about this, user apps can only access what is in the interaction. I thought it could get some basic info like the channel it was in but the routes are bot only and the bot can't be present in DMs/guilds it wasn't added to
Want results from more Discord servers?
Add your server