-
Notifications
You must be signed in to change notification settings - Fork 4
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
Cannot use buttons in version: 7c8e8ad #8
Comments
Hey @devan-mysterio! I assume you've tried to follow the instructions in the README? If so, they seem to be outdated. The way that this library generates button IDs are as follows: "$commandName.${button.id.ifEmpty { function.name.lowercase() }}" Please give this a try. Note that the commandName is the Here's an example: If you are still unable to fix the issue, please provide some code samples.
|
Wait, I'm confused where do I put that code at? |
That code I provided is simply how the library generates IDs, you aren't meant to put it anywhere. You just gotta update your button IDs when adding them to your message (in the action row). e.g. @Command
fun mood(event: SlashCommandEvent) {
event.reply("How are you?").addActionRow(
success(id = "Mood.good", label = "Good"), // here
danger(id = "Mood.bad", label = "Bad") // and here, notice the `id = "Mood.bad"`
).queue()
} |
And then the function would be just fun good(...) |
Correct! It should work as intended now. |
I'll definitely give it a try when I wake up |
but let me ask what if they're in events? how would that work? |
What do you mean by "if they're in events"? |
They error when using buttons in modals i made a modal and it errors when i check the buttoninteractionevent saying unknown button blah blah |
Can you share the code where you create the button and the declaration of the handler function? |
Don't mind it, still needs cleaned up but eh class StaffAppListener : SuspendEventListener() {
} |
The library automatically registers an event listener for The issue here is you creating 'regular' buttons which are not bound to any command/handler function:
(Within a command this would look something like When clicked, the event listener (obviously) can't find handlers for the IDs Hope that helps. |
but the buttons aren't added when i use the cmd @command
} class StaffAppListener : SuspendEventListener() {
} |
You are not adding any buttons in your command, you're simply replying with a modal. The custom listener you wrote only handles This is not an issue with this library, I'll be closing this issue. |
Well it errors saying unknown button https://i.imgur.com/QssSu2n.png |
It's still erroring because this library also handles e.g. @Command
class StaffApp : SlashCommand() {
// other code...
@Button
fun denied(event: ButtonClickEvent) {
// code to run when the button is clicked with the id of `StaffApp.denied`
}
} @ruffrick I feel like this error could be silently ignored, rather than throwing an error. Maybe just a |
I mean but even with events how would I do so? |
I'm using discord jda library version 5.0.0-beta.12
java.lang.IllegalArgumentException: Unknown button expBooster
at dev.ruffrick.jda.commands.event.ButtonInteractionListener.onEvent(ButtonInteractionListener.kt:21)
at dev.ruffrick.jda.kotlinx.event.SuspendEventManager$handle$1.invokeSuspend(SuspendEventManager.kt:38)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
The text was updated successfully, but these errors were encountered: