2023-05-05 16:32:29 +02:00
|
|
|
import { Parser, Command, OptionType } from '../build/esm/index.js';
|
|
|
|
|
2024-03-24 20:38:48 +01:00
|
|
|
const createCommand = new Command({
|
|
|
|
name: 'create',
|
|
|
|
options: [{
|
|
|
|
name: 'registration-code',
|
|
|
|
aliases: ['code'],
|
|
|
|
type: OptionType.SUB_COMMAND,
|
|
|
|
options: [{
|
|
|
|
name: 'amount',
|
|
|
|
flag: true,
|
|
|
|
type: OptionType.INTEGER,
|
|
|
|
defaultValue: 1,
|
|
|
|
valueOptional: true,
|
|
|
|
required: true
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
const botbanCommand = new Command({
|
2023-12-14 16:33:54 +01:00
|
|
|
name: 'botban',
|
|
|
|
options: [
|
|
|
|
{ name: 'users', type: OptionType.STRING, required: true },
|
|
|
|
{ name: 'service', choices: ['support', 'reports'], valueAsAlias: true, required: true }
|
|
|
|
]
|
2023-05-05 16:32:29 +02:00
|
|
|
});
|
2024-03-24 20:38:48 +01:00
|
|
|
|
|
|
|
const volumeCommand = new Command({
|
|
|
|
name: 'volume',
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'volume',
|
|
|
|
type: OptionType.INTEGER,
|
|
|
|
maximum: 100,
|
|
|
|
minimum: 0
|
|
|
|
},
|
|
|
|
]
|
|
|
|
});
|
|
|
|
const parser = new Parser({ commands: [createCommand, botbanCommand, volumeCommand], prefix: '', debug: true });
|
2023-05-05 16:32:29 +02:00
|
|
|
parser.on('debug', console.log)
|
2024-03-24 20:38:48 +01:00
|
|
|
console.log((await parser.parseMessage('create code -a 1')).args);
|
|
|
|
console.log((await parser.parseMessage('create code --help')).args);
|
|
|
|
// console.log(await parser.parseMessage('create --help'));
|
2023-12-14 16:33:54 +01:00
|
|
|
|
2024-03-24 20:38:48 +01:00
|
|
|
console.log((await parser.parseMessage('create code')).args);
|
2023-12-14 16:33:54 +01:00
|
|
|
|
2024-03-24 20:38:48 +01:00
|
|
|
console.log((await parser.parseMessage('botban support dingus')).args);
|
|
|
|
console.log((await parser.parseMessage('volume 500')).args);
|