Closed NotM1Dev closed 11 months ago
You can use a temporary fix by adding as const
keyword after your command object to fix this error while still having the type checks
You can use a temporary fix by adding
as const
keyword after your command object to fix this error while still having the type checks
@NotGhex That's a good idea. However, I've found another solution:
import { ChatInputCommandInteraction } from 'discord.js';
import { CommandType, type RecipleModuleData, type AnyCommandResolvable } from 'reciple';
export default class implements RecipleModuleData {
public versions: string = '^8';
public onStart() {
return true;
}
public commands: AnyCommandResolvable[] = [
{
name: 'my_command',
description: 'does a thing',
command_type: CommandType.SlashCommand,
execute({ interaction }: { interaction: ChatInputCommandInteraction }) {
interaction.reply('Test.');
},
},
];
}
Specifically: public commands: AnyCommandResolvable[]
Manually specifying the AnyCommandResolvable[] type fixes this, so I don't need to add as const
at the end of every command.
Dependencies
typescript v5.2.2 discord.js v14.3.0 @reciple/core v8.1.7 reciple v8.1.7
Issue Description
I found a problem when attempting to create commands as objects (rather than command builders). Right now, reciple expects
commands
to be an array of command builders, so I can't create a command as an object.Using
command_type: CommandType.SlashCommand
removed the error from the command object itself, but the command array throws an error:And here's the test code:
src/example.ts