Argument not found

UserError: The argument "rarity" was not found.
1 Reply
čamdžić
čamdžić3mo ago
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;
}
}
(All of that is in /arguments/RarityArgument.ts) Using it like this: const rarity = await args.pick('rarity');
Want results from more Discord servers?
Add your server