Argument not found
UserError: The argument "rarity" was not found.
1 Reply
import { Argument } from '@sapphire/framework';
import { isNullishOrEmpty } from '@sapphire/utilities';
import { CardRarity } from '../structures/types';
export class RarityArgument extends Argument<string> {
public run(parameter: string, context: Argument.Context) {
if (isNullishOrEmpty(parameter)) {
return this.error({
context,
parameter,
message:
'No array of options was provided. You should alert the bot developer.',
identifier: 'NoArrayContextProvided'
});
}
const rarities = ['Common', 'Rare', 'Secret'];
if (rarities.includes(parameter)) return this.ok(parameter as CardRarity);
return this.error({
context,
parameter,
message:
'The provided parameter does not include an element from the array.',
identifier: 'NotInArrayOfOptions'
});
}
}
declare module '@sapphire/framework' {
interface ArgType {
rarity: CardRarity;
}
}
import { Argument } from '@sapphire/framework';
import { isNullishOrEmpty } from '@sapphire/utilities';
import { CardRarity } from '../structures/types';
export class RarityArgument extends Argument<string> {
public run(parameter: string, context: Argument.Context) {
if (isNullishOrEmpty(parameter)) {
return this.error({
context,
parameter,
message:
'No array of options was provided. You should alert the bot developer.',
identifier: 'NoArrayContextProvided'
});
}
const rarities = ['Common', 'Rare', 'Secret'];
if (rarities.includes(parameter)) return this.ok(parameter as CardRarity);
return this.error({
context,
parameter,
message:
'The provided parameter does not include an element from the array.',
identifier: 'NotInArrayOfOptions'
});
}
}
declare module '@sapphire/framework' {
interface ArgType {
rarity: CardRarity;
}
}
const rarity = await args.pick('rarity');