Skip to content

Commit

Permalink
fix: fix more instances
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiralite committed Jun 12, 2023
1 parent 3e1c49d commit b3f4317
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 22 deletions.
45 changes: 25 additions & 20 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3713,9 +3713,11 @@ export class ApplicationCommandManager<
id?: Snowflake,
options?: FetchApplicationCommandOptions,
): Promise<Collection<Snowflake, ApplicationCommandScope>>;
public set(commands: ApplicationCommandDataResolvable[]): Promise<Collection<Snowflake, ApplicationCommandScope>>;
public set(
commands: ApplicationCommandDataResolvable[],
commands: readonly ApplicationCommandDataResolvable[],
): Promise<Collection<Snowflake, ApplicationCommandScope>>;
public set(
commands: readonly ApplicationCommandDataResolvable[],
guildId: Snowflake,
): Promise<Collection<Snowflake, ApplicationCommand>>;
private static transformCommand(command: ApplicationCommandDataResolvable): RESTPostAPIApplicationCommandsJSONBody;
Expand Down Expand Up @@ -3748,21 +3750,21 @@ export class ApplicationCommandPermissionsManager<
options:
| (FetchSingleOptions & {
token: string;
channels?: (GuildChannelResolvable | ChannelPermissionConstant)[];
roles?: (RoleResolvable | RolePermissionConstant)[];
users: UserResolvable[];
channels?: readonly (GuildChannelResolvable | ChannelPermissionConstant)[];
roles?: readonly (RoleResolvable | RolePermissionConstant)[];
users: readonly UserResolvable[];
})
| (FetchSingleOptions & {
token: string;
channels?: (GuildChannelResolvable | ChannelPermissionConstant)[];
roles: (RoleResolvable | RolePermissionConstant)[];
users?: UserResolvable[];
channels?: readonly (GuildChannelResolvable | ChannelPermissionConstant)[];
roles: readonly (RoleResolvable | RolePermissionConstant)[];
users?: readonly UserResolvable[];
})
| (FetchSingleOptions & {
token: string;
channels: (GuildChannelResolvable | ChannelPermissionConstant)[];
roles?: (RoleResolvable | RolePermissionConstant)[];
users?: UserResolvable[];
channels: readonly (GuildChannelResolvable | ChannelPermissionConstant)[];
roles?: readonly (RoleResolvable | RolePermissionConstant)[];
users?: readonly UserResolvable[];
}),
): Promise<ApplicationCommandPermissions[]>;
public set(
Expand Down Expand Up @@ -4321,7 +4323,7 @@ export interface ChatInputApplicationCommandData extends BaseApplicationCommandD
description: string;
descriptionLocalizations?: LocalizationMap;
type?: ApplicationCommandType.ChatInput;
options?: ApplicationCommandOptionData[];
options?: readonly ApplicationCommandOptionData[];
}

export type ApplicationCommandData =
Expand Down Expand Up @@ -4407,14 +4409,14 @@ export interface ApplicationCommandAutocompleteStringOptionData
export interface ApplicationCommandChoicesData<Type extends string | number = string | number>
extends Omit<BaseApplicationCommandOptionsData, 'autocomplete'> {
type: CommandOptionChoiceResolvableType;
choices?: ApplicationCommandOptionChoiceData<Type>[];
choices?: readonly ApplicationCommandOptionChoiceData<Type>[];
autocomplete?: false;
}

export interface ApplicationCommandChoicesOption<Type extends string | number = string | number>
extends Omit<BaseApplicationCommandOptionsData, 'autocomplete'> {
type: CommandOptionChoiceResolvableType;
choices?: ApplicationCommandOptionChoiceData<Type>[];
choices?: readonly ApplicationCommandOptionChoiceData<Type>[];
autocomplete?: false;
}

Expand Down Expand Up @@ -4456,22 +4458,25 @@ export interface ApplicationCommandBooleanOption extends BaseApplicationCommandO

export interface ApplicationCommandSubGroupData extends Omit<BaseApplicationCommandOptionsData, 'required'> {
type: ApplicationCommandOptionType.SubcommandGroup;
options: ApplicationCommandSubCommandData[];
options: readonly ApplicationCommandSubCommandData[];
}

export interface ApplicationCommandSubGroup extends Omit<BaseApplicationCommandOptionsData, 'required'> {
type: ApplicationCommandOptionType.SubcommandGroup;
options?: ApplicationCommandSubCommand[];
options?: readonly ApplicationCommandSubCommand[];
}

export interface ApplicationCommandSubCommandData extends Omit<BaseApplicationCommandOptionsData, 'required'> {
type: ApplicationCommandOptionType.Subcommand;
options?: Exclude<ApplicationCommandOptionData, ApplicationCommandSubGroupData | ApplicationCommandSubCommandData>[];
options?: readonly Exclude<
ApplicationCommandOptionData,
ApplicationCommandSubGroupData | ApplicationCommandSubCommandData
>[];
}

export interface ApplicationCommandSubCommand extends Omit<BaseApplicationCommandOptionsData, 'required'> {
type: ApplicationCommandOptionType.Subcommand;
options?: Exclude<ApplicationCommandOption, ApplicationCommandSubGroup | ApplicationCommandSubCommand>[];
options?: readonly Exclude<ApplicationCommandOption, ApplicationCommandSubGroup | ApplicationCommandSubCommand>[];
}

export interface ApplicationCommandNonOptionsData extends BaseApplicationCommandOptionsData {
Expand Down Expand Up @@ -4527,11 +4532,11 @@ export interface ApplicationCommandPermissionsUpdateData {
id: Snowflake;
guildId: Snowflake;
applicationId: Snowflake;
permissions: ApplicationCommandPermissions[];
permissions: readonly ApplicationCommandPermissions[];
}

export interface EditApplicationCommandPermissionsMixin {
permissions: ApplicationCommandPermissions[];
permissions: readonly ApplicationCommandPermissions[];
token: string;
}

Expand Down
61 changes: 59 additions & 2 deletions packages/discord.js/typings/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ import {
ThreadManager,
FetchedThreads,
FetchedThreadsMore,
ApplicationCommandChannelOptionData,
ApplicationCommandChannelOption,
ApplicationCommandChoicesOption,
ApplicationCommandChoicesData,
ApplicationCommandSubGroup,
ApplicationCommandSubCommand,
ChatInputApplicationCommandData,
ApplicationCommandPermissionsManager,
} from '.';
import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd';
import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders';
Expand Down Expand Up @@ -1355,7 +1363,7 @@ declare const applicationCommandManager: ApplicationCommandManager;
applicationCommandManager.set([applicationCommandData]),
);
expectType<Promise<Collection<Snowflake, ApplicationCommand>>>(
applicationCommandManager.set([applicationCommandData], '0'),
applicationCommandManager.set([applicationCommandData] as const, '0'),
);

// Test inference of choice values.
Expand All @@ -1377,6 +1385,33 @@ declare const applicationCommandManager: ApplicationCommandManager;
}
}

declare const applicationCommandPermissionsManager: ApplicationCommandPermissionsManager<
{},
{},
Guild | null,
Snowflake
>;
{
applicationCommandPermissionsManager.add({ permissions: [], token: '' });
applicationCommandPermissionsManager.add({ permissions: [] as const, token: '' });
applicationCommandPermissionsManager.set({ permissions: [], token: '' });
applicationCommandPermissionsManager.set({ permissions: [] as const, token: '' });
applicationCommandPermissionsManager.remove({ channels: [], roles: [], users: [], token: '' });

applicationCommandPermissionsManager.remove({
channels: [] as const,
roles: [] as const,
users: [] as const,
token: '',
});
}

declare const chatInputApplicationCommandData: ChatInputApplicationCommandData;
{
chatInputApplicationCommandData.options = [];
chatInputApplicationCommandData.options = [] as const;
}

declare const applicationCommandChannelOptionData: ApplicationCommandChannelOptionData;
declare const applicationCommandChannelOption: ApplicationCommandChannelOption;
{
Expand All @@ -1395,10 +1430,32 @@ declare const applicationNonChoiceOptionData: ApplicationCommandOptionData & {
applicationNonChoiceOptionData.choices;
}

declare const applicationCommandChoicesData: ApplicationCommandChoicesData;
declare const applicationCommandChoicesOption: ApplicationCommandChoicesOption;
{
applicationCommandChoicesData.choices = [];
applicationCommandChoicesData.choices = [] as const;
applicationCommandChoicesOption.choices = [];
applicationCommandChoicesOption.choices = [] as const;
}

declare const applicationCommandSubCommandData: ApplicationCommandSubCommandData;
declare const applicationCommandSubCommand: ApplicationCommandSubCommand;
{
applicationCommandSubCommandData.options = [];
applicationCommandSubCommandData.options = [] as const;
applicationCommandSubCommand.options = [];
applicationCommandSubCommand.options = [] as const;
}

declare const applicationSubGroupCommandData: ApplicationCommandSubGroupData;
declare const applicationCommandSubGroup: ApplicationCommandSubGroup;
{
expectType<ApplicationCommandOptionType.SubcommandGroup>(applicationSubGroupCommandData.type);
expectType<ApplicationCommandSubCommandData[]>(applicationSubGroupCommandData.options);
applicationSubGroupCommandData.options = [];
applicationSubGroupCommandData.options = [] as const;
applicationCommandSubGroup.options = [];
applicationCommandSubGroup.options = [] as const;
}

declare const autoModerationRuleManager: AutoModerationRuleManager;
Expand Down

0 comments on commit b3f4317

Please sign in to comment.