sol
sol
SIASapphire - Imagine a framework
Created by sol on 8/23/2023 in #sapphire-support
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.
14 replies
Paginated Message Replies Only to Interactions?
When I use a paginated message from @sapphire/discord.js-utilities with an interaction and call the run method it replies to the original interaction. However when I follow the same process with a message object it does not reply to the original message. I was wondering if this is perhaps an intents issue or the like but having given the bot all intents and scoured the docs I still can't find a solution. Any help would be much appreciated.
7 replies