Skip to content

Commit

Permalink
jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
catplvsplus committed Sep 3, 2024
1 parent d8467e1 commit 3104029
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class MessageCommandBooleanFlagBuilder extends BaseMessageCommandFlagBuil
super(data);
}


public readonly resolve_value = (options: MessageCommandFlagBuilderResolveValueOptions<boolean>): boolean[] => {
return options.values.map(v => boolean(v));
}
Expand All @@ -18,6 +19,9 @@ export class MessageCommandBooleanFlagBuilder extends BaseMessageCommandFlagBuil

public readonly value_type: 'boolean' = 'boolean';

/**
* Asynchronously resolves a boolean flag from the given flag manager.
*/
public static async resolveFlag(name: string, options: MessageCommandFlagManager, required?: boolean): Promise<boolean[]> {
return super.resolveFlag(name, options, required);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,28 @@ export class MessageCommandChannelFlagBuilder extends BaseMessageCommandFlagBuil
if (typeof data?.allow_outside_channels === 'boolean') this.setAllowOutsideChannels(data.allow_outside_channels);
}

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

/**
* Adds channel types to the MessageCommandChannelFlagBuilder.
* @param {...RestOrArray<ChannelType>} channel_types - The channel types to add.
*/
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.
*/
public setAllowOutsideChannels(allow_outside_channels?: boolean): this {
this.allow_outside_channels = allow_outside_channels;
return this;
Expand Down Expand Up @@ -68,6 +80,9 @@ export class MessageCommandChannelFlagBuilder extends BaseMessageCommandFlagBuil

public readonly value_type: 'string' = 'string';

/**
* Asynchronously resolves a channel flag from the given flag manager.
*/
public static async resolveFlag(name: string, options: MessageCommandFlagManager, required?: boolean): Promise<Channel[]> {
return super.resolveFlag(name, options, required);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,19 @@ export class MessageCommandIntegerFlagBuilder extends BaseMessageCommandFlagBuil
if (typeof data?.min_value === 'number') this.setMinValue(data.min_value);
}

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

/**
* Sets the minimum value for this flag.
* @param {number} [minValue] - The minimum value to set. If not provided, the minimum value will be unset.
*/
public setMinValue(minValue?: number): this {
this.min_value = minValue;
return this;
Expand All @@ -43,6 +51,9 @@ export class MessageCommandIntegerFlagBuilder extends BaseMessageCommandFlagBuil

public readonly value_type: 'string' | 'boolean' = 'string';

/**
* Asynchronously resolves an integer flag from the given flag manager.
*/
public static async resolveFlag(name: string, options: MessageCommandFlagManager, required?: boolean): Promise<number[]> {
return super.resolveFlag(name, options, required);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@ export class MessageCommandMessageFlagBuilder extends BaseMessageCommandFlagBuil
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.
*/
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.
*/
public setAllowBotMessages(allowBotMessages?: boolean) {
this.allow_bot_messages = allowBotMessages;
return this;
Expand All @@ -44,6 +52,10 @@ export class MessageCommandMessageFlagBuilder extends BaseMessageCommandFlagBuil

public readonly value_type: 'string' = 'string';

/**
* Fetches a message from the given options.
* @param {MessageCommandFlagBuilderResolveValueOptions<Message>} options - The options containing the value to fetch.
*/
protected static async fetchMessageFromOptions(options: MessageCommandFlagBuilderResolveValueOptions<Message>): Promise<Message[]> {
const messages: Message[] = [];

Expand All @@ -63,6 +75,9 @@ export class MessageCommandMessageFlagBuilder extends BaseMessageCommandFlagBuil
return messages;
}

/**
* Resolves a message flag from the given flag manager.
*/
public static async resolveFlag(name: string, options: MessageCommandFlagManager, required?: boolean): Promise<Message[]> {
return super.resolveFlag(name, options, required);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,19 @@ export class MessageCommandNumberFlagBuilder extends BaseMessageCommandFlagBuild
if (typeof data?.min_value === 'number') this.setMinValue(data.min_value);
}

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

/**
* Sets the minimum value for this flag.
* @param {number} [minValue] - The minimum value to set. If not provided, the minimum value will be unset.
*/
public setMinValue(minValue?: number): this {
this.min_value = minValue;
return this;
Expand All @@ -43,6 +51,9 @@ export class MessageCommandNumberFlagBuilder extends BaseMessageCommandFlagBuild

public readonly value_type: 'string' | 'boolean' = 'string';

/**
* Asynchronously resolves a number flag from the given flag manager.
*/
public static async resolveFlag(name: string, options: MessageCommandFlagManager, required?: boolean): Promise<number[]> {
return super.resolveFlag(name, options, required);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export class MessageCommandRoleFlagBuilder extends BaseMessageCommandFlagBuilder
if (typeof data?.allow_everyone === 'boolean') this.setAllowEveryone(data.allow_everyone);
}

/**
* Sets the value of `allow_everyone`
* @param {boolean} allowEveryone - The value to set `allow_everyone` to. If not provided, `allow_everyone` will be set to `undefined`.
*/
public setAllowEveryone(allowEveryone?: boolean): this {
this.allow_everyone = allowEveryone;
return this;
Expand Down Expand Up @@ -46,6 +50,9 @@ export class MessageCommandRoleFlagBuilder extends BaseMessageCommandFlagBuilder

public readonly value_type: 'string' = 'string';

/**
* Asynchronously resolves a role flag from the given flag manager.
*/
public static async resolveFlag(name: string, options: MessageCommandFlagManager, required?: boolean): Promise<Role[]> {
return super.resolveFlag(name, options, required);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export class MessageCommandUserFlagBuilder extends BaseMessageCommandFlagBuilder
if (typeof data?.allow_bots === 'boolean') this.setAllowBots(data.allow_bots);
}

/**
* Sets the value of `allow_bots` property.
* @param {boolean} [allowBots] - The new value for `allow_bots`. If not provided, it will be set to `undefined`.
*/
public setAllowBots(allowBots?: boolean): this {
this.allow_bots = allowBots;
return this;
Expand Down Expand Up @@ -46,6 +50,9 @@ export class MessageCommandUserFlagBuilder extends BaseMessageCommandFlagBuilder

public readonly value_type: 'string' = 'string';

/**
* Asynchronously resolves a user flag from the given flag manager.
*/
public static async resolveFlag(name: string, options: MessageCommandFlagManager, required?: boolean): Promise<User[]> {
return super.resolveFlag(name, options, required);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@ export class MessageCommandBooleanOptionBuilder extends BaseMessageCommandOption
return true;
}

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?: 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>;
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 @@ -20,7 +20,6 @@ export class MessageCommandChannelOptionBuilder extends BaseMessageCommandOption

/**
* Sets the channel types for the MessageCommandChannelOptionBuilder.
*
* @param {...RestOrArray<ChannelType>} channel_types - The channel types to set.
*/
public setChannelTypes(...channel_types: RestOrArray<ChannelType>): this {
Expand All @@ -30,9 +29,7 @@ export class MessageCommandChannelOptionBuilder extends BaseMessageCommandOption

/**
* 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));
Expand All @@ -41,9 +38,7 @@ export class MessageCommandChannelOptionBuilder extends BaseMessageCommandOption

/**
* 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;
Expand Down Expand Up @@ -71,11 +66,6 @@ export class MessageCommandChannelOptionBuilder extends BaseMessageCommandOption

/**
* 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 @@ -19,9 +19,7 @@ export class MessageCommandIntegerOptionBuilder extends BaseMessageCommandOption

/**
* 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;
Expand All @@ -30,9 +28,7 @@ export class MessageCommandIntegerOptionBuilder extends BaseMessageCommandOption

/**
* 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;
Expand All @@ -52,17 +48,12 @@ export class MessageCommandIntegerOptionBuilder extends BaseMessageCommandOption
return true;
}

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?: 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>;
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 @@ -18,9 +18,7 @@ export class MessageCommandMessageOptionBuilder extends BaseMessageCommandOption

/**
* 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;
Expand All @@ -29,9 +27,7 @@ export class MessageCommandMessageOptionBuilder extends BaseMessageCommandOption

/**
* 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;
Expand All @@ -55,9 +51,7 @@ export class MessageCommandMessageOptionBuilder extends BaseMessageCommandOption

/**
* 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 @@ -72,17 +66,12 @@ export class MessageCommandMessageOptionBuilder extends BaseMessageCommandOption
return message;
}

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?: 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>;
public static async resolveOption(name: string, options: MessageCommandOptionManager, required?: boolean): Promise<Message|null> {
return super.resolveOption(name, options, required);
}
Expand Down
Loading

0 comments on commit 3104029

Please sign in to comment.