mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
feat(CommandInteractionOptionResolver): add sub-command required option (#6165)
This commit is contained in:
@@ -97,10 +97,11 @@ class CommandInteractionOptionResolver {
|
||||
|
||||
/**
|
||||
* Gets the selected sub-command.
|
||||
* @returns {string} The name of the selected sub-command.
|
||||
* @param {boolean} [required=true] Whether to throw an error if there is no sub-command.
|
||||
* @returns {?string} The name of the selected sub-command, or null if not set and not required.
|
||||
*/
|
||||
getSubCommand() {
|
||||
if (!this._subCommand) {
|
||||
getSubCommand(required = true) {
|
||||
if (required && !this._subCommand) {
|
||||
throw new TypeError('COMMAND_INTERACTION_OPTION_NO_SUB_COMMAND');
|
||||
}
|
||||
return this._subCommand;
|
||||
@@ -108,10 +109,11 @@ class CommandInteractionOptionResolver {
|
||||
|
||||
/**
|
||||
* Gets the selected sub-command group.
|
||||
* @returns {string} The name of the selected sub-command group.
|
||||
* @param {boolean} [required=true] Whether to throw an error if there is no sub-command group.
|
||||
* @returns {?string} The name of the selected sub-command group, or null if not set and not required.
|
||||
*/
|
||||
getSubCommandGroup() {
|
||||
if (!this._group) {
|
||||
getSubCommandGroup(required = true) {
|
||||
if (required && !this._group) {
|
||||
throw new TypeError('COMMAND_INTERACTION_OPTION_NO_SUB_COMMAND_GROUP');
|
||||
}
|
||||
return this._group;
|
||||
|
||||
Reference in New Issue
Block a user