Using the command builders
The CommandOptionsBuilder
The CommandOptionsBuilder
open in new window can be used to create CommandOptions, like the name or description of a command.
const { Command, CommandOptionsBuilder } = require("gcommands");
module.exports = class extends Command {
constructor(client) {
super(client, new CommandOptionsBuilder()
.setName('example')
.setDescription('This is a example')
.setCooldown('2s')
.setContext(false)
// And all other options
);
}
};
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
The CommandArgsOptionBuilder
The CommandArgsOptionBuilder
open in new window can be used to create new arguments.
const { Command, ArgumentType, CommandOptionsBuilder, CommandArgsOptionBuilder } = require("gcommands");
module.exports = class extends Command {
constructor(client) {
super(client, new CommandOptionsBuilder()
// Add one argument
.addArg(new CommandArgsOptionBuilder()
.setName('message')
.setDescription('The example message')
.setPrompt('What is your example message?')
.setRequired(true)
.setType(ArgumentType.STRING)
)
// Add a array of arguments
.addArgs([
new CommandArgsOptionBuilder()
.setName('message')
.setDescription('The example message')
.setPrompt('What is your example message?')
.setRequired(true)
.setType(ArgumentType.STRING),
])
);
}
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
The CommandArgsChoiceOptionBuilder
The CommandArgsChoiceBuilder
open in new window can be used to create new argument choices.
const { Command, ArgumentType, CommandOptionsBuilder, CommandArgsOptionBuilder, CommandArgsChoiceBuilder } = require("gcommands");
module.exports = class extends Command {
constructor(client) {
super(client, new CommandOptionsBuilder()
.addArg(new CommandArgsOptionBuilder()
// Add one choice
.addChoice(new CommandArgsChoiceBuilder()
.setName('true')
.setValue(true)
)
// Add a array of choices
.addChoices([
new CommandArgsChoiceBuilder()
.setName('true')
.setValue(true),
])
)
);
}
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21