parsePrefixArgs
parsePrefixArgs(
input,specs):PrefixArgsResult
Defined in: packages/utils/src/args.ts:218
Reads prefix-command arguments by position, as typed values. IDs come back as strings (user, role, channel); a mentionable says which it was. The first problem is reported, with the argument’s name, instead of throwing.
Parameters
Section titled “Parameters”string | readonly string[]
The text after the command name, or already-split arguments.
readonly PrefixArgSpec[]
The expected arguments in order; a rest argument must be last.
Returns
Section titled “Returns”Example
Section titled “Example”const result = parsePrefixArgs(`@user 10 spamming links`, [ { name: "user", type: "user", required: true }, { name: "minutes", type: "integer", min: 1, max: 40320 }, { name: "reason", type: "rest" },]);if (!result.ok) return message.reply(`\`${result.arg}\` ${result.error}.`);