Open DRSchlaubi opened 3 years ago
There shouldn't be any huge complications with transforming kxc to use slash commands except for arguments.
Discord expects arguments to have a certain type (STRING, INTEGER, BOOLEAN, USER, CHANNEL, ROLE). We could mask all arguments as STRING, as that is how they're implemented right now, but it would obviously be much better to fully integrate with Discord.
Yeah eventually we should support the types as the types Discord offers because the Discord apps will probabbly provide better ui for specific types
kxc doesn't really know which arguments represent which type, and all implementations are effectively file-private as well. As is, there's no way for us to map arguments to Discord argument types. I had rather kept the platform target-agnostic, but Discord was always going to be the main focus, so I'm willing to give that idea up for native integration with Discord's argument types.
Alternatively, we could introduce a separate DSL/event handler/event source/arguments for slash commands. Discord's concept is sufficiently different enough for it. If I were to, on the spot, convert a part of the example given by Discord, I'd implement it something like this:
fun example() = slashCommand("permissions") {
description = "Get or edit permissions for a user or a role"
group("user") {
description = "Get or edit permissions for a user"
command("get",
user(name = "user", description = "The user to get"),
channel(name = "channel", description = "The channel permissions to get. If omitted, the guild permissions will be returned").optional()
){ user: User, channel: Channel? ->
//TODO
}
}
}
I'm not saying this is how it should look though (I just wrote this in a couple of minutes, and I understand that Discord's Argument objects are a lot more complex than provided in the example), but locking the feature behind a custom DSL is probably going to be easier to implement. Discord has only a few argument types, and we can allow conversion of standard types to Discord's STRING types as well as mappings inbetween if that's required.
I agree. Making a DSL does not require changing all the existing arguments and we won't lose the ability to add support for anything else but Discord if that's ever going to hapen
It seems that discord arguments aren't too much different from the ones, we've currently got with Kordx, except I agree with Bart it might be a little complicated to make, I think they should make a separate library-based just on "slash-commands" in general, it seems to be hassle to even get through the latency issues with it right now.
Related to kordlib/kord#142 There should be a way of registering kordx.commands commands with Discord slash commands