mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
chore: use descriptive type parameter names (#9937)
* chore: use descriptive type parameter names * refactor: requested changes --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -66,8 +66,8 @@ export function validateChoicesLength(amountAdding: number, choices?: APIApplica
|
||||
}
|
||||
|
||||
export function assertReturnOfBuilder<
|
||||
T extends ApplicationCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder,
|
||||
>(input: unknown, ExpectedInstanceOf: new () => T): asserts input is T {
|
||||
ReturnType extends ApplicationCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder,
|
||||
>(input: unknown, ExpectedInstanceOf: new () => ReturnType): asserts input is ReturnType {
|
||||
s.instance(ExpectedInstanceOf).parse(input);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ const booleanPredicate = s.boolean;
|
||||
/**
|
||||
* This mixin holds choices and autocomplete symbols used for options.
|
||||
*/
|
||||
export class ApplicationCommandOptionWithChoicesAndAutocompleteMixin<T extends number | string> {
|
||||
export class ApplicationCommandOptionWithChoicesAndAutocompleteMixin<ChoiceType extends number | string> {
|
||||
/**
|
||||
* The choices of this option.
|
||||
*/
|
||||
public readonly choices?: APIApplicationCommandOptionChoice<T>[];
|
||||
public readonly choices?: APIApplicationCommandOptionChoice<ChoiceType>[];
|
||||
|
||||
/**
|
||||
* Whether this option utilizes autocomplete.
|
||||
@@ -37,7 +37,7 @@ export class ApplicationCommandOptionWithChoicesAndAutocompleteMixin<T extends n
|
||||
*
|
||||
* @param choices - The choices to add
|
||||
*/
|
||||
public addChoices(...choices: APIApplicationCommandOptionChoice<T>[]): this {
|
||||
public addChoices(...choices: APIApplicationCommandOptionChoice<ChoiceType>[]): this {
|
||||
if (choices.length > 0 && this.autocomplete) {
|
||||
throw new RangeError('Autocomplete and choices are mutually exclusive to each other.');
|
||||
}
|
||||
@@ -69,7 +69,7 @@ export class ApplicationCommandOptionWithChoicesAndAutocompleteMixin<T extends n
|
||||
*
|
||||
* @param choices - The choices to set
|
||||
*/
|
||||
public setChoices<Input extends APIApplicationCommandOptionChoice<T>[]>(...choices: Input): this {
|
||||
public setChoices<Input extends APIApplicationCommandOptionChoice<ChoiceType>[]>(...choices: Input): this {
|
||||
if (choices.length > 0 && this.autocomplete) {
|
||||
throw new RangeError('Autocomplete and choices are mutually exclusive to each other.');
|
||||
}
|
||||
|
||||
@@ -148,13 +148,15 @@ export class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
|
||||
* @param Instance - The instance of whatever is being added
|
||||
* @internal
|
||||
*/
|
||||
private _sharedAddOptionMethod<T extends ApplicationCommandOptionBase>(
|
||||
private _sharedAddOptionMethod<OptionBuilder extends ApplicationCommandOptionBase>(
|
||||
input:
|
||||
| Omit<T, 'addChoices'>
|
||||
| Omit<T, 'setAutocomplete'>
|
||||
| T
|
||||
| ((builder: T) => Omit<T, 'addChoices'> | Omit<T, 'setAutocomplete'> | T),
|
||||
Instance: new () => T,
|
||||
| Omit<OptionBuilder, 'addChoices'>
|
||||
| Omit<OptionBuilder, 'setAutocomplete'>
|
||||
| OptionBuilder
|
||||
| ((
|
||||
builder: OptionBuilder,
|
||||
) => Omit<OptionBuilder, 'addChoices'> | Omit<OptionBuilder, 'setAutocomplete'> | OptionBuilder),
|
||||
Instance: new () => OptionBuilder,
|
||||
): ShouldOmitSubcommandFunctions extends true ? Omit<this, 'addSubcommand' | 'addSubcommandGroup'> : this {
|
||||
const { options } = this;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user