Skip to content

Custom commands error out #38

Description

@benonymity

Whenever I try to use a custom command (I have whitelist and execute commands) they load forever on Discord and spit out a ton of errors in the console. I'm on 1.21.11.

My commands.toml is

configGenerated = true

    [[commands.customCommands]]
      name = "whitelist"
      description = "Whitelists a player on the Server"
      mcCommand = "whitelist add %player%"
      textToSend = ""
      adminOnly = false
      hidden = false

        [[commands.customCommands.args]]
          name = "player"
          description = "The player to be whitelisted"
          optional = false

    [[commands.customCommands]]
      name = "execute"
      description = "Execute an arbitrary command on the server"
      mcCommand = "execute run %command%"
      textToSend = ""
      adminOnly = true
      hidden = true

        [[commands.customCommands.args]]
          name = "command"
          description = "The command to run"
          optional = false

and whenever I call one of them in Discord, this message repeats over and over in the console:

[20:09:07] [JDA MainWS-ReadThread/ERROR]: There was an error in the WebSocket connection. Trace: [["gateway-prd-arm-us-east1-d-fq5d",{"micros":2054,"calls":["id_created",{"micros":0,"calls":[]},"session_lookup_time",{"micros":579,"calls":[]},"session_lookup_finished",{"micros":9,"calls":[]},"discord-sessions-prd-2-45",{"micros":30}]}]]
java.lang.NoSuchMethodError: 'void net.minecraft.class_2168.<init>(net.minecraft.class_2165, net.minecraft.class_243, net.minecraft.class_241, net.minecraft.class_3218, int, java.lang.String, net.minecraft.class_2561, net.minecraft.server.MinecraftServer, net.minecraft.class_1297)'
	at knot//de.erdbeerbaerlp.dcintegration.architectury.command.DCCommandSender.createCommandSourceStack(DCCommandSender.java:99)
	at knot//de.erdbeerbaerlp.dcintegration.architectury.util.ServerInterface.runMcCommand(ServerInterface.java:145)
	at knot//de.erdbeerbaerlp.dcintegration.common.discordCommands.CommandFromConfig.execute(CommandFromConfig.java:57)
	at knot//de.erdbeerbaerlp.dcintegration.common.DiscordEventListener.processDiscordCommand(DiscordEventListener.java:197)
	at knot//de.erdbeerbaerlp.dcintegration.common.DiscordEventListener.onEvent(DiscordEventListener.java:63)
	at knot//net.dv8tion.jda.api.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:98)
	at knot//net.dv8tion.jda.internal.hooks.EventManagerProxy.handleInternally(EventManagerProxy.java:88)
	at knot//net.dv8tion.jda.internal.hooks.EventManagerProxy.handle(EventManagerProxy.java:70)
	at knot//net.dv8tion.jda.internal.JDAImpl.handleEvent(JDAImpl.java:171)
	at knot//net.dv8tion.jda.internal.handle.InteractionCreateHandler.handleCommand(InteractionCreateHandler.java:112)
	at knot//net.dv8tion.jda.internal.handle.InteractionCreateHandler.handleInternally(InteractionCreateHandler.java:83)
	at knot//net.dv8tion.jda.internal.handle.SocketHandler.handle(SocketHandler.java:39)
	at knot//net.dv8tion.jda.internal.requests.WebSocketClient.onDispatch(WebSocketClient.java:1009)
	at knot//net.dv8tion.jda.internal.requests.WebSocketClient.onEvent(WebSocketClient.java:892)
	at knot//net.dv8tion.jda.internal.requests.WebSocketClient.handleEvent(WebSocketClient.java:870)
	at knot//net.dv8tion.jda.internal.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:1048)
	at knot//dcshadow.com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:385)
	at knot//dcshadow.com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:276)
	at knot//dcshadow.com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:996)
	at knot//dcshadow.com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:755)
	at knot//dcshadow.com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108)
	at knot//dcshadow.com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64)
	at knot//dcshadow.com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)

Apparently the command constructor got deprecated sometime in the 1.21.x updates, now we're supposed to derive from the server's base command. Our AI overlords suggest a fix to DCCommandSender.java like this, but I don't have the time to compile and test it:

public CommandSourceStack createCommandSourceStack() {
    return DiscordIntegrationMod.server
        .createCommandSourceStack()
        .withSource(this)
        .withPosition(Vec3.ZERO)
        .withRotation(Vec2.ZERO)
        .withLevel(DiscordIntegrationMod.server.getLevel(ServerLevel.OVERWORLD))
        .withPermission(4)
        .withSuppressedOutput(false);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions