Problem with RegisterHandler and question about functions
Closed this issue · 3 comments
EncryptSL commented
Hi, i have question is there way how send response message when commands are blocked in function addCheck.
Thanks for answer.
EncryptSL commented
I have another question, i implemented register handler by default from documentation.
SlashCommandClient.default("encryptsl.cekuj.net.jmusic.cmds.general")
.addCheck { ctx ->
return@addCheck !DiscordUtils.allowedChannels(ctx.channel.id,
config.getString("discordbot.server.channels.text.commandChannel").toString())
}
.buildWith(bot)
But log says this:
12:08:11[INFO] [tv.blademaker.slash.client.DefaultSlashCommandClient] Discovered a total of 0 commands in 81ms.
[22:36:34 ERROR]: [tv.blademaker.slash.client.DefaultSlashCommandClient] Not found handler for command path skip
I do something bad or something missing ?
EncryptSL commented
When class doesn't have any dependency in constructor, framework registering him fine.
class Test : BaseSlashCommand("test") {
@SlashCommand(target = InteractionTarget.ALL)
suspend fun onTest(ctx: SlashCommandContext) {
ctx.acknowledge()
ctx.hook.sendMessage("Hiii every one !").queue()
}
}
But when i add into constructor something dependency, framework not registering him.
class Test(something: Else) : BaseSlashCommand("test") {
@SlashCommand(target = InteractionTarget.ALL)
suspend fun onTest(ctx: SlashCommandContext) {
ctx.acknowledge()
ctx.hook.sendMessage("Hiii every one !").queue()
}
}
Printed error
Exception in thread "main" java.lang.NoSuchMethodException: encryptsl.cekuj.net.jmusic.cmds.fun.Test.<init>()
at java.base/java.lang.Class.getConstructor0(Class.java:3585)
at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2754)
at tv.blademaker.slash.SlashUtils.discoverSlashCommands(SlashUtils.kt:60)
at tv.blademaker.slash.client.DefaultSlashCommandClient.<init>(DefaultSlashCommandClient.kt:43)
at tv.blademaker.slash.client.DefaultSlashCommandClient.<init>(DefaultSlashCommandClient.kt)
at tv.blademaker.slash.client.DefaultSlashCommandBuilder.build(DefaultSlashCommandBuilder.kt:62)
at tv.blademaker.slash.client.DefaultSlashCommandBuilder.buildWith(DefaultSlashCommandBuilder.kt:74)
at encryptsl.cekuj.net.jmusic.JMusicBot.startBot(Main.kt:30)
at encryptsl.cekuj.net.jmusic.MainKt.main(Main.kt:55)
EncryptSL commented
Solved by own way.