-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slash commands #145
Slash commands #145
Conversation
Since interactions don't need a kord instance to exist.
The team agreed on the following solution:
How does this solve the problemKord will introduce a event handler for the interaction create event, which keeps track of the nullity of the appId. In-case the appId was null, the event handler won't emit an Below are some code samples val kord = Kord(bot_id) { appid = null }
kord.on<InteractionBehavior> { // flow will always be empty since `appId` is null
} val kord = Kord(bot_id) { appid = null }
kord.on<Interaction> { // flow emits even if appId is null
} val kord = Kord(bot_id) { appid = appId }
kord.on<InteractionBehavior> { // flow emits since appId is not null
} |
They are not allowed through this endpoint
Due to the lack of information regarding the global commands discord/discord-api-docs#2367 I've considered providing a guild application.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for the most part, missed quite a few @KordPreview in the gateway module though.
core/src/main/kotlin/gateway/handler/InteractionEventHandler.kt
Outdated
Show resolved
Hide resolved
# Conflicts: # core/src/main/kotlin/Kord.kt # core/src/main/kotlin/behavior/GuildBehavior.kt # core/src/main/kotlin/cache/data/MemberData.kt # rest/src/main/kotlin/route/Route.kt # rest/src/main/kotlin/service/RestClient.kt
What this PR should Implement
Issues encountered
As the Discord docs states , neither a slash command doesn't depend on a bot user, nor a bot user requires a slash commands to work.
Solutions proposed
One simple solution to the problem, is to allow
applicationId
be nullable as follows:But this wouldn't provide the user with a useful message or warning if the
applicationId
was null. In addition, this would require to validateapplicationId
each time we work with it.Provide an annotation warning the same way we did for intents.
However annotations can be ignored and do not provide a strict message as well.
Move interactions into their own class that works along side Kord
e.g: SlashCommands
This is the best solution we have at the moment.
The problem is that this solution limts Kord's control over slash commands overall.
if we were going to use this object to create a command from message, or any other context we will need to keep a reference and limits the flexibility of code writing.