#Invalid Form Body (or at least something like that) When the bot tries to register a new command

1 messages Β· Page 1 of 1 (latest)

gray vortex
#

Hello, I just started to continue on my bot. I just did a upgrade to the most recent version of discord.js and sapphire. But now, the bot started giving me after "boot" cringe errors telling me that he can't register the commands. Exactly: take a look on the screenshot, this **** ist too long!

sapphire-version is "next". I use CommonJS btw, that was a previous error πŸ˜…

wary pulsarBOT
#

@gray vortex to help others find answers, you can mark your question as solved via Right Click Solution Message->Apps->βœ… Mark Solution

gray vortex
#

BTW, the code of one of the commands is: ```ts
import { PrismaClient } from '@prisma/client';
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
const prisma = new PrismaClient();
@ApplyOptions<Command.Options>({
description: 'Some description.'
})
export class UserCommand extends Command {
public constructor(context: Command.Context) {
super(context, {
preconditions: ['admin', 'guildchannel'],
cooldownDelay: 10_000
});
}

public override registerApplicationCommands(registry: Command.Registry) {
    registry.registerChatInputCommand({
        name: this.name,
        description: this.description
    });
}

public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { /* some code */}}} // I didn't count the brackets```
jaunty steeple
#

its most likely to do with the fact that your providing the decorator and constructor. you have to provide one or the other, so you can either:

  • move your preconditions and cooldownDelay into the the decorator and remove the constructor
  • move your description into the constructor and remove the decorator
pure flax
#

Can you show the code for losungschannel command

gray vortex
gray vortex
#

Because it worked until I did a upgrade to [email protected] πŸ˜… (and the latest sapphire version of course πŸ˜‰)

jaunty steeple
gray vortex
#

Ok. I think I crossed two templates, I'll change this.

gray vortex
#

I just removed the decorators from every command having a constructor. Sapphire stopped showing this error, and loads the commands properly, so I think this issue is done for now. Thanks @jaunty steeple !!!

wary pulsarBOT
#

Thank you for marking this question as solved!

Question Message ID

1066821271511367800

Solution Message ID

1066863814433320980

pure flax
#

well you should remove the contructor instead

jaunty steeple
#

maybe this will help visualize what i mean, whilst trying not to spoonfeed

public constructor(context: <Class>.Context) {
  super(context, {
      // you would move everything in this object, into the decorators object
      // after moving everything, remove the whole of this constructor method
      // leaving you with your decorator, registerApplicationCommands, chatInputRun and so on
  });
}