Subcommand Preconditions Support

I've got the below code to create a command with subcommands and preconditions in ESM JS. My issue is that no matter what I seem to do, and I've had a look on the docs and had a look at the repo Favna linked here https://discord.com/channels/737141877803057244/1143510279024545864/1143541634248740955 , the preconditions on the subcommands never seem to be acknowledged, either in the precondition or the commands args.
import { Subcommand } from '@sapphire/plugin-subcommands';

export class warRoomCommand extends Subcommand {
constructor(context, options) {
super(context, {
...options,
name: 'warRoom',
description: 'War Rooms Command.',
aliases: ['wr', 'room'],
subcommands: [
{ name: 'd', preconditions: ['isMilcom'], messageRun: 'delete' },
{
name: 'i',
preconditions: ['isMember'],
messageRun: 'info',
},
],
});
}

async info(message, args) {
console.log(args.command);
const id = await this.getId(message);
if (!id) return;
}
// delete(), getId() etc.
}
import { Subcommand } from '@sapphire/plugin-subcommands';

export class warRoomCommand extends Subcommand {
constructor(context, options) {
super(context, {
...options,
name: 'warRoom',
description: 'War Rooms Command.',
aliases: ['wr', 'room'],
subcommands: [
{ name: 'd', preconditions: ['isMilcom'], messageRun: 'delete' },
{
name: 'i',
preconditions: ['isMember'],
messageRun: 'info',
},
],
});
}

async info(message, args) {
console.log(args.command);
const id = await this.getId(message);
if (!id) return;
}
// delete(), getId() etc.
}
Logging the commands args.command as above (using '.wr i') yields the following
subcommandPreconditions: Map(0) {},
parsedSubcommandMappings: [
{
name: 'd',
preconditions: [Array],
messageRun: 'delete',
type: 'method'
},
{
name: 'i',
preconditions: [Array],
messageRun: 'info',
type: 'method'
}
],
caseInsensitiveSubcommands: false
subcommandPreconditions: Map(0) {},
parsedSubcommandMappings: [
{
name: 'd',
preconditions: [Array],
messageRun: 'delete',
type: 'method'
},
{
name: 'i',
preconditions: [Array],
messageRun: 'info',
type: 'method'
}
],
caseInsensitiveSubcommands: false
Presumably the subcommand preconditions just aren't registered as per the Map(0) {} but I'm unsure what I'm doing wrong. Any help would be much appreciated.
8 Replies
awawawawawawa
awawawawawawa2y ago
Are you on the latest PR version that includes it?
sol
solOP2y ago
What do you mean by PR? If by PR you mean npm package version then yes I’m on subcommands version 4.1.0
Favna
Favna2y ago
it was released to npm @Ararou, subscribe to #Announcements by getting the role from <id:customize>
awawawawawawa
awawawawawawa2y ago
ah
Favna
Favna2y ago
Oh I made an oopsie ill release it soon, for now you can add "type": "method" to your subcommands https://github.com/sapphiredev/plugins/commit/6007a23926cad34e15dd72d58fec90bb858ae6c1 I want to include 3 other refactors for the repo (1 which is also precondition related for subcommands) so give us (the devs) a couple of days at the least
sol
solOP2y ago
Ah excellent. All good. Thankyou very much :)
Favna
Favna2y ago
Fixed in v4.1.1 @solaris9uk
sol
solOP2y ago
Thankyou :)

Did you find this page helpful?