Skip to content

Commit

Permalink
add jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
catplvsplus committed Jun 18, 2024
1 parent 131fbc2 commit 50be64e
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ export class MessageCommandBooleanOptionBuilder extends BaseMessageCommandOption
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: false): Promise<boolean|null>;
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: true): Promise<boolean>
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: boolean): Promise<boolean|null>;
/**
* Asynchronously resolves a boolean option from the given manager.
*
* @param {string} name - The name of the option to resolve.
* @param {MessageCommandOptionManager} options - The option manager to resolve from.
* @param {boolean} [required=false] - Whether the option is required or not.
* @return {Promise<boolean|null>} - A promise that resolves to the resolved boolean value, or null if the option is not present and not required.
*/
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: boolean): Promise<boolean|null> {
return super.resolveOption(name, options, required);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,34 @@ export class MessageCommandChannelOptionBuilder extends BaseMessageCommandOption
if (typeof data?.allow_outside_channels === 'boolean') this.setAllowOutsideChannels(data.allow_outside_channels);
}

/**
* Sets the channel types for the MessageCommandChannelOptionBuilder.
*
* @param {...RestOrArray<ChannelType>} channel_types - The channel types to set.
* @return {this} - The updated MessageCommandChannelOptionBuilder instance.
*/
public setChannelTypes(...channel_types: RestOrArray<ChannelType>): this {
this.channel_types = normalizeArray(channel_types);
return this;
}

/**
* Adds channel types to the MessageCommandChannelOptionBuilder.
*
* @param {...RestOrArray<ChannelType>} channel_types - The channel types to add.
* @return {this} - The updated MessageCommandChannelOptionBuilder instance.
*/
public addChannelTypes(...channel_types: RestOrArray<ChannelType>): this {
this.channel_types.push(...normalizeArray(channel_types));
return this;
}

/**
* Sets the value of allow_outside_channels to the provided boolean value.
*
* @param {boolean} allow_outside_channels - The boolean value to set. If not provided, the value will be undefined.
* @return {this} - The updated instance of the class.
*/
public setAllowOutsideChannels(allow_outside_channels?: boolean): this {
this.allow_outside_channels = allow_outside_channels;
return this;
Expand All @@ -52,6 +70,14 @@ export class MessageCommandChannelOptionBuilder extends BaseMessageCommandOption
return true;
}

/**
* Asynchronously resolves a channel option from the given manager.
*
* @param {string} name - The name of the option to resolve.
* @param {MessageCommandOptionManager} options - The option manager to resolve from.
* @param {boolean} [required] - Whether the option is required or not.
* @return {Promise<Channel|null>} - A promise that resolves to the resolved channel or null.
*/
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: boolean): Promise<Channel|null> {
return super.resolveOption(name, options, required);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,23 @@ export class MessageCommandIntegerOptionBuilder extends BaseMessageCommandOption
if (typeof data?.min_value === 'number') this.setMinValue(data.min_value);
}

/**
* Sets the maximum value for this option.
*
* @param {number} [maxValue] - The maximum value to set. If not provided, the maximum value will be unset.
* @return {this} - Returns the current object for method chaining.
*/
public setMaxValue(maxValue?: number): this {
this.max_value = maxValue;
return this;
}

/**
* Sets the minimum value for this option.
*
* @param {number} [minValue] - The minimum value to set. If not provided, the minimum value will be unset.
* @return {this} - Returns the current object for method chaining.
*/
public setMinValue(minValue?: number): this {
this.min_value = minValue;
return this;
Expand All @@ -43,6 +55,14 @@ export class MessageCommandIntegerOptionBuilder extends BaseMessageCommandOption
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: false): Promise<number|null>;
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: true): Promise<number>
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: boolean): Promise<number|null>;
/**
* Asynchronously resolves an integer option from the given option manager.
*
* @param {string} name - The name of the option to resolve.
* @param {MessageCommandOptionManager} options - The option manager to resolve from.
* @param {boolean} [required] - Whether the option is required or not.
* @return {Promise<number|null>} - A promise that resolves to the resolved integer value, or null if the option is not present or not valid.
*/
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: boolean): Promise<number|null> {
return super.resolveOption(name, options, required);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,23 @@ export class MessageCommandMessageOptionBuilder extends BaseMessageCommandOption
super(data);
}

/**
* Sets the value of allow_outside_messages to the provided boolean value.
*
* @param {boolean} allowOutsideMessages - The boolean value to set. If not provided, the value will be undefined.
* @return {this} - The updated instance of the class.
*/
public setAllowOutsideMessages(allowOutsideMessages?: boolean) {
this.allow_outside_messages = allowOutsideMessages;
return this;
}

/**
* Sets the value of allow_bot_messages to the provided boolean value.
*
* @param {boolean} allowBotMessages - The boolean value to set. If not provided, the value will be undefined.
* @return {this} - The updated instance of the class.
*/
public setAllowBotMessages(allowBotMessages?: boolean) {
this.allow_bot_messages = allowBotMessages;
return this;
Expand All @@ -41,6 +53,12 @@ export class MessageCommandMessageOptionBuilder extends BaseMessageCommandOption
return true;
};

/**
* Fetches a message from the given options.
*
* @param {MessageCommandOptionBuilderResolveValueOptions} options - The options containing the value to fetch.
* @return {Promise<Message|null>} A promise that resolves to the fetched message or null if not found.
*/
protected static async fetchMessageFromOptions(options: MessageCommandOptionBuilderResolveValueOptions): Promise<Message|null> {
let message: Message|null = null;

Expand All @@ -57,6 +75,14 @@ export class MessageCommandMessageOptionBuilder extends BaseMessageCommandOption
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: false): Promise<Message|null>;
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: true): Promise<Message>
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: boolean): Promise<Message|null>;
/**
* Resolves a message option from the given options object.
*
* @param {string} name - The name of the option to resolve.
* @param {MessageCommandOptionManager} options - The options object containing the option.
* @param {boolean} [required] - Whether the option is required or not.
* @return {Promise<Message|null>} - A promise that resolves to the resolved message or null if the option is not present and not required.
*/
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: boolean): Promise<Message|null> {
return super.resolveOption(name, options, required);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,23 @@ export class MessageCommandNumberOptionBuilder extends BaseMessageCommandOptionB
if (typeof data?.min_value === 'number') this.setMinValue(data.min_value);
}

/**
* Sets the maximum value for this option.
*
* @param {number} [maxValue] - The maximum value to set. If not provided, the maximum value will be unset.
* @return {this} - Returns the current object for method chaining.
*/
public setMaxValue(maxValue?: number): this {
this.max_value = maxValue;
return this;
}

/**
* Sets the minimum value for this option.
*
* @param {number} [minValue] - The minimum value to set. If not provided, the minimum value will be unset.
* @return {this} - Returns the current object for method chaining.
*/
public setMinValue(minValue?: number): this {
this.min_value = minValue;
return this;
Expand All @@ -43,6 +55,14 @@ export class MessageCommandNumberOptionBuilder extends BaseMessageCommandOptionB
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: false): Promise<number|null>;
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: true): Promise<number>
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: boolean): Promise<number|null>;
/**
* Asynchronously resolves a number option from the given manager.
*
* @param {string} name - The name of the option to resolve.
* @param {MessageCommandOptionManager} options - The option manager to resolve from.
* @param {boolean} [required=false] - Whether the option is required or not.
* @return {Promise<number|null>} - A promise that resolves to the resolved number value, or null if the option is not present and not required.
*/
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: boolean): Promise<number|null> {
return super.resolveOption(name, options, required);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ export class MessageCommandRoleOptionBuilder extends BaseMessageCommandOptionBui
if (typeof data?.allow_everyone === 'boolean') this.setAllowEveryone(data.allow_everyone);
}

/**
* Sets the value of `allow_everyone` to the provided `allowEveryone` parameter and returns the current instance.
*
* @param {boolean} allowEveryone - The value to set `allow_everyone` to. If not provided, `allow_everyone` will be set to `undefined`.
* @return {this} The current instance of the class.
*/
public setAllowEveryone(allowEveryone?: boolean): this {
this.allow_everyone = allowEveryone;
return this;
Expand All @@ -34,6 +40,14 @@ export class MessageCommandRoleOptionBuilder extends BaseMessageCommandOptionBui
return true;
}

/**
* Asynchronously resolves a role option from the given option manager.
*
* @param {string} name - The name of the option to resolve.
* @param {MessageCommandOptionManager} options - The option manager to resolve from.
* @param {boolean} [required=false] - Whether the option is required or not.
* @return {Promise<Role|null>} - A promise that resolves to the resolved role value, or null if the option is not present and not required.
*/
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: boolean): Promise<Role|null> {
return super.resolveOption(name, options, required);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export class MessageCommandUserOptionBuilder extends BaseMessageCommandOptionBui
if (typeof data?.allow_bots === 'boolean') this.setAllowBots(data.allow_bots);
}

/**
* Sets the value of `allow_bots` property and returns the current instance.
*
* @param {boolean} [allowBots] - The new value for `allow_bots`. If not provided, it will be set to `undefined`.
* @return {this} The current instance of the class.
*/
public setAllowBots(allowBots?: boolean): this {
this.allow_bots = allowBots;
return this;
Expand All @@ -38,6 +44,14 @@ export class MessageCommandUserOptionBuilder extends BaseMessageCommandOptionBui
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: false): Promise<User|null>;
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: true): Promise<User>
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: boolean): Promise<User|null>;
/**
* Asynchronously resolves a user option from the given manager.
*
* @param {string} name - The name of the option to resolve.
* @param {MessageCommandOptionManager} options - The option manager to resolve from.
* @param {boolean} [required=false] - Whether the option is required or not.
* @return {Promise<User|null>} - A promise that resolves to the resolved user value, or null if the option is not present and not required.
*/
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: boolean): Promise<User|null> {
return super.resolveOption(name, options, required);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { MessageCommandOptionBuilder, MessageCommandOptionBuilderData, MessageCommandOptionBuilderResolveValueOptions, MessageCommandOptionManager, MessageCommandOptionValidators } from '@reciple/core';

export abstract class BaseMessageCommandOptionBuilder<T extends any = any> extends (MessageCommandOptionBuilder as (new <T extends any>(options?: MessageCommandOptionBuilderData<T>) => Omit<MessageCommandOptionBuilder<T>, 'setName'|'setDescription'|'setRequired'|'setResolveValue'|'setValidate'>))<T> {
/**
* Initializes a new instance of the MessageCommandBooleanOptionBuilder class.
*
* @param {MessageCommandBooleanOptionBuilderData<T>} [data] - Optional data to initialize the builder with.
*/
constructor(data?: MessageCommandOptionBuilderData<T>) {
super(data);
}
Expand Down

0 comments on commit 50be64e

Please sign in to comment.