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
šŸŽƒ ararou!
šŸŽƒ ararou!ā€¢15mo ago
Are you on the latest PR version that includes it?
sol
solā€¢15mo 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
Favnaā€¢15mo ago
it was released to npm @Ararou, subscribe to #Announcements by getting the role from <id:customize>
šŸŽƒ ararou!
šŸŽƒ ararou!ā€¢15mo ago
ah
Favna
Favnaā€¢15mo 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
solā€¢15mo ago
Ah excellent. All good. Thankyou very much :)
Favna
Favnaā€¢15mo ago
Fixed in v4.1.1 @solaris9uk
sol
solā€¢15mo ago
Thankyou :)
Want results from more Discord servers?
Add your server