diff --git a/build.gradle b/build.gradle index bea5027..07bcf93 100644 --- a/build.gradle +++ b/build.gradle @@ -59,7 +59,7 @@ dependencies { implementation("me.shedaniel:linkie-core:1.0.92") { exclude module: "korio" } - discord_apiImplementation("com.github.Discord4J.Discord4J:discord4j-core:c25f7e1") { + discord_apiImplementation("com.github.Discord4J.Discord4J:discord4j-core:c8b1738") { force = true } // compile("com.github.shadorc.discord4j:discord4j-core:217336e") { diff --git a/src/main/kotlin/me/shedaniel/linkie/discord/LinkieBot.kt b/src/main/kotlin/me/shedaniel/linkie/discord/LinkieBot.kt index b58f58a..b857b4c 100644 --- a/src/main/kotlin/me/shedaniel/linkie/discord/LinkieBot.kt +++ b/src/main/kotlin/me/shedaniel/linkie/discord/LinkieBot.kt @@ -209,7 +209,7 @@ fun registerCommands(commands: CommandManager) { commands.registerCommand(false, QueryMappingsCommand(null, MappingsEntryType.METHOD), "m", "method") commands.registerCommand(false, QueryMappingsCommand(null, MappingsEntryType.FIELD), "f", "field") - commands.registerCommand(false, QueryMappingsCommand(Namespaces["yarn"], *MappingsEntryType.values()), "y", "yarn") + commands.registerCommand(QueryMappingsCommand(Namespaces["yarn"], *MappingsEntryType.values()), listOf("y", "yarn"), listOf("yarn")) commands.registerCommand(false, QueryMappingsCommand(Namespaces["yarn"], MappingsEntryType.CLASS), "yc", "yarnc") commands.registerCommand(false, QueryMappingsCommand(Namespaces["yarn"], MappingsEntryType.METHOD), "ym", "yarnm") commands.registerCommand(false, QueryMappingsCommand(Namespaces["yarn"], MappingsEntryType.FIELD), "yf", "yarnf") @@ -224,7 +224,7 @@ fun registerCommands(commands: CommandManager) { commands.registerCommand(false, QueryMappingsCommand(Namespaces["yarrn"], MappingsEntryType.METHOD), "yrm", "yarrnm") commands.registerCommand(false, QueryMappingsCommand(Namespaces["yarrn"], MappingsEntryType.FIELD), "yrf", "yarnrf") - commands.registerCommand(false, QueryMappingsCommand(Namespaces["mcp"], *MappingsEntryType.values()), "mcp") + commands.registerCommand(QueryMappingsCommand(Namespaces["mcp"], *MappingsEntryType.values()), "mcp") commands.registerCommand(false, QueryMappingsCommand(Namespaces["mcp"], MappingsEntryType.CLASS), "mcpc") commands.registerCommand(false, QueryMappingsCommand(Namespaces["mcp"], MappingsEntryType.METHOD), "mcpm") commands.registerCommand(false, QueryMappingsCommand(Namespaces["mcp"], MappingsEntryType.FIELD), "mcpf") @@ -236,12 +236,12 @@ fun registerCommands(commands: CommandManager) { commands.registerCommand(false, QueryMappingsCommand(Namespaces["plasma"], MappingsEntryType.METHOD), "plasmam", "plm") commands.registerCommand(false, QueryMappingsCommand(Namespaces["plasma"], MappingsEntryType.FIELD), "plasmaf", "plf") - commands.registerCommand(false, QueryMappingsCommand(Namespaces["mojang"], *MappingsEntryType.values()), "mmi", "mojmapi") + commands.registerCommand(QueryMappingsCommand(Namespaces["mojang"], *MappingsEntryType.values()), listOf("mmi", "mojmapi"), listOf("mmi")) commands.registerCommand(false, QueryMappingsCommand(Namespaces["mojang"], MappingsEntryType.CLASS), "mmic", "mojmapic") commands.registerCommand(false, QueryMappingsCommand(Namespaces["mojang"], MappingsEntryType.METHOD), "mmim", "mojmapim") commands.registerCommand(false, QueryMappingsCommand(Namespaces["mojang"], MappingsEntryType.FIELD), "mmif", "mojmapim") - commands.registerCommand(false, QueryMappingsCommand(Namespaces["mojang_srg"], *MappingsEntryType.values()), "mms", "mojmaps") + commands.registerCommand(QueryMappingsCommand(Namespaces["mojang_srg"], *MappingsEntryType.values()), listOf("mms", "mojmaps"), listOf("mms")) commands.registerCommand(false, QueryMappingsCommand(Namespaces["mojang_srg"], MappingsEntryType.CLASS), "mmsc", "mojmapsc") commands.registerCommand(false, QueryMappingsCommand(Namespaces["mojang_srg"], MappingsEntryType.METHOD), "mmsm", "mojmapsm") commands.registerCommand(false, QueryMappingsCommand(Namespaces["mojang_srg"], MappingsEntryType.FIELD), "mmsf", "mojmapsm") diff --git a/src/main/kotlin/me/shedaniel/linkie/discord/commands/QueryMappingsCommand.kt b/src/main/kotlin/me/shedaniel/linkie/discord/commands/QueryMappingsCommand.kt index 8d94372..ad503b0 100644 --- a/src/main/kotlin/me/shedaniel/linkie/discord/commands/QueryMappingsCommand.kt +++ b/src/main/kotlin/me/shedaniel/linkie/discord/commands/QueryMappingsCommand.kt @@ -63,10 +63,14 @@ open class QueryMappingsCommand( ) : Command { override suspend fun SlashCommandBuilderInterface.buildCommand(slash: Boolean) { if (slash) { - (sequenceOf("all") + MappingsEntryType.values().asSequence().map { it.name.toLowerCase() }).forEach { type -> - subGroup(type, "Queries mappings for the '$type' type") { - buildNamespaces(slash, if (type == "all") MappingsEntryType.values() else arrayOf(MappingsEntryType.valueOf(type.toUpperCase()))) + if (namespace == null) { + (sequenceOf("all") + MappingsEntryType.values().asSequence().map { it.name.toLowerCase() }).forEach { type -> + subGroup(type, "Queries mappings for the '$type' type") { + buildNamespaces(slash, if (type == "all") MappingsEntryType.values() else arrayOf(MappingsEntryType.valueOf(type.toUpperCase()))) + } } + } else { + buildNamespaces(false, types) } } else { buildNamespaces(slash, types) diff --git a/src/main/kotlin/me/shedaniel/linkie/discord/commands/RunTrickCommand.kt b/src/main/kotlin/me/shedaniel/linkie/discord/commands/RunTrickCommand.kt index 3bc4dbf..ca92849 100644 --- a/src/main/kotlin/me/shedaniel/linkie/discord/commands/RunTrickCommand.kt +++ b/src/main/kotlin/me/shedaniel/linkie/discord/commands/RunTrickCommand.kt @@ -20,6 +20,7 @@ import me.shedaniel.linkie.discord.Command import me.shedaniel.linkie.discord.scommands.SlashCommandBuilderInterface import me.shedaniel.linkie.discord.scommands.args import me.shedaniel.linkie.discord.scommands.opt +import me.shedaniel.linkie.discord.scommands.optNullable import me.shedaniel.linkie.discord.scommands.string import me.shedaniel.linkie.discord.scripting.ContextExtensions import me.shedaniel.linkie.discord.scripting.EvalContext @@ -33,7 +34,7 @@ object RunTrickCommand : Command { override suspend fun SlashCommandBuilderInterface.buildCommand(slash: Boolean) { val trickName = string("trick_name", "Name of the trick") val args = args(required = false) - executeCommandWithGetter { ctx, options -> execute(ctx, options.opt(trickName), options.opt(args)) } + executeCommandWithGetter { ctx, options -> execute(ctx, options.opt(trickName), options.optNullable(args) ?: mutableListOf()) } } suspend fun execute(ctx: CommandContext, trickName: String, args: MutableList) {