From feaea8034a69a73e1fc18f721667bff5bd6277b2 Mon Sep 17 00:00:00 2001 From: Toastie Date: Thu, 12 Sep 2024 17:52:06 +1200 Subject: [PATCH] Added payload files --- payloads/common.ts | 104 + payloads/index.ts | 4 + .../_chatInput/attachment.ts | 11 + .../_applicationCommands/_chatInput/base.ts | 29 + .../_chatInput/boolean.ts | 9 + .../_chatInput/channel.ts | 14 + .../_chatInput/integer.ts | 28 + .../_chatInput/mentionable.ts | 11 + .../_applicationCommands/_chatInput/number.ts | 28 + .../_applicationCommands/_chatInput/role.ts | 10 + .../_applicationCommands/_chatInput/shared.ts | 27 + .../_applicationCommands/_chatInput/string.ts | 28 + .../_chatInput/subcommand.ts | 14 + .../_chatInput/subcommandGroup.ts | 17 + .../_applicationCommands/_chatInput/user.ts | 10 + .../_applicationCommands/chatInput.ts | 130 ++ .../_applicationCommands/contextMenu.ts | 91 + .../_applicationCommands/internals.ts | 9 + .../_applicationCommands/permissions.ts | 58 + .../v9/_interactions/applicationCommands.ts | 138 ++ payloads/v9/_interactions/autocomplete.ts | 33 + payloads/v9/_interactions/base.ts | 174 ++ .../v9/_interactions/messageComponents.ts | 97 + payloads/v9/_interactions/modalSubmit.ts | 49 + payloads/v9/_interactions/ping.ts | 4 + payloads/v9/_interactions/responses.ts | 124 ++ payloads/v9/application.ts | 252 +++ payloads/v9/auditLog.ts | 811 ++++++++ payloads/v9/autoModeration.ts | 203 ++ payloads/v9/channel.ts | 1724 +++++++++++++++++ payloads/v9/emoji.ts | 51 + payloads/v9/gateway.ts | 378 ++++ payloads/v9/guild.ts | 1009 ++++++++++ payloads/v9/guildScheduledEvent.ts | 152 ++ payloads/v9/index.ts | 20 + payloads/v9/interactions.ts | 57 + payloads/v9/invite.ts | 126 ++ payloads/v9/oauth2.ts | 132 ++ payloads/v9/permissions.ts | 87 + payloads/v9/stageInstance.ts | 79 + payloads/v9/sticker.ts | 128 ++ payloads/v9/teams.ts | 66 + payloads/v9/template.ts | 65 + payloads/v9/user.ts | 347 ++++ payloads/v9/voice.ts | 92 + payloads/v9/webhook.ts | 79 + 46 files changed, 7109 insertions(+) create mode 100644 payloads/common.ts create mode 100644 payloads/index.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/_chatInput/attachment.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/_chatInput/base.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/_chatInput/boolean.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/_chatInput/channel.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/_chatInput/integer.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/_chatInput/mentionable.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/_chatInput/number.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/_chatInput/role.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/_chatInput/shared.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/_chatInput/string.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/_chatInput/subcommand.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/_chatInput/user.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/chatInput.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/contextMenu.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/internals.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/permissions.ts create mode 100644 payloads/v9/_interactions/applicationCommands.ts create mode 100644 payloads/v9/_interactions/autocomplete.ts create mode 100644 payloads/v9/_interactions/base.ts create mode 100644 payloads/v9/_interactions/messageComponents.ts create mode 100644 payloads/v9/_interactions/modalSubmit.ts create mode 100644 payloads/v9/_interactions/ping.ts create mode 100644 payloads/v9/_interactions/responses.ts create mode 100644 payloads/v9/application.ts create mode 100644 payloads/v9/auditLog.ts create mode 100644 payloads/v9/autoModeration.ts create mode 100644 payloads/v9/channel.ts create mode 100644 payloads/v9/emoji.ts create mode 100644 payloads/v9/gateway.ts create mode 100644 payloads/v9/guild.ts create mode 100644 payloads/v9/guildScheduledEvent.ts create mode 100644 payloads/v9/index.ts create mode 100644 payloads/v9/interactions.ts create mode 100644 payloads/v9/invite.ts create mode 100644 payloads/v9/oauth2.ts create mode 100644 payloads/v9/permissions.ts create mode 100644 payloads/v9/stageInstance.ts create mode 100644 payloads/v9/sticker.ts create mode 100644 payloads/v9/teams.ts create mode 100644 payloads/v9/template.ts create mode 100644 payloads/v9/user.ts create mode 100644 payloads/v9/voice.ts create mode 100644 payloads/v9/webhook.ts diff --git a/payloads/common.ts b/payloads/common.ts new file mode 100644 index 0000000..bf336e1 --- /dev/null +++ b/payloads/common.ts @@ -0,0 +1,104 @@ +import type { LocaleString } from '../rest/common'; + +/** + * https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags + * + * These flags are exported as `BigInt`s and NOT numbers. Wrapping them in `Number()` + * may cause issues, try to use BigInts as much as possible or modules that can + * replicate them in some way + */ +export const PermissionFlagsBits = { + CreateInstantInvite: BigInt(1) << BigInt(0), + KickMembers: BigInt(1) << BigInt(1), + BanMembers: BigInt(1) << BigInt(2), + Administrator: BigInt(1) << BigInt(3), + ManageChannels: BigInt(1) << BigInt(4), + ManageGuild: BigInt(1) << BigInt(5), + AddReactions: BigInt(1) << BigInt(6), + ViewAuditLog: BigInt(1) << BigInt(7), + PrioritySpeaker: BigInt(1) << BigInt(8), + Stream: BigInt(1) << BigInt(9), + ViewChannel: BigInt(1) << BigInt(10), + SendMessages: BigInt(1) << BigInt(11), + SendTTSMessages: BigInt(1) << BigInt(12), + ManageMessages: BigInt(1) << BigInt(13), + EmbedLinks: BigInt(1) << BigInt(14), + AttachFiles: BigInt(1) << BigInt(15), + ReadMessageHistory: BigInt(1) << BigInt(16), + MentionEveryone: BigInt(1) << BigInt(17), + UseExternalEmojis: BigInt(1) << BigInt(18), + ViewGuildInsights: BigInt(1) << BigInt(19), + Connect: BigInt(1) << BigInt(20), + Speak: BigInt(1) << BigInt(21), + MuteMembers: BigInt(1) << BigInt(22), + DeafenMembers: BigInt(1) << BigInt(23), + MoveMembers: BigInt(1) << BigInt(24), + UseVAD: BigInt(1) << BigInt(25), + ChangeNickname: BigInt(1) << BigInt(26), + ManageNicknames: BigInt(1) << BigInt(27), + ManageRoles: BigInt(1) << BigInt(28), + ManageWebhooks: BigInt(1) << BigInt(29), + ManageEmojisAndStickers: BigInt(1) << BigInt(30), + UseApplicationCommands: BigInt(1) << BigInt(31), + RequestToSpeak: BigInt(1) << BigInt(32), + ManageEvents: BigInt(1) << BigInt(33), + ManageThreads: BigInt(1) << BigInt(34), + CreatePublicThreads: BigInt(1) << BigInt(35), + CreatePrivateThreads: BigInt(1) << BigInt(36), + UseExternalStickers: BigInt(1) << BigInt(37), + SendMessagesInThreads: BigInt(1) << BigInt(38), + UseEmbeddedActivities: BigInt(1) << BigInt(39), + ModerateMembers: BigInt(1) << BigInt(40), +} as const; + +/** + * Freeze the object of bits, preventing any modifications to it + * @internal + */ +Object.freeze(PermissionFlagsBits); + +export type LocalizationMap = Partial>; + +/** + * https://discord.com/developers/docs/topics/opcodes-and-status-codes#json + */ +export interface RESTError { + code: number; + message: string; + errors?: RESTErrorData; +} + +export interface RESTErrorFieldInformation { + code: string; + message: string; +} + +export interface RESTErrorGroupWrapper { + _errors: RESTErrorData[]; +} + +export type RESTErrorData = RESTErrorGroupWrapper | RESTErrorFieldInformation | { [k: string]: RESTErrorData } | string; + +/** + * https://discord.com/developers/docs/topics/rate-limits#exceeding-a-rate-limit-rate-limit-response-structure + */ +export interface RESTRateLimit { + /** + * An error code for some limits + * + * {@link RESTJSONErrorCodes} + */ + code?: number; + /** + * A value indicating if you are being globally rate limited or not + */ + global: boolean; + /** + * A message saying you are being rate limited. + */ + message: string; + /** + * The number of seconds to wait before submitting another request. + */ + retry_after: number; +} diff --git a/payloads/index.ts b/payloads/index.ts new file mode 100644 index 0000000..fad3a48 --- /dev/null +++ b/payloads/index.ts @@ -0,0 +1,4 @@ +// This file exports all the payloads available in the recommended API version +// Thereby, things MAY break in the future. Try sticking to imports from a specific version + +export * from './v9/index'; diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/attachment.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/attachment.ts new file mode 100644 index 0000000..2e2441e --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/attachment.ts @@ -0,0 +1,11 @@ +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; +import type { Snowflake } from '../../../../../globals'; + +export type APIApplicationCommandAttachmentOption = + APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataAttachmentOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Attachment, + Snowflake +>; diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/base.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/base.ts new file mode 100644 index 0000000..03a9454 --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/base.ts @@ -0,0 +1,29 @@ +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared'; +import type { LocalizationMap } from '../../../../../v9'; + +export interface APIApplicationCommandOptionBase { + type: Type; + name: string; + name_localizations?: LocalizationMap | null; + description: string; + description_localizations?: LocalizationMap | null; + required?: boolean; +} + +export interface APIInteractionDataOptionBase { + name: string; + type: T; + value: D; +} + +export type APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + Base extends APIApplicationCommandOptionBase, + ChoiceType extends APIApplicationCommandOptionChoice, +> = + | (Base & { + autocomplete: true; + }) + | (Base & { + autocomplete?: false; + choices?: ChoiceType[]; + }); diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/boolean.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/boolean.ts new file mode 100644 index 0000000..5743325 --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/boolean.ts @@ -0,0 +1,9 @@ +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export type APIApplicationCommandBooleanOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataBooleanOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Boolean, + boolean +>; diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/channel.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/channel.ts new file mode 100644 index 0000000..39183cd --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/channel.ts @@ -0,0 +1,14 @@ +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; +import type { Snowflake } from '../../../../../globals'; +import type { ChannelType } from '../../../channel'; + +export interface APIApplicationCommandChannelOption + extends APIApplicationCommandOptionBase { + channel_types?: Exclude[]; +} + +export type APIApplicationCommandInteractionDataChannelOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Channel, + Snowflake +>; diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/integer.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/integer.ts new file mode 100644 index 0000000..6da871b --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/integer.ts @@ -0,0 +1,28 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared'; + +interface APIApplicationCommandIntegerOptionBase + extends APIApplicationCommandOptionBase { + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + min_value?: number; + /** + * If the option is an `INTEGER` or `NUMBER` type, the maximum value permitted. + */ + max_value?: number; +} + +export type APIApplicationCommandIntegerOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandIntegerOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataIntegerOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/mentionable.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/mentionable.ts new file mode 100644 index 0000000..59dd3bb --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/mentionable.ts @@ -0,0 +1,11 @@ +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; +import type { Snowflake } from '../../../../../globals'; + +export type APIApplicationCommandMentionableOption = + APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataMentionableOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Mentionable, + Snowflake +>; diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/number.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/number.ts new file mode 100644 index 0000000..108b110 --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/number.ts @@ -0,0 +1,28 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared'; + +interface APIApplicationCommandNumberOptionBase + extends APIApplicationCommandOptionBase { + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + min_value?: number; + /** + * If the option is an `INTEGER` or `NUMBER` type, the maximum value permitted. + */ + max_value?: number; +} + +export type APIApplicationCommandNumberOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandNumberOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataNumberOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/role.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/role.ts new file mode 100644 index 0000000..2f6d80c --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/role.ts @@ -0,0 +1,10 @@ +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; +import type { Snowflake } from '../../../../../globals'; + +export type APIApplicationCommandRoleOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataRoleOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Role, + Snowflake +>; diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/shared.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/shared.ts new file mode 100644 index 0000000..506ff40 --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/shared.ts @@ -0,0 +1,27 @@ +import type { LocalizationMap } from '../../../../../v9'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type + */ +export enum ApplicationCommandOptionType { + Subcommand = 1, + SubcommandGroup, + String, + Integer, + Boolean, + User, + Channel, + Role, + Mentionable, + Number, + Attachment, +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure + */ +export interface APIApplicationCommandOptionChoice { + name: string; + name_localizations?: LocalizationMap | null; + value: ValueType; +} diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/string.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/string.ts new file mode 100644 index 0000000..a789ace --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/string.ts @@ -0,0 +1,28 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared'; + +interface APIApplicationCommandStringOptionBase + extends APIApplicationCommandOptionBase { + /** + * For option type `STRING`, the minimum allowed length (minimum of `0`, maximum of `6000`). + */ + min_length?: number; + /** + * For option type `STRING`, the maximum allowed length (minimum of `1`, maximum of `6000`). + */ + max_length?: number; +} + +export type APIApplicationCommandStringOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandStringOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataStringOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommand.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommand.ts new file mode 100644 index 0000000..c8c8b9c --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommand.ts @@ -0,0 +1,14 @@ +import type { APIApplicationCommandOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; +import type { APIApplicationCommandBasicOption, APIApplicationCommandInteractionDataBasicOption } from '../chatInput'; + +export interface APIApplicationCommandSubcommandOption + extends APIApplicationCommandOptionBase { + options?: APIApplicationCommandBasicOption[]; +} + +export interface APIApplicationCommandInteractionDataSubcommandOption { + name: string; + type: ApplicationCommandOptionType.Subcommand; + options?: APIApplicationCommandInteractionDataBasicOption[]; +} diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts new file mode 100644 index 0000000..37d5f72 --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts @@ -0,0 +1,17 @@ +import type { APIApplicationCommandOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; +import type { + APIApplicationCommandInteractionDataSubcommandOption, + APIApplicationCommandSubcommandOption, +} from './subcommand'; + +export interface APIApplicationCommandSubcommandGroupOption + extends APIApplicationCommandOptionBase { + options?: APIApplicationCommandSubcommandOption[]; +} + +export interface APIApplicationCommandInteractionDataSubcommandGroupOption { + name: string; + type: ApplicationCommandOptionType.SubcommandGroup; + options: APIApplicationCommandInteractionDataSubcommandOption[]; +} diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/user.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/user.ts new file mode 100644 index 0000000..a87bd7f --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/user.ts @@ -0,0 +1,10 @@ +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; +import type { Snowflake } from '../../../../../globals'; + +export type APIApplicationCommandUserOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataUserOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.User, + Snowflake +>; diff --git a/payloads/v9/_interactions/_applicationCommands/chatInput.ts b/payloads/v9/_interactions/_applicationCommands/chatInput.ts new file mode 100644 index 0000000..e0c34d7 --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/chatInput.ts @@ -0,0 +1,130 @@ +import type { + APIApplicationCommandAttachmentOption, + APIApplicationCommandInteractionDataAttachmentOption, +} from './_chatInput/attachment'; +import type { + APIApplicationCommandBooleanOption, + APIApplicationCommandInteractionDataBooleanOption, +} from './_chatInput/boolean'; +import type { + APIApplicationCommandChannelOption, + APIApplicationCommandInteractionDataChannelOption, +} from './_chatInput/channel'; +import type { + APIApplicationCommandIntegerOption, + APIApplicationCommandInteractionDataIntegerOption, +} from './_chatInput/integer'; +import type { + APIApplicationCommandInteractionDataMentionableOption, + APIApplicationCommandMentionableOption, +} from './_chatInput/mentionable'; +import type { + APIApplicationCommandInteractionDataNumberOption, + APIApplicationCommandNumberOption, +} from './_chatInput/number'; +import type { + APIApplicationCommandInteractionDataRoleOption, + APIApplicationCommandRoleOption, +} from './_chatInput/role'; +import type { + APIApplicationCommandInteractionDataStringOption, + APIApplicationCommandStringOption, +} from './_chatInput/string'; +import type { + APIApplicationCommandInteractionDataSubcommandOption, + APIApplicationCommandSubcommandOption, +} from './_chatInput/subcommand'; +import type { + APIApplicationCommandInteractionDataSubcommandGroupOption, + APIApplicationCommandSubcommandGroupOption, +} from './_chatInput/subcommandGroup'; +import type { + APIApplicationCommandInteractionDataUserOption, + APIApplicationCommandUserOption, +} from './_chatInput/user'; +import type { APIBaseApplicationCommandInteractionData } from './internals'; +import type { APIInteractionDataResolved } from '../../index'; +import type { APIApplicationCommandInteractionWrapper, ApplicationCommandType } from '../applicationCommands'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base'; + +export * from './_chatInput/attachment'; +export * from './_chatInput/base'; +export * from './_chatInput/boolean'; +export * from './_chatInput/channel'; +export * from './_chatInput/integer'; +export * from './_chatInput/mentionable'; +export * from './_chatInput/number'; +export * from './_chatInput/role'; +export * from './_chatInput/shared'; +export * from './_chatInput/string'; +export * from './_chatInput/subcommand'; +export * from './_chatInput/subcommandGroup'; +export * from './_chatInput/user'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure + */ +export type APIApplicationCommandBasicOption = + | APIApplicationCommandStringOption + | APIApplicationCommandIntegerOption + | APIApplicationCommandBooleanOption + | APIApplicationCommandUserOption + | APIApplicationCommandChannelOption + | APIApplicationCommandRoleOption + | APIApplicationCommandMentionableOption + | APIApplicationCommandNumberOption + | APIApplicationCommandAttachmentOption; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure + */ +export type APIApplicationCommandOption = + | APIApplicationCommandSubcommandOption + | APIApplicationCommandSubcommandGroupOption + | APIApplicationCommandBasicOption; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-interaction-data-option-structure + */ +export type APIApplicationCommandInteractionDataOption = + | APIApplicationCommandInteractionDataSubcommandOption + | APIApplicationCommandInteractionDataSubcommandGroupOption + | APIApplicationCommandInteractionDataBasicOption; + +export type APIApplicationCommandInteractionDataBasicOption = + | APIApplicationCommandInteractionDataStringOption + | APIApplicationCommandInteractionDataIntegerOption + | APIApplicationCommandInteractionDataBooleanOption + | APIApplicationCommandInteractionDataUserOption + | APIApplicationCommandInteractionDataChannelOption + | APIApplicationCommandInteractionDataRoleOption + | APIApplicationCommandInteractionDataMentionableOption + | APIApplicationCommandInteractionDataNumberOption + | APIApplicationCommandInteractionDataAttachmentOption; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data + */ +export interface APIChatInputApplicationCommandInteractionData + extends APIBaseApplicationCommandInteractionData { + options?: APIApplicationCommandInteractionDataOption[]; + resolved?: APIInteractionDataResolved; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIChatInputApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIChatInputApplicationCommandDMInteraction = + APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIChatInputApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; diff --git a/payloads/v9/_interactions/_applicationCommands/contextMenu.ts b/payloads/v9/_interactions/_applicationCommands/contextMenu.ts new file mode 100644 index 0000000..a56542e --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/contextMenu.ts @@ -0,0 +1,91 @@ +import type { APIBaseApplicationCommandInteractionData } from './internals'; +import type { Snowflake } from '../../../../globals'; +import type { APIMessage } from '../../channel'; +import type { APIApplicationCommandInteractionWrapper, ApplicationCommandType } from '../applicationCommands'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper, APIUserInteractionDataResolved } from '../base'; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data + */ +export interface APIUserApplicationCommandInteractionData + extends APIBaseApplicationCommandInteractionData { + target_id: Snowflake; + resolved: APIUserInteractionDataResolved; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data + */ +export interface APIMessageApplicationCommandInteractionData + extends APIBaseApplicationCommandInteractionData { + target_id: Snowflake; + resolved: APIMessageApplicationCommandInteractionDataResolved; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure + */ +export interface APIMessageApplicationCommandInteractionDataResolved { + messages: Record; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data + */ +export type APIContextMenuInteractionData = + | APIUserApplicationCommandInteractionData + | APIMessageApplicationCommandInteractionData; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandDMInteraction = APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandDMInteraction = + APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuInteraction = APIUserApplicationCommandInteraction | APIMessageApplicationCommandInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuDMInteraction = + | APIUserApplicationCommandDMInteraction + | APIMessageApplicationCommandDMInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuGuildInteraction = + | APIUserApplicationCommandGuildInteraction + | APIMessageApplicationCommandGuildInteraction; diff --git a/payloads/v9/_interactions/_applicationCommands/internals.ts b/payloads/v9/_interactions/_applicationCommands/internals.ts new file mode 100644 index 0000000..8432ffb --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/internals.ts @@ -0,0 +1,9 @@ +import type { Snowflake } from '../../../../globals'; +import type { ApplicationCommandType } from '../applicationCommands'; + +export interface APIBaseApplicationCommandInteractionData { + id: Snowflake; + type: Type; + name: string; + guild_id?: Snowflake; +} diff --git a/payloads/v9/_interactions/_applicationCommands/permissions.ts b/payloads/v9/_interactions/_applicationCommands/permissions.ts new file mode 100644 index 0000000..948501c --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/permissions.ts @@ -0,0 +1,58 @@ +import type { Snowflake } from '../../../../globals'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure + */ +export interface APIGuildApplicationCommandPermissions { + /** + * The id of the command or the application id if that permission applies to all commands + */ + id: Snowflake; + /** + * The id of the application the command belongs to + */ + application_id: Snowflake; + /** + * The id of the guild + */ + guild_id: Snowflake; + /** + * The permissions for the command in the guild + */ + permissions: APIApplicationCommandPermission[]; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-structure + */ +export interface APIApplicationCommandPermission { + /** + * The id of the role, user or channel. Can also be a permission constant + */ + id: Snowflake; + /** + * Role, user or channel + */ + type: ApplicationCommandPermissionType; + /** + * `true` to allow, `false`, to disallow + */ + permission: boolean; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type + */ +export enum ApplicationCommandPermissionType { + Role = 1, + User, + Channel, +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-constants + */ +export const APIApplicationCommandPermissionsConstant = { + Everyone: (guildId: string | bigint): Snowflake => String(guildId), + AllChannels: (guildId: string | bigint): Snowflake => String(BigInt(guildId) - BigInt(1)), +}; diff --git a/payloads/v9/_interactions/applicationCommands.ts b/payloads/v9/_interactions/applicationCommands.ts new file mode 100644 index 0000000..2c9c716 --- /dev/null +++ b/payloads/v9/_interactions/applicationCommands.ts @@ -0,0 +1,138 @@ +import type { + APIApplicationCommandOption, + APIChatInputApplicationCommandDMInteraction, + APIChatInputApplicationCommandGuildInteraction, + APIChatInputApplicationCommandInteraction, + APIChatInputApplicationCommandInteractionData, +} from './_applicationCommands/chatInput'; +import type { + APIContextMenuDMInteraction, + APIContextMenuGuildInteraction, + APIContextMenuInteraction, + APIContextMenuInteractionData, +} from './_applicationCommands/contextMenu'; +import type { APIBaseInteraction } from './base'; +import type { InteractionType } from './responses'; +import type { Permissions, Snowflake } from '../../../globals'; +import type { LocalizationMap } from '../../../v9'; + +export * from './_applicationCommands/chatInput'; +export * from './_applicationCommands/contextMenu'; +export * from './_applicationCommands/permissions'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object + */ +export interface APIApplicationCommand { + /** + * Unique id of the command + */ + id: Snowflake; + /** + * Type of the command + */ + type: ApplicationCommandType; + /** + * Unique id of the parent application + */ + application_id: Snowflake; + /** + * Guild id of the command, if not global + */ + guild_id?: Snowflake; + /** + * 1-32 character name; `CHAT_INPUT` command names must be all lowercase matching `^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$` + */ + name: string; + /** + * Localization dictionary for the name field. Values follow the same restrictions as name + */ + name_localizations?: LocalizationMap | null; + /** + * The localized name + */ + name_localized?: string; + /** + * 1-100 character description for `CHAT_INPUT` commands, empty string for `USER` and `MESSAGE` commands + */ + description: string; + /** + * Localization dictionary for the description field. Values follow the same restrictions as description + */ + description_localizations?: LocalizationMap | null; + /** + * The localized description + */ + description_localized?: string; + /** + * The parameters for the `CHAT_INPUT` command, max 25 + */ + options?: APIApplicationCommandOption[]; + /** + * Set of permissions represented as a bitset + */ + default_member_permissions: Permissions | null; + /** + * Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible + */ + dm_permission?: boolean; + /** + * Whether the command is enabled by default when the app is added to a guild + * + * If missing, this property should be assumed as `true` + * @deprecated Use `dm_permission` and/or `default_member_permissions` instead + */ + default_permission?: boolean; + /** + * Indicates whether the command is age-restricted, defaults to `false` + */ + nsfw?: boolean; + /** + * Autoincrementing version identifier updated during substantial record changes + */ + version: Snowflake; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types + */ +export enum ApplicationCommandType { + ChatInput = 1, + User, + Message, +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data + */ +export type APIApplicationCommandInteractionData = + | APIChatInputApplicationCommandInteractionData + | APIContextMenuInteractionData; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandInteractionWrapper = + APIBaseInteraction & + Required< + Pick, 'channel_id' | 'data' | 'app_permissions'> + >; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandInteraction = APIChatInputApplicationCommandInteraction | APIContextMenuInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandDMInteraction = + | APIChatInputApplicationCommandDMInteraction + | APIContextMenuDMInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandGuildInteraction = + | APIChatInputApplicationCommandGuildInteraction + | APIContextMenuGuildInteraction; diff --git a/payloads/v9/_interactions/autocomplete.ts b/payloads/v9/_interactions/autocomplete.ts new file mode 100644 index 0000000..79d5485 --- /dev/null +++ b/payloads/v9/_interactions/autocomplete.ts @@ -0,0 +1,33 @@ +import type { + APIBaseInteraction, + APIChatInputApplicationCommandInteractionData, + APIDMInteractionWrapper, + APIGuildInteractionWrapper, + InteractionType, +} from '../index'; + +export type APIApplicationCommandAutocompleteInteraction = APIBaseInteraction< + InteractionType.ApplicationCommandAutocomplete, + APIChatInputApplicationCommandInteractionData +> & + Required< + Pick< + APIBaseInteraction< + InteractionType.ApplicationCommandAutocomplete, + Required> + >, + 'data' + > + >; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandAutocompleteDMInteraction = + APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandAutocompleteGuildInteraction = + APIGuildInteractionWrapper; diff --git a/payloads/v9/_interactions/base.ts b/payloads/v9/_interactions/base.ts new file mode 100644 index 0000000..3b1a0a7 --- /dev/null +++ b/payloads/v9/_interactions/base.ts @@ -0,0 +1,174 @@ +import type { InteractionType } from './responses'; +import type { Permissions, Snowflake } from '../../../globals'; +import type { APIRole, LocaleString } from '../../../v9'; +import type { APIAttachment, APIMessage, APIPartialChannel, APIThreadMetadata } from '../channel'; +import type { APIGuildMember } from '../guild'; +import type { APIUser } from '../user'; + +export type PartialAPIMessageInteractionGuildMember = Pick< + APIGuildMember, + | 'roles' + | 'premium_since' + | 'pending' + | 'nick' + | 'mute' + | 'joined_at' + | 'deaf' + | 'communication_disabled_until' + | 'avatar' +>; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object + */ +export interface APIMessageInteraction { + /** + * ID of the interaction + */ + id: Snowflake; + /** + * The type of interaction + */ + type: InteractionType; + /** + * The name of the application command, including subcommands and subcommand groups + */ + name: string; + /** + * The user who invoked the interaction + */ + user: APIUser; + /** + * The guild member who invoked the interaction, only sent in MESSAGE_CREATE events + */ + member?: PartialAPIMessageInteractionGuildMember; +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-member-object + */ +export interface APIInteractionGuildMember extends APIGuildMember { + permissions: Permissions; + user: APIUser; +} + +// INTERACTIONS RECEIVED + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export interface APIBaseInteraction { + /** + * ID of the interaction + */ + id: Snowflake; + /** + * ID of the application this interaction is for + */ + application_id: Snowflake; + /** + * The type of interaction + */ + type: Type; + /** + * The command data payload + */ + data?: Data; + /** + * The guild it was sent from + */ + guild_id?: Snowflake; + /** + * The channel it was sent from + */ + channel_id?: Snowflake; + /** + * Guild member data for the invoking user, including permissions + * + * **This is only sent when an interaction is invoked in a guild** + */ + member?: APIInteractionGuildMember; + /** + * User object for the invoking user, if invoked in a DM + */ + user?: APIUser; + /** + * A continuation token for responding to the interaction + */ + token: string; + /** + * Read-only property, always `1` + */ + version: 1; + /** + * For components, the message they were attached to + */ + message?: APIMessage; + /** + * Bitwise set of permissions the app or bot has within the channel the interaction was sent from + */ + app_permissions?: Permissions; + /** + * The selected language of the invoking user + */ + locale: LocaleString; + /** + * The guild's preferred locale, if invoked in a guild + */ + guild_locale?: LocaleString; +} + +export type APIDMInteractionWrapper> = Omit< + Original, + 'member' | 'guild_id' +> & + Required>; + +export type APIGuildInteractionWrapper> = Omit< + Original, + 'user' +> & + Required>; + +/** + * https://discord.com/developers/docs/resources/channel#channel-object + */ +export interface APIInteractionDataResolvedChannel extends Required { + thread_metadata?: APIThreadMetadata | null; + permissions: Permissions; + parent_id?: string | null; +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-member-object + */ +export interface APIInteractionDataResolvedGuildMember extends Omit { + permissions: Permissions; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure + */ +export interface APIInteractionDataResolved { + users?: Record; + roles?: Record; + members?: Record; + channels?: Record; + attachments?: Record; +} + +/** + * @deprecated Renamed to `APIInteractionDataResolved` + */ +export type APIChatInputApplicationCommandInteractionDataResolved = APIInteractionDataResolved; + +/** + * `users` and optional `members` from APIInteractionDataResolved, for user commands and user selects + */ +export type APIUserInteractionDataResolved = Required> & + Pick; + +/** + * @deprecated Renamed to `APIUserInteractionDataResolved` + */ +export type APIUserApplicationCommandInteractionDataResolved = APIUserInteractionDataResolved; diff --git a/payloads/v9/_interactions/messageComponents.ts b/payloads/v9/_interactions/messageComponents.ts new file mode 100644 index 0000000..269c9f7 --- /dev/null +++ b/payloads/v9/_interactions/messageComponents.ts @@ -0,0 +1,97 @@ +import type { + APIDMInteractionWrapper, + APIGuildInteractionWrapper, + APIInteractionDataResolved, + APIUserInteractionDataResolved, +} from './base'; +import type { Snowflake } from '../../../globals'; +import type { ComponentType } from '../channel'; +import type { APIBaseInteraction, InteractionType } from '../interactions'; + +export type APIMessageComponentInteraction = APIBaseInteraction< + InteractionType.MessageComponent, + APIMessageComponentInteractionData +> & + Required< + Pick< + APIBaseInteraction, + 'channel_id' | 'data' | 'app_permissions' | 'message' + > + >; + +export type APIMessageComponentButtonInteraction = APIBaseInteraction< + InteractionType.MessageComponent, + APIMessageButtonInteractionData +> & + Required< + Pick< + APIBaseInteraction, + 'channel_id' | 'data' | 'app_permissions' | 'message' + > + >; + +export type APIMessageComponentSelectMenuInteraction = APIBaseInteraction< + InteractionType.MessageComponent, + APIMessageSelectMenuInteractionData +> & + Required< + Pick< + APIBaseInteraction, + 'channel_id' | 'data' | 'app_permissions' | 'message' + > + >; + +export type APIMessageComponentInteractionData = APIMessageButtonInteractionData | APIMessageSelectMenuInteractionData; + +export interface APIMessageComponentBaseInteractionData { + /** + * The `custom_id` of the component + */ + custom_id: string; + /** + * The type of the component + */ + component_type: CType; +} + +export type APIMessageButtonInteractionData = APIMessageComponentBaseInteractionData; + +export interface APIMessageStringSelectInteractionData + extends APIMessageComponentBaseInteractionData { + values: string[]; +} + +export interface APIMessageUserSelectInteractionData + extends APIMessageComponentBaseInteractionData { + values: Snowflake[]; + resolved: APIUserInteractionDataResolved; +} + +export interface APIMessageRoleSelectInteractionData + extends APIMessageComponentBaseInteractionData { + values: Snowflake[]; + resolved: Required>; +} + +export interface APIMessageMentionableSelectInteractionData + extends APIMessageComponentBaseInteractionData { + values: Snowflake[]; + resolved: Pick; +} + +export interface APIMessageChannelSelectInteractionData + extends APIMessageComponentBaseInteractionData { + values: Snowflake[]; + resolved: Required>; +} + +export type APIMessageSelectMenuInteractionData = + | APIMessageStringSelectInteractionData + | APIMessageUserSelectInteractionData + | APIMessageRoleSelectInteractionData + | APIMessageMentionableSelectInteractionData + | APIMessageChannelSelectInteractionData; + +export type APIMessageComponentDMInteraction = APIDMInteractionWrapper; + +export type APIMessageComponentGuildInteraction = APIGuildInteractionWrapper; diff --git a/payloads/v9/_interactions/modalSubmit.ts b/payloads/v9/_interactions/modalSubmit.ts new file mode 100644 index 0000000..ed70073 --- /dev/null +++ b/payloads/v9/_interactions/modalSubmit.ts @@ -0,0 +1,49 @@ +import type { APIActionRowComponent, APIModalActionRowComponent } from '../channel'; +import type { + APIBaseInteraction, + APIDMInteractionWrapper, + APIGuildInteractionWrapper, + ComponentType, + InteractionType, +} from '../index'; + +export interface ModalSubmitComponent { + type: ComponentType; + custom_id: string; + value: string; +} + +export interface ModalSubmitActionRowComponent + extends Omit, 'components'> { + components: ModalSubmitComponent[]; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-modal-submit-data-structure + */ +export interface APIModalSubmission { + /** + * A developer-defined identifier for the component, max 100 characters + */ + custom_id: string; + /** + * A list of child components + */ + components: ModalSubmitActionRowComponent[]; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIModalSubmitInteraction = APIBaseInteraction & + Required, 'data'>>; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIModalSubmitDMInteraction = APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIModalSubmitGuildInteraction = APIGuildInteractionWrapper; diff --git a/payloads/v9/_interactions/ping.ts b/payloads/v9/_interactions/ping.ts new file mode 100644 index 0000000..55784f4 --- /dev/null +++ b/payloads/v9/_interactions/ping.ts @@ -0,0 +1,4 @@ +import type { APIBaseInteraction } from './base'; +import type { InteractionType } from './responses'; + +export type APIPingInteraction = Omit, 'locale'>; diff --git a/payloads/v9/_interactions/responses.ts b/payloads/v9/_interactions/responses.ts new file mode 100644 index 0000000..f78e9c6 --- /dev/null +++ b/payloads/v9/_interactions/responses.ts @@ -0,0 +1,124 @@ +import type { APIApplicationCommandOptionChoice } from './applicationCommands'; +import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v9'; +import type { APIActionRowComponent, APIModalActionRowComponent } from '../channel'; +import type { MessageFlags } from '../index'; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type + */ +export enum InteractionType { + Ping = 1, + ApplicationCommand, + MessageComponent, + ApplicationCommandAutocomplete, + ModalSubmit, +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object + */ +export type APIInteractionResponse = + | APIInteractionResponsePong + | APIInteractionResponseChannelMessageWithSource + | APIInteractionResponseDeferredChannelMessageWithSource + | APIInteractionResponseDeferredMessageUpdate + | APIInteractionResponseUpdateMessage + | APIApplicationCommandAutocompleteResponse + | APIModalInteractionResponse; + +export interface APIInteractionResponsePong { + type: InteractionResponseType.Pong; +} + +export interface APIApplicationCommandAutocompleteResponse { + type: InteractionResponseType.ApplicationCommandAutocompleteResult; + data: APICommandAutocompleteInteractionResponseCallbackData; +} + +export interface APIModalInteractionResponse { + type: InteractionResponseType.Modal; + data: APIModalInteractionResponseCallbackData; +} + +export interface APIInteractionResponseChannelMessageWithSource { + type: InteractionResponseType.ChannelMessageWithSource; + data: APIInteractionResponseCallbackData; +} + +export interface APIInteractionResponseDeferredChannelMessageWithSource { + type: InteractionResponseType.DeferredChannelMessageWithSource; + data?: Pick; +} + +export interface APIInteractionResponseDeferredMessageUpdate { + type: InteractionResponseType.DeferredMessageUpdate; +} + +export interface APIInteractionResponseUpdateMessage { + type: InteractionResponseType.UpdateMessage; + data?: APIInteractionResponseCallbackData; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type + */ +export enum InteractionResponseType { + /** + * ACK a `Ping` + */ + Pong = 1, + /** + * Respond to an interaction with a message + */ + ChannelMessageWithSource = 4, + /** + * ACK an interaction and edit to a response later, the user sees a loading state + */ + DeferredChannelMessageWithSource, + /** + * ACK a button interaction and update it to a loading state + */ + DeferredMessageUpdate, + /** + * ACK a button interaction and edit the message to which the button was attached + */ + UpdateMessage, + /** + * For autocomplete interactions + */ + ApplicationCommandAutocompleteResult, + /** + * Respond to an interaction with an modal for a user to fill-out + */ + Modal, +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-data-structure + */ +export type APIInteractionResponseCallbackData = Omit< + RESTPostAPIWebhookWithTokenJSONBody, + 'username' | 'avatar_url' +> & { flags?: MessageFlags }; + +export interface APICommandAutocompleteInteractionResponseCallbackData { + choices?: APIApplicationCommandOptionChoice[]; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-modal + */ +export interface APIModalInteractionResponseCallbackData { + /** + * A developer-defined identifier for the component, max 100 characters + */ + custom_id: string; + /** + * The title of the popup modal + */ + title: string; + /** + * Between 1 and 5 (inclusive) components that make up the modal + */ + components: APIActionRowComponent[]; +} diff --git a/payloads/v9/application.ts b/payloads/v9/application.ts new file mode 100644 index 0000000..c37ff5e --- /dev/null +++ b/payloads/v9/application.ts @@ -0,0 +1,252 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/application + */ + +import type { OAuth2Scopes } from './oauth2'; +import type { APITeam } from './teams'; +import type { APIUser } from './user'; +import type { Permissions, Snowflake } from '../../globals'; +import type { LocalizationMap } from '../common'; + +/** + * https://discord.com/developers/docs/resources/application#application-object + */ +export interface APIApplication { + /** + * The id of the app + */ + id: Snowflake; + /** + * The name of the app + */ + name: string; + /** + * The icon hash of the app + */ + icon: string | null; + /** + * The description of the app + */ + description: string; + /** + * An array of rpc origin urls, if rpc is enabled + */ + rpc_origins?: string[]; + /** + * When `false` only app owner can join the app's bot to guilds + */ + bot_public: boolean; + /** + * When `true` the app's bot will only join upon completion of the full oauth2 code grant flow + */ + bot_require_code_grant: boolean; + /** + * The url of the application's terms of service + */ + terms_of_service_url?: string; + /** + * The url of the application's privacy policy + */ + privacy_policy_url?: string; + /** + * Partial user object containing info on the owner of the application + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + owner?: APIUser; + /** + * An empty string + * + * @deprecated This field will be removed in v11 + */ + summary: string; + /** + * The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function + * + * See https://discord.com/developers/docs/game-sdk/applications#getticket + */ + verify_key: string; + /** + * The team this application belongs to + * + * See https://discord.com/developers/docs/topics/teams#data-models-team-object + */ + team: APITeam | null; + /** + * If this application is a game sold on Discord, this field will be the guild to which it has been linked + */ + guild_id?: Snowflake; + /** + * If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists + */ + primary_sku_id?: Snowflake; + /** + * If this application is a game sold on Discord, this field will be the URL slug that links to the store page + */ + slug?: string; + /** + * If this application is a game sold on Discord, this field will be the hash of the image on store embeds + */ + cover_image?: string; + /** + * The application's public flags + * + * See https://discord.com/developers/docs/resources/application#application-object-application-flags + */ + flags: ApplicationFlags; + /** + * Up to 5 tags describing the content and functionality of the application + */ + tags?: [string, string?, string?, string?, string?]; + /** + * Settings for the application's default in-app authorization link, if enabled + */ + install_params?: APIApplicationInstallParams; + /** + * The application's default custom authorization link, if enabled + */ + custom_install_url?: string; + /** + * The application's role connection verification entry point, + * which when configured will render the app as a verification method in the guild role verification configuration + */ + role_connections_verification_url?: string; +} + +export interface APIApplicationInstallParams { + scopes: OAuth2Scopes[]; + permissions: Permissions; +} + +/** + * https://discord.com/developers/docs/resources/application#application-object-application-flags + */ +export enum ApplicationFlags { + /** + * @unstable + */ + EmbeddedReleased = 1 << 1, + /** + * @unstable + */ + ManagedEmoji = 1 << 2, + /** + * @unstable + */ + GroupDMCreate = 1 << 4, + /** + * @unstable + */ + RPCHasConnected = 1 << 11, + /** + * Intent required for bots in 100 or more servers to receive `presence_update` events + */ + GatewayPresence = 1 << 12, + /** + * Intent required for bots in under 100 servers to receive `presence_update` events, found in Bot Settings + */ + GatewayPresenceLimited = 1 << 13, + /** + * Intent required for bots in 100 or more servers to receive member-related events like `guild_member_add`. + * See list of member-related events [under `GUILD_MEMBERS`](https://discord.com/developers/docs/topics/gateway#list-of-intents) + */ + GatewayGuildMembers = 1 << 14, + /** + * Intent required for bots in under 100 servers to receive member-related events like `guild_member_add`, found in Bot Settings. + * See list of member-related events [under `GUILD_MEMBERS`](https://discord.com/developers/docs/topics/gateway#list-of-intents) + */ + GatewayGuildMembersLimited = 1 << 15, + /** + * Indicates unusual growth of an app that prevents verification + */ + VerificationPendingGuildLimit = 1 << 16, + /** + * Indicates if an app is embedded within the Discord client (currently unavailable publicly) + */ + Embedded = 1 << 17, + /** + * Intent required for bots in 100 or more servers to receive [message content](https://support-dev.discord.com/hc/en-us/articles/4404772028055) + */ + GatewayMessageContent = 1 << 18, + /** + * Intent required for bots in under 100 servers to receive [message content](https://support-dev.discord.com/hc/en-us/articles/4404772028055), + * found in Bot Settings + */ + GatewayMessageContentLimited = 1 << 19, + /** + * @unstable + */ + EmbeddedFirstParty = 1 << 20, + /** + * Indicates if an app has registered global [application commands](https://discord.com/developers/docs/interactions/application-commands) + */ + ApplicationCommandBadge = 1 << 23, +} + +/** + * https://discord.com/developers/docs/resources/application-role-connection-metadata#application-role-connection-metadata-object-application-role-connection-metadata-structure + */ +export interface APIApplicationRoleConnectionMetadata { + /** + * Type of metadata value + */ + type: ApplicationRoleConnectionMetadataType; + /** + * Dictionary key for the metadata field (must be `a-z`, `0-9`, or `_` characters; 1-50 characters) + */ + key: string; + /** + * Name of the metadata field (1-100 characters) + */ + name: string; + /** + * Translations of the name + */ + name_localizations?: LocalizationMap; + /** + * Description of the metadata field (1-200 characters) + */ + description: string; + /** + * Translations of the description + */ + description_localizations?: LocalizationMap; +} + +/** + * https://discord.com/developers/docs/resources/application-role-connection-metadata#application-role-connection-metadata-object-application-role-connection-metadata-type + */ +export enum ApplicationRoleConnectionMetadataType { + /** + * The metadata value (`integer`) is less than or equal to the guild's configured value (`integer`) + */ + IntegerLessThanOrEqual = 1, + /** + * The metadata value (`integer`) is greater than or equal to the guild's configured value (`integer`) + */ + IntegerGreaterThanOrEqual, + /** + * The metadata value (`integer`) is equal to the guild's configured value (`integer`) + */ + IntegerEqual, + /** + * The metadata value (`integer`) is not equal to the guild's configured value (`integer`) + */ + IntegerNotEqual, + /** + * The metadata value (`ISO8601 string`) is less than or equal to the guild's configured value (`integer`; days before current date) + */ + DatetimeLessThanOrEqual, + /** + * The metadata value (`ISO8601 string`) is greater than or equal to the guild's configured value (`integer`; days before current date) + */ + DatetimeGreaterThanOrEqual, + /** + * The metadata value (`integer`) is equal to the guild's configured value (`integer`; `1`) + */ + BooleanEqual, + /** + * The metadata value (`integer`) is not equal to the guild's configured value (`integer`; `1`) + */ + BooleanNotEqual, +} diff --git a/payloads/v9/auditLog.ts b/payloads/v9/auditLog.ts new file mode 100644 index 0000000..32e963e --- /dev/null +++ b/payloads/v9/auditLog.ts @@ -0,0 +1,811 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/audit-log + */ + +import type { + APIAutoModerationAction, + APIAutoModerationRule, + APIAutoModerationRuleTriggerMetadata, + AutoModerationRuleEventType, + AutoModerationRuleTriggerType, +} from './autoModeration'; +import type { APIChannel, APIOverwrite } from './channel'; +import type { + APIGuildIntegration, + GuildDefaultMessageNotifications, + GuildExplicitContentFilter, + GuildMFALevel, + GuildVerificationLevel, + IntegrationExpireBehavior, +} from './guild'; +import type { + APIGuildScheduledEvent, + GuildScheduledEventEntityType, + GuildScheduledEventStatus, +} from './guildScheduledEvent'; +import type { APIApplicationCommand } from './interactions'; +import type { APIRole } from './permissions'; +import type { StageInstancePrivacyLevel } from './stageInstance'; +import type { StickerFormatType } from './sticker'; +import type { APIUser } from './user'; +import type { APIWebhook } from './webhook'; +import type { Snowflake } from '../../globals'; + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure + */ +export interface APIAuditLog { + /** + * List of application commands found in the audit log + * + * See https://discord.com/developers/docs/interactions/application-commands#application-command-object + */ + application_commands: APIApplicationCommand[]; + /** + * Webhooks found in the audit log + * + * See https://discord.com/developers/docs/resources/webhook#webhook-object + */ + webhooks: APIWebhook[]; + /** + * Users found in the audit log + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + users: APIUser[]; + /** + * Audit log entries + * + * See https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object + */ + audit_log_entries: APIAuditLogEntry[]; + /** + * List of auto moderation rules referenced in the audit log + * + * See https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object + */ + auto_moderation_rules: APIAutoModerationRule[]; + /** + * Partial integration objects + * + * See https://discord.com/developers/docs/resources/guild#integration-object + */ + integrations: APIGuildIntegration[]; + /** + * Threads found in the audit log + * + * Threads referenced in THREAD_CREATE and THREAD_UPDATE events are included in the threads map, since archived threads might not be kept in memory by clients. + * + * See https://discord.com/developers/docs/resources/channel#channel-object + */ + threads: APIChannel[]; + /** + * The guild scheduled events in the audit log + * + * See https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object + */ + guild_scheduled_events: APIGuildScheduledEvent[]; +} + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-entry-structure + */ +export interface APIAuditLogEntry { + /** + * ID of the affected entity (webhook, user, role, etc.) + */ + target_id: string | null; + /** + * Changes made to the `target_id` + * + * See https://discord.com/developers/docs/resources/audit-log#audit-log-change-object + */ + changes?: APIAuditLogChange[]; + /** + * The user who made the changes + * + * This can be `null` in some cases (webhooks deleting themselves by using their own token, for example) + */ + user_id: Snowflake | null; + /** + * ID of the entry + */ + id: Snowflake; + /** + * Type of action that occurred + * + * See https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events + */ + action_type: AuditLogEvent; + /** + * Additional info for certain action types + * + * See https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info + */ + options?: APIAuditLogOptions; + /** + * The reason for the change (0-512 characters) + */ + reason?: string; +} + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events + */ +export enum AuditLogEvent { + GuildUpdate = 1, + + ChannelCreate = 10, + ChannelUpdate, + ChannelDelete, + ChannelOverwriteCreate, + ChannelOverwriteUpdate, + ChannelOverwriteDelete, + + MemberKick = 20, + MemberPrune, + MemberBanAdd, + MemberBanRemove, + MemberUpdate, + MemberRoleUpdate, + MemberMove, + MemberDisconnect, + BotAdd, + + RoleCreate = 30, + RoleUpdate, + RoleDelete, + + InviteCreate = 40, + InviteUpdate, + InviteDelete, + + WebhookCreate = 50, + WebhookUpdate, + WebhookDelete, + + EmojiCreate = 60, + EmojiUpdate, + EmojiDelete, + + MessageDelete = 72, + MessageBulkDelete, + MessagePin, + MessageUnpin, + + IntegrationCreate = 80, + IntegrationUpdate, + IntegrationDelete, + StageInstanceCreate, + StageInstanceUpdate, + StageInstanceDelete, + + StickerCreate = 90, + StickerUpdate, + StickerDelete, + + GuildScheduledEventCreate = 100, + GuildScheduledEventUpdate, + GuildScheduledEventDelete, + + ThreadCreate = 110, + ThreadUpdate, + ThreadDelete, + + ApplicationCommandPermissionUpdate = 121, + + AutoModerationRuleCreate = 140, + AutoModerationRuleUpdate, + AutoModerationRuleDelete, + AutoModerationBlockMessage, + AutoModerationFlagToChannel, + AutoModerationUserCommunicationDisabled, +} + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info + */ +export interface APIAuditLogOptions { + /** + * Name of the Auto Moderation rule that was triggered + * + * Present from: + * - AUTO_MODERATION_BLOCK_MESSAGE + * - AUTO_MODERATION_FLAG_TO_CHANNEL + * - AUTO_MODERATION_USER_COMMUNICATION_DISABLED + */ + auto_moderation_rule_name?: string; + /** + * Trigger type of the Auto Moderation rule that was triggered + * + * Present from: + * - AUTO_MODERATION_BLOCK_MESSAGE + * - AUTO_MODERATION_FLAG_TO_CHANNEL + * - AUTO_MODERATION_USER_COMMUNICATION_DISABLED + */ + auto_moderation_rule_trigger_type?: AuditLogRuleTriggerType; + /** + * Number of days after which inactive members were kicked + * + * Present from: + * - MEMBER_PRUNE + */ + delete_member_days?: string; + /** + * Number of members removed by the prune + * + * Present from: + * - MEMBER_PRUNE + */ + members_removed?: string; + + /** + * Channel in which the entities were targeted + * + * Present from: + * - MEMBER_MOVE + * - MESSAGE_PIN + * - MESSAGE_UNPIN + * - MESSAGE_DELETE + * - STAGE_INSTANCE_CREATE + * - STAGE_INSTANCE_UPDATE + * - STAGE_INSTANCE_DELETE + * - AUTO_MODERATION_BLOCK_MESSAGE + * - AUTO_MODERATION_FLAG_TO_CHANNEL + * - AUTO_MODERATION_USER_COMMUNICATION_DISABLED + */ + channel_id?: Snowflake; + + /** + * ID of the message that was targeted + * + * Present from: + * - MESSAGE_PIN + * - MESSAGE_UNPIN + */ + message_id?: Snowflake; + + /** + * Number of entities that were targeted + * + * Present from: + * - MESSAGE_DELETE + * - MESSAGE_BULK_DELETE + * - MEMBER_DISCONNECT + * - MEMBER_MOVE + */ + count?: string; + + /** + * ID of the overwritten entity + * + * Present from: + * - CHANNEL_OVERWRITE_CREATE + * - CHANNEL_OVERWRITE_UPDATE + * - CHANNEL_OVERWRITE_DELETE + */ + id?: Snowflake; + + /** + * Type of overwritten entity - "0" for "role" or "1" for "member" + * + * Present from: + * - CHANNEL_OVERWRITE_CREATE + * - CHANNEL_OVERWRITE_UPDATE + * - CHANNEL_OVERWRITE_DELETE + * + * {@link AuditLogOptionsType} + */ + type?: AuditLogOptionsType; + + /** + * Name of the role + * + * Present from: + * - CHANNEL_OVERWRITE_CREATE + * - CHANNEL_OVERWRITE_UPDATE + * - CHANNEL_OVERWRITE_DELETE + * + * **Present only if the {@link APIAuditLogOptions#type entry type} is "0"** + */ + role_name?: string; +} + +export enum AuditLogOptionsType { + Role = '0', + Member = '1', +} + +export type AuditLogRuleTriggerType = `${AutoModerationRuleTriggerType}`; + +/** + * https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure + */ +export type APIAuditLogChange = + | APIAuditLogChangeKeyName + | APIAuditLogChangeKeyDescription + | APIAuditLogChangeKeyIconHash + | APIAuditLogChangeKeyImageHash + | APIAuditLogChangeKeySplashHash + | APIAuditLogChangeKeyDiscoverySplashHash + | APIAuditLogChangeKeyBannerHash + | APIAuditLogChangeKeyOwnerId + | APIAuditLogChangeKeyRegion + | APIAuditLogChangeKeyPreferredLocale + | APIAuditLogChangeKeyAFKChannelId + | APIAuditLogChangeKeyAFKTimeout + | APIAuditLogChangeKeyRulesChannelId + | APIAuditLogChangeKeyPublicUpdatesChannelId + | APIAuditLogChangeKeyMFALevel + | APIAuditLogChangeKeyVerificationLevel + | APIAuditLogChangeKeyExplicitContentFilter + | APIAuditLogChangeKeyDefaultMessageNotifications + | APIAuditLogChangeKeyVanityURLCode + | APIAuditLogChangeKey$Add + | APIAuditLogChangeKey$Remove + | APIAuditLogChangeKeyPruneDeleteDays + | APIAuditLogChangeKeyWidgetEnabled + | APIAuditLogChangeKeyWidgetChannelId + | APIAuditLogChangeKeySystemChannelId + | APIAuditLogChangeKeyPosition + | APIAuditLogChangeKeyTopic + | APIAuditLogChangeKeyBitrate + | APIAuditLogChangeKeyPermissionOverwrites + | APIAuditLogChangeKeyNSFW + | APIAuditLogChangeKeyApplicationId + | APIAuditLogChangeKeyRateLimitPerUser + | APIAuditLogChangeKeyPermissions + | APIAuditLogChangeKeyColor + | APIAuditLogChangeKeyHoist + | APIAuditLogChangeKeyMentionable + | APIAuditLogChangeKeyAllow + | APIAuditLogChangeKeyDeny + | APIAuditLogChangeKeyCode + | APIAuditLogChangeKeyChannelId + | APIAuditLogChangeKeyInviterId + | APIAuditLogChangeKeyMaxUses + | APIAuditLogChangeKeyUses + | APIAuditLogChangeKeyMaxAge + | APIAuditLogChangeKeyTemporary + | APIAuditLogChangeKeyDeaf + | APIAuditLogChangeKeyMute + | APIAuditLogChangeKeyNick + | APIAuditLogChangeKeyAvatarHash + | APIAuditLogChangeKeyId + | APIAuditLogChangeKeyType + | APIAuditLogChangeKeyEnableEmoticons + | APIAuditLogChangeKeyExpireBehavior + | APIAuditLogChangeKeyExpireGracePeriod + | APIAuditLogChangeKeyUserLimit + | APIAuditLogChangeKeyPrivacyLevel + | APIAuditLogChangeKeyTags + | APIAuditLogChangeKeyFormatType + | APIAuditLogChangeKeyAsset + | APIAuditLogChangeKeyAvailable + | APIAuditLogChangeKeyGuildId + | APIAuditLogChangeKeyArchived + | APIAuditLogChangeKeyLocked + | APIAuditLogChangeKeyAutoArchiveDuration + | APIAuditLogChangeKeyDefaultAutoArchiveDuration + | APIAuditLogChangeKeyEntityType + | APIAuditLogChangeKeyStatus + | APIAuditLogChangeKeyLocation + | APIAuditLogChangeKeyCommunicationDisabledUntil + | APIAuditLogChangeKeyTriggerType + | APIAuditLogChangeKeyEventType + | APIAuditLogChangeKeyTriggerMetadata + | APIAuditLogChangeKeyActions + | APIAuditLogChangeKeyEnabled + | APIAuditLogChangeKeyExemptRoles + | APIAuditLogChangeKeyExemptChannels; + +/** + * Returned when an entity's name is changed + */ +export type APIAuditLogChangeKeyName = AuditLogChangeData<'name', string>; + +/** + * Returned when a guild's or sticker's or guild scheduled event's description is changed + */ +export type APIAuditLogChangeKeyDescription = AuditLogChangeData<'description', string>; + +/** + * Returned when a guild's icon is changed + */ +export type APIAuditLogChangeKeyIconHash = AuditLogChangeData<'icon_hash', string>; + +/** + * Returned when a guild's scheduled event's cover image is changed + */ +export type APIAuditLogChangeKeyImageHash = AuditLogChangeData<'image_hash', string>; + +/** + * Returned when a guild's splash is changed + */ +export type APIAuditLogChangeKeySplashHash = AuditLogChangeData<'splash_hash', string>; + +/** + * Returned when a guild's discovery splash is changed + */ +export type APIAuditLogChangeKeyDiscoverySplashHash = AuditLogChangeData<'discovery_splash_hash', string>; + +/** + * Returned when a guild's banner hash is changed + */ +export type APIAuditLogChangeKeyBannerHash = AuditLogChangeData<'banner_hash', string>; + +/** + * Returned when a guild's owner_id is changed + */ +export type APIAuditLogChangeKeyOwnerId = AuditLogChangeData<'owner_id', Snowflake>; + +/** + * Returned when a guild's region is changed + */ +export type APIAuditLogChangeKeyRegion = AuditLogChangeData<'region', string>; + +/** + * Returned when a guild's preferred_locale is changed + */ +export type APIAuditLogChangeKeyPreferredLocale = AuditLogChangeData<'preferred_locale', string>; + +/** + * Returned when a guild's afk_channel_id is changed + */ +export type APIAuditLogChangeKeyAFKChannelId = AuditLogChangeData<'afk_channel_id', Snowflake>; + +/** + * Returned when a guild's afk_timeout is changed + */ +export type APIAuditLogChangeKeyAFKTimeout = AuditLogChangeData<'afk_timeout', number>; + +/** + * Returned when a guild's rules_channel_id is changed + */ +export type APIAuditLogChangeKeyRulesChannelId = AuditLogChangeData<'rules_channel_id', string>; + +/** + * Returned when a guild's public_updates_channel_id is changed + */ +export type APIAuditLogChangeKeyPublicUpdatesChannelId = AuditLogChangeData<'public_updates_channel_id', string>; + +/** + * Returned when a guild's mfa_level is changed + */ +export type APIAuditLogChangeKeyMFALevel = AuditLogChangeData<'mfa_level', GuildMFALevel>; + +/** + * Returned when a guild's verification_level is changed + */ +export type APIAuditLogChangeKeyVerificationLevel = AuditLogChangeData<'verification_level', GuildVerificationLevel>; + +/** + * Returned when a guild's explicit_content_filter is changed + */ +export type APIAuditLogChangeKeyExplicitContentFilter = AuditLogChangeData< + 'explicit_content_filter', + GuildExplicitContentFilter +>; + +/** + * Returned when a guild's default_message_notifications is changed + */ +export type APIAuditLogChangeKeyDefaultMessageNotifications = AuditLogChangeData< + 'default_message_notifications', + GuildDefaultMessageNotifications +>; + +/** + * Returned when a guild's vanity_url_code is changed + */ +export type APIAuditLogChangeKeyVanityURLCode = AuditLogChangeData<'vanity_url_code', string>; + +/** + * Returned when new role(s) are added + */ +export type APIAuditLogChangeKey$Add = AuditLogChangeData<'$add', APIRole[]>; + +/** + * Returned when role(s) are removed + */ +export type APIAuditLogChangeKey$Remove = AuditLogChangeData<'$remove', APIRole[]>; + +/** + * Returned when there is a change in number of days after which inactive and role-unassigned members are kicked + */ +export type APIAuditLogChangeKeyPruneDeleteDays = AuditLogChangeData<'prune_delete_days', number>; + +/** + * Returned when a guild's widget is enabled + */ +export type APIAuditLogChangeKeyWidgetEnabled = AuditLogChangeData<'widget_enabled', boolean>; + +/** + * Returned when a guild's widget_channel_id is changed + */ +export type APIAuditLogChangeKeyWidgetChannelId = AuditLogChangeData<'widget_channel_id', Snowflake>; + +/** + * Returned when a guild's system_channel_id is changed + */ +export type APIAuditLogChangeKeySystemChannelId = AuditLogChangeData<'system_channel_id', Snowflake>; + +/** + * Returned when a channel's position is changed + */ +export type APIAuditLogChangeKeyPosition = AuditLogChangeData<'position', number>; + +/** + * Returned when a channel's topic is changed + */ +export type APIAuditLogChangeKeyTopic = AuditLogChangeData<'topic', string>; + +/** + * Returned when a voice channel's bitrate is changed + */ +export type APIAuditLogChangeKeyBitrate = AuditLogChangeData<'bitrate', number>; + +/** + * Returned when a channel's permission overwrites is changed + */ +export type APIAuditLogChangeKeyPermissionOverwrites = AuditLogChangeData<'permission_overwrites', APIOverwrite[]>; + +/** + * Returned when a channel's NSFW restriction is changed + */ +export type APIAuditLogChangeKeyNSFW = AuditLogChangeData<'nsfw', boolean>; + +/** + * The application ID of the added or removed Webhook or Bot + */ +export type APIAuditLogChangeKeyApplicationId = AuditLogChangeData<'application_id', Snowflake>; + +/** + * Returned when a channel's amount of seconds a user has to wait before sending another message + * is changed + */ +export type APIAuditLogChangeKeyRateLimitPerUser = AuditLogChangeData<'rate_limit_per_user', number>; + +/** + * Returned when a permission bitfield is changed + */ +export type APIAuditLogChangeKeyPermissions = AuditLogChangeData<'permissions', string>; + +/** + * Returned when a role's color is changed + */ +export type APIAuditLogChangeKeyColor = AuditLogChangeData<'color', number>; + +/** + * Represents a change where the key is a snowflake. + * Currently, the only known instance of this is returned when permissions for a command were updated () + */ +export type APIAuditLogChangeKeySnowflake = AuditLogChangeData; + +/** + * Returned when a role's hoist status is changed + */ +export type APIAuditLogChangeKeyHoist = AuditLogChangeData<'hoist', boolean>; + +/** + * Returned when a role's mentionable status is changed + */ +export type APIAuditLogChangeKeyMentionable = AuditLogChangeData<'mentionable', boolean>; + +/** + * Returned when an overwrite's allowed permissions bitfield is changed + */ +export type APIAuditLogChangeKeyAllow = AuditLogChangeData<'allow', string>; + +/** + * Returned when an overwrite's denied permissions bitfield is changed + */ +export type APIAuditLogChangeKeyDeny = AuditLogChangeData<'deny', string>; + +/** + * Returned when an invite's code is changed + */ +export type APIAuditLogChangeKeyCode = AuditLogChangeData<'code', string>; + +/** + * Returned when an invite's or guild scheduled event's channel_id is changed + */ +export type APIAuditLogChangeKeyChannelId = AuditLogChangeData<'channel_id', Snowflake>; + +/** + * Returned when an invite's inviter_id is changed + */ +export type APIAuditLogChangeKeyInviterId = AuditLogChangeData<'inviter_id', Snowflake>; + +/** + * Returned when an invite's max_uses is changed + */ +export type APIAuditLogChangeKeyMaxUses = AuditLogChangeData<'max_uses', number>; + +/** + * Returned when an invite's uses is changed + */ +export type APIAuditLogChangeKeyUses = AuditLogChangeData<'uses', number>; + +/** + * Returned when an invite's max_age is changed + */ +export type APIAuditLogChangeKeyMaxAge = AuditLogChangeData<'max_age', number>; + +/** + * Returned when an invite's temporary status is changed + */ +export type APIAuditLogChangeKeyTemporary = AuditLogChangeData<'temporary', boolean>; + +/** + * Returned when a user's deaf status is changed + */ +export type APIAuditLogChangeKeyDeaf = AuditLogChangeData<'deaf', boolean>; + +/** + * Returned when a user's mute status is changed + */ +export type APIAuditLogChangeKeyMute = AuditLogChangeData<'mute', boolean>; + +/** + * Returned when a user's nick is changed + */ +export type APIAuditLogChangeKeyNick = AuditLogChangeData<'nick', string>; + +/** + * Returned when a user's avatar_hash is changed + */ +export type APIAuditLogChangeKeyAvatarHash = AuditLogChangeData<'avatar_hash', string>; + +/** + * The ID of the changed entity - sometimes used in conjunction with other keys + */ +export type APIAuditLogChangeKeyId = AuditLogChangeData<'id', Snowflake>; + +/** + * The type of entity created + */ +export type APIAuditLogChangeKeyType = AuditLogChangeData<'type', number | string>; + +/** + * Returned when an integration's enable_emoticons is changed + */ +export type APIAuditLogChangeKeyEnableEmoticons = AuditLogChangeData<'enable_emoticons', boolean>; + +/** + * Returned when an integration's expire_behavior is changed + */ +export type APIAuditLogChangeKeyExpireBehavior = AuditLogChangeData<'expire_behavior', IntegrationExpireBehavior>; + +/** + * Returned when an integration's expire_grace_period is changed + */ +export type APIAuditLogChangeKeyExpireGracePeriod = AuditLogChangeData<'expire_grace_period', number>; + +/** + * Returned when a voice channel's user_limit is changed + */ +export type APIAuditLogChangeKeyUserLimit = AuditLogChangeData<'user_limit', number>; + +/** + * Returned when privacy level of a stage instance or guild scheduled event is changed + */ +export type APIAuditLogChangeKeyPrivacyLevel = AuditLogChangeData<'privacy_level', StageInstancePrivacyLevel>; + +/** + * Returned when a sticker's related emoji is changed + */ +export type APIAuditLogChangeKeyTags = AuditLogChangeData<'tags', string>; + +/** + * Returned when a sticker's format_type is changed + */ +export type APIAuditLogChangeKeyFormatType = AuditLogChangeData<'format_type', StickerFormatType>; + +/** + * Empty string + */ +export type APIAuditLogChangeKeyAsset = AuditLogChangeData<'asset', ''>; + +/** + * Returned when a sticker's availability is changed + */ +export type APIAuditLogChangeKeyAvailable = AuditLogChangeData<'available', boolean>; + +/** + * Returned when a sticker's guild_id is changed + */ +export type APIAuditLogChangeKeyGuildId = AuditLogChangeData<'guild_id', Snowflake>; + +/* + * Returned when a thread's archive status is changed + */ +export type APIAuditLogChangeKeyArchived = AuditLogChangeData<'archived', boolean>; + +/* + * Returned when a thread's lock status is changed + */ +export type APIAuditLogChangeKeyLocked = AuditLogChangeData<'locked', boolean>; + +/* + * Returned when a thread's auto archive duration is changed + */ +export type APIAuditLogChangeKeyAutoArchiveDuration = AuditLogChangeData<'auto_archive_duration', number>; + +/* + * Returned when a channel's default auto archive duration for newly created threads is changed + */ +export type APIAuditLogChangeKeyDefaultAutoArchiveDuration = AuditLogChangeData< + 'default_auto_archive_duration', + number +>; + +/** + * Returned when entity type of a guild scheduled event is changed + */ +export type APIAuditLogChangeKeyEntityType = AuditLogChangeData<'entity_type', GuildScheduledEventEntityType>; + +/** + * Returned when status of a guild scheduled event is changed + */ +export type APIAuditLogChangeKeyStatus = AuditLogChangeData<'status', GuildScheduledEventStatus>; + +/** + * Returned when location of a guild scheduled event is changed + */ +export type APIAuditLogChangeKeyLocation = AuditLogChangeData<'location', string>; + +/** + * Returned when a user's timeout is changed + */ +export type APIAuditLogChangeKeyCommunicationDisabledUntil = AuditLogChangeData<'communication_disabled_until', string>; + +/** + * Returned when an auto moderation rule's trigger type is changed (only in rule creation or deletion) + */ +export type APIAuditLogChangeKeyTriggerType = AuditLogChangeData<'trigger_type', AutoModerationRuleTriggerType>; + +/** + * Returned when an auto moderation rule's event type is changed + */ +export type APIAuditLogChangeKeyEventType = AuditLogChangeData<'event_type', AutoModerationRuleEventType>; + +/** + * Returned when an auto moderation rule's trigger metadata is changed + */ +export type APIAuditLogChangeKeyTriggerMetadata = AuditLogChangeData< + 'trigger_metadata', + APIAutoModerationRuleTriggerMetadata +>; + +/** + * Returned when an auto moderation rule's actions is changed + */ +export type APIAuditLogChangeKeyActions = AuditLogChangeData<'actions', APIAutoModerationAction[]>; + +/** + * Returned when an auto moderation rule's enabled status is changed + */ +export type APIAuditLogChangeKeyEnabled = AuditLogChangeData<'enabled', boolean>; + +/** + * Returned when an auto moderation rule's exempt roles is changed + */ +export type APIAuditLogChangeKeyExemptRoles = AuditLogChangeData<'exempt_roles', Snowflake[]>; + +/** + * Returned when an auto moderation rule's exempt channels is changed + */ +export type APIAuditLogChangeKeyExemptChannels = AuditLogChangeData<'exempt_channels', Snowflake[]>; + +interface AuditLogChangeData { + key: K; + /** + * The new value + * + * If `new_value` is not present in the change object, while `old_value` is, + * that means the property that was changed has been reset, or set to `null` + */ + new_value?: D; + old_value?: D; +} diff --git a/payloads/v9/autoModeration.ts b/payloads/v9/autoModeration.ts new file mode 100644 index 0000000..1c2bea3 --- /dev/null +++ b/payloads/v9/autoModeration.ts @@ -0,0 +1,203 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/auto-moderation + */ + +import type { Snowflake } from '../../globals'; + +/** + * https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-auto-moderation-rule-structure + */ +export interface APIAutoModerationRule { + /** + * The id of this rule + */ + id: Snowflake; + /** + * The guild which this rule belongs to + */ + guild_id: Snowflake; + /** + * The rule name + */ + name: string; + /** + * The user id who created this rule + */ + creator_id: Snowflake; + /** + * The rule event type + */ + event_type: AutoModerationRuleEventType; + /** + * The rule trigger type + */ + trigger_type: AutoModerationRuleTriggerType; + /** + * The rule trigger metadata + */ + trigger_metadata: APIAutoModerationRuleTriggerMetadata; + /** + * The actions which will execute when this rule is triggered + */ + actions: APIAutoModerationAction[]; + /** + * Whether this rule is enabled + */ + enabled: boolean; + /** + * The role ids that shouldn't be affected by this rule (Maximum of 20) + */ + exempt_roles: Snowflake[]; + /** + * The channel ids that shouldn't be affected by this rule (Maximum of 50) + */ + exempt_channels: Snowflake[]; +} + +/** + * https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types + */ +export enum AutoModerationRuleTriggerType { + /** + * Check if content contains words from a user defined list of keywords (Maximum of 3 per guild) + */ + Keyword = 1, + /** + * Check if content represents generic spam (Maximum of 1 per guild) + */ + Spam = 3, + /** + * Check if content contains words from internal pre-defined wordsets (Maximum of 1 per guild) + */ + KeywordPreset, + /** + * Check if content contains more mentions than allowed (Maximum of 1 per guild) + */ + MentionSpam, +} + +/** + * https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata + */ +export interface APIAutoModerationRuleTriggerMetadata { + /** + * Substrings which will be searched for in content (Maximum of 1000) + * + * A keyword can be a phrase which contains multiple words. Wildcard symbols can be used to customize how each string will be matched. Each keyword must be 30 characters or less + * See [keyword matching strategies](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies) + * + * Associated trigger type: {@link AutoModerationRuleTriggerType.Keyword} + */ + keyword_filter?: string[]; + /** + * The internally pre-defined wordsets which will be searched for in content + * + * Associated trigger type: {@link AutoModerationRuleTriggerType.KeywordPreset} + */ + presets?: AutoModerationRuleKeywordPresetType[]; + /** + * Substrings which will be exempt from triggering the preset trigger type (Maximum of 1000) + * + * A allowed-word can be a phrase which contains multiple words. Wildcard symbols can be used to customize how each string will be matched. Each keyword must be 30 characters or less + * See [keyword matching strategies](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies) + * + * Associated trigger type: {@link AutoModerationRuleTriggerType.KeywordPreset} + */ + allow_list?: string[]; + /** + * Regular expression patterns which will be matched against content (Maximum of 10) + * + * Only Rust flavored regex is currently supported (Maximum of 75 characters) + * + * Associated trigger type: {@link AutoModerationRuleTriggerType.Keyword} + */ + regex_patterns?: string[]; + /** + * Total number of mentions (role & user) allowed per message (Maximum of 50) + * + * Associated trigger type: {@link AutoModerationRuleTriggerType.MentionSpam} + */ + mention_total_limit?: number; +} + +/** + * https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-preset-types + */ +export enum AutoModerationRuleKeywordPresetType { + /** + * Words that may be considered forms of swearing or cursing + */ + Profanity = 1, + /** + * Words that refer to sexually explicit behavior or activity + */ + SexualContent, + /** + * Personal insults or words that may be considered hate speech + */ + Slurs, +} + +/** + * https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types + */ +export enum AutoModerationRuleEventType { + /** + * When a member sends or edits a message in the guild + */ + MessageSend = 1, +} + +/** + * https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-auto-moderation-action-structure + */ +export interface APIAutoModerationAction { + /** + * The action type + */ + type: AutoModerationActionType; + /** + * Additional metadata needed during execution for this specific action type + * + * Will only be omitted if the action type is {@link AutoModerationActionType.BlockMessage} + */ + metadata?: APIAutoModerationActionMetadata; +} + +/** + * https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-action-types + */ +export enum AutoModerationActionType { + /** + * Blocks the content of a message according to the rule + */ + BlockMessage = 1, + /** + * Logs user content to a specified channel + */ + SendAlertMessage, + /** + * Timeout user for specified duration, this action type can be set if the bot has `MODERATE_MEMBERS` permission + */ + Timeout, +} + +/** + * https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-action-metadata + */ +export interface APIAutoModerationActionMetadata { + /** + * Channel to which user content should be logged + * + * Associated action type: {@link AutoModerationActionType.SendAlertMessage} + */ + channel_id?: Snowflake; + /** + * Timeout duration in seconds (Maximum of 4 weeks - 2419200 seconds) + * + * Only available if using {@link AutoModerationRuleTriggerType.Keyword} + * + * Associated action type: {@link AutoModerationActionType.Timeout} + */ + duration_seconds?: number; +} diff --git a/payloads/v9/channel.ts b/payloads/v9/channel.ts new file mode 100644 index 0000000..a3ec773 --- /dev/null +++ b/payloads/v9/channel.ts @@ -0,0 +1,1724 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/channel + */ + +import type { APIApplication } from './application'; +import type { APIPartialEmoji } from './emoji'; +import type { APIGuildMember } from './guild'; +import type { APIMessageInteraction } from './interactions'; +import type { APIInvite } from './invite'; +import type { APIRole } from './permissions'; +import type { APISticker, APIStickerItem } from './sticker'; +import type { APIUser } from './user'; +import type { GatewayVoiceState } from './voice'; +import type { APIWebhook } from './webhook'; +import type { Permissions, Snowflake } from '../../globals'; + +/** + * Not documented, but partial only includes id, name, and type + */ +export interface APIPartialChannel { + /** + * The id of the channel + */ + id: Snowflake; + /** + * The type of the channel + * + * See https://discord.com/developers/docs/resources/channel#channel-object-channel-types + */ + type: ChannelType; + /** + * The name of the channel (1-100 characters) + */ + name?: string | null; +} + +/** + * This interface is used to allow easy extension for other channel types. While + * also allowing `APIPartialChannel` to be used without breaking. + */ +export interface APIChannelBase extends APIPartialChannel { + type: T; + flags?: ChannelFlags; +} + +export type TextChannelType = + | ChannelType.DM + | ChannelType.GroupDM + | ChannelType.GuildAnnouncement + | ChannelType.PublicThread + | ChannelType.PrivateThread + | ChannelType.AnnouncementThread + | ChannelType.GuildText + | ChannelType.GuildForum + | ChannelType.GuildVoice; + +export type GuildChannelType = Exclude; + +export interface APITextBasedChannel extends APIChannelBase { + /** + * The id of the last message sent in this channel (may not point to an existing or valid message) + */ + last_message_id?: Snowflake | null; + /** + * When the last pinned message was pinned. + * This may be `null` in events such as `GUILD_CREATE` when a message is not pinned + */ + last_pin_timestamp?: string | null; + /** + * Amount of seconds a user has to wait before sending another message (0-21600); + * bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected + * + * `rate_limit_per_user` also applies to thread creation. Users can send one message and create one thread during each `rate_limit_per_user` interval. + * + * For thread channels, `rate_limit_per_user` is only returned if the field is set to a non-zero and non-null value. + * The absence of this field in API calls and Gateway events should indicate that slowmode has been reset to the default value. + */ + rate_limit_per_user?: number; +} + +export interface APIGuildChannel extends Omit, 'name'> { + /** + * The name of the channel (1-100 characters) + */ + name: string; + /** + * The id of the guild (may be missing for some channel objects received over gateway guild dispatches) + */ + guild_id?: Snowflake; + /** + * Explicit permission overwrites for members and roles + * + * See https://discord.com/developers/docs/resources/channel#overwrite-object + */ + permission_overwrites?: APIOverwrite[]; + /** + * Sorting position of the channel + */ + position: number; + /** + * ID of the parent category for a channel (each parent category can contain up to 50 channels) + * + * OR + * + * ID of the parent channel for a thread + */ + parent_id?: Snowflake | null; + /** + * Whether the channel is nsfw + */ + nsfw?: boolean; +} + +export type GuildTextChannelType = Exclude; + +export interface APIGuildTextChannel + extends Omit, 'name'>, + APIGuildChannel { + /** + * Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity + */ + default_auto_archive_duration?: ThreadAutoArchiveDuration; + /** + * The initial `rate_limit_per_user` to set on newly created threads. + * This field is copied to the thread at creation time and does not live update + */ + default_thread_rate_limit_per_user?: number; + /** + * The channel topic (0-1024 characters) + */ + topic?: string | null; +} + +export type APITextChannel = APIGuildTextChannel; +export type APINewsChannel = APIGuildTextChannel; +export type APIGuildCategoryChannel = APIGuildChannel; + +export interface APIVoiceChannelBase extends APIGuildChannel { + /** + * The bitrate (in bits) of the voice channel + */ + bitrate?: number; + /** + * The user limit of the voice channel + */ + user_limit?: number; + /** + * Voice region id for the voice or stage channel, automatic when set to `null` + * + * See https://discord.com/developers/docs/resources/voice#voice-region-object + */ + rtc_region?: string | null; +} + +export interface APIGuildVoiceChannel + extends APIVoiceChannelBase, + Omit, 'name' | 'last_pin_timestamp'> { + /** + * The camera video quality mode of the voice channel, `1` when not present + * + * See https://discord.com/developers/docs/resources/channel#channel-object-video-quality-modes + */ + video_quality_mode?: VideoQualityMode; +} + +export type APIGuildStageVoiceChannel = APIVoiceChannelBase; + +export interface APIDMChannelBase extends Omit, 'rate_limit_per_user'> { + /** + * The recipients of the DM + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + recipients?: APIUser[]; +} + +export interface APIDMChannel extends Omit, 'name'> { + /** + * The name of the channel (always null for DM channels) + */ + name: null; +} + +export interface APIGroupDMChannel extends Omit, 'name'> { + /** + * The name of the channel (1-100 characters) + */ + name: string | null; + /** + * Application id of the group DM creator if it is bot-created + */ + application_id?: Snowflake; + /** + * Icon hash + */ + icon?: string | null; + /** + * ID of the DM creator + */ + owner_id?: Snowflake; + /** + * Whether the channel is managed by an OAuth2 application + */ + managed?: boolean; +} + +export interface APIThreadChannel + extends Omit< + APITextBasedChannel, + 'name' + >, + APIGuildChannel { + /** + * The client users member for the thread, only included in select endpoints + */ + member?: APIThreadMember; + /** + * The metadata for a thread channel not shared by other channels + */ + thread_metadata?: APIThreadMetadata; + /** + * Number of messages (not including the initial message or deleted messages) in a thread + * + * If the thread was created before July 1, 2022, it stops counting at 50 messages + */ + message_count?: number; + /** + * The approximate member count of the thread, does not count above 50 even if there are more members + */ + member_count?: number; + /** + * ID of the thread creator + */ + owner_id?: Snowflake; + /** + * Number of messages ever sent in a thread + * + * Similar to `message_count` on message creation, but won't decrement when a message is deleted + */ + total_message_sent?: number; + /** + * The IDs of the set of tags that have been applied to a thread in a forum channel + */ + applied_tags: Snowflake[]; +} + +/** + * https://discord.com/developers/docs/resources/channel#forum-tag-object-forum-tag-structure + */ +export interface APIGuildForumTag { + /** + * The id of the tag + */ + id: Snowflake; + /** + * The name of the tag (0-20 characters) + */ + name: string; + /** + * Whether this tag can only be added to or removed from threads by a member with the `MANAGE_THREADS` permission + */ + moderated: boolean; + /** + * The id of a guild's custom emoji + */ + emoji_id: Snowflake | null; + /** + * The unicode character of the emoji + */ + emoji_name: string | null; +} + +/** + * https://discord.com/developers/docs/resources/channel#default-reaction-object-default-reaction-structure + */ +export interface APIGuildForumDefaultReactionEmoji { + /** + * The id of a guild's custom emoji + */ + emoji_id: Snowflake | null; + /** + * The unicode character of the emoji + */ + emoji_name: string | null; +} + +/** + * https://discord.com/developers/docs/resources/channel/#channel-object-sort-order-types + */ +export enum SortOrderType { + /** + * Sort forum posts by activity + */ + LatestActivity, + /** + * Sort forum posts by creation time (from most recent to oldest) + */ + CreationDate, +} + +/** + * https://discord.com/developers/docs/resources/channel/#channel-object-forum-layout-types + */ +export enum ForumLayoutType { + /** + * No default has been set for forum channel + */ + NotSet, + /** + * Display posts as a list + */ + ListView, + /** + * Display posts as a collection of tiles + */ + GalleryView, +} + +export interface APIGuildForumChannel extends APIGuildTextChannel { + /** + * The set of tags that can be used in a forum channel + */ + available_tags: APIGuildForumTag[]; + /** + * The emoji to show in the add reaction button on a thread in a forum channel + */ + default_reaction_emoji: APIGuildForumDefaultReactionEmoji | null; + /** + * The default sort order type used to order posts in a forum channel + */ + default_sort_order: SortOrderType | null; + /** + * The default layout type used to display posts in a forum channel. Defaults to `0`, which indicates a layout view has not been set by a channel admin + */ + default_forum_layout: ForumLayoutType; +} + +/** + * https://discord.com/developers/docs/resources/channel#channel-object-channel-structure + */ +export type APIChannelType = + | APIGroupDMChannel + | APIDMChannel + | APITextChannel + | APINewsChannel + | APIGuildVoiceChannel + | APIGuildStageVoiceChannel + | APIGuildCategoryChannel + | APIThreadChannel + | APIGuildForumChannel; + +export interface APIChannel { + id: Snowflake; + created_at: string; + name?: string; + icon?: string | null; + type: ChannelType; + recipients?: APIUser[]; + last_message_id?: Snowflake; + guild_id?: Snowflake; + parent_id: Snowflake; + owner_id?: Snowflake; + last_pin_timestamp?: number; + default_auto_archive_duration?: number; + position?: number; + permission_overwrites?: APIOverwrite[]; + video_quality_mode?: number; + bitrate?: number; + user_limit?: number; + nsfw: boolean; + rate_limit_per_user?: number; + topic?: string; + invites?: APIInvite[]; + retention_policy_id?: string; + messages?: APIMessage[]; + voice_states?: GatewayVoiceState[]; + read_states?: APIReadState[]; + webhooks?: APIWebhook[]; + flags: number; + default_thread_rate_limit_per_user: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#channel-object-channel-types + */ +export enum ChannelType { + /** + * A text channel within a guild + */ + GuildText, + /** + * A direct message between users + */ + DM, + /** + * A voice channel within a guild + */ + GuildVoice, + /** + * A direct message between multiple users + */ + GroupDM, + /** + * An organizational category that contains up to 50 channels + * + * See https://support.discord.com/hc/articles/115001580171 + */ + GuildCategory, + /** + * A channel that users can follow and crosspost into their own guild + * + * See https://support.discord.com/hc/articles/360032008192 + */ + GuildAnnouncement, + /** + * A channel in which game developers can sell their game on Discord + */ + GuildStore, + /** + * E2EE channel + */ + Encrypted, + /** + * E2EE Thread channel + */ + EncryptedThread, + /** + * Event chain style transactional channel + */ + Transactional, + /** + * A temporary sub-channel within a Guild Announcement channel + */ + AnnouncementThread, + /** + * A temporary sub-channel within a Guild Text or Guild Forum channel + */ + PublicThread, + /** + * A temporary sub-channel within a Guild Text channel that is only viewable by those invited and those with the Manage Threads permission + */ + PrivateThread, + /** + * A voice channel for hosting events with an audience + * + * See https://support.discord.com/hc/articles/1500005513722 + */ + GuildStageVoice, + /** + * The channel in a Student Hub containing the listed servers + * + * See https://support.discord.com/hc/articles/4406046651927 + */ + GuildDirectory, + /** + * A channel that can only contain threads + */ + GuildForum, + /** + * ticket tracker, individual ticket items shall have type 12 + */ + TicketTracker = 33, + /** + * Confluence like kanban board + */ + KanBan = 34, + /** + * Whiteboard but without voice (whiteboard + voice is the same as stage) + */ + VoicelessWhiteboard = 35, + + // EVERYTHING BELOW THIS LINE SHOULD BE OLD NAMES FOR RENAMED ENUM MEMBERS // + + /** + * A channel that users can follow and crosspost into their own guild + * + * @deprecated This is the old name for {@apilink ChannelType#GuildAnnouncement} + * + * See https://support.discord.com/hc/articles/360032008192 + */ + GuildNews = 5, + /** + * A temporary sub-channel within a Guild Announcement channel + * + * @deprecated This is the old name for {@apilink ChannelType#AnnouncementThread} + */ + GuildNewsThread = 10, + /** + * A temporary sub-channel within a Guild Text channel + * + * @deprecated This is the old name for {@apilink ChannelType#PublicThread} + */ + GuildPublicThread = 11, + /** + * A temporary sub-channel within a Guild Text channel that is only viewable by those invited and those with the Manage Threads permission + * + * @deprecated This is the old name for {@apilink ChannelType#PrivateThread} + */ + GuildPrivateThread = 12, +} + +export enum VideoQualityMode { + /** + * Discord chooses the quality for optimal performance + */ + Auto = 1, + /** + * 720p + */ + Full, +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-structure + */ +export interface APIMessage { + /** + * ID of the message + */ + id: Snowflake; + /** + * ID of the channel the message was sent in + */ + channel_id: Snowflake; + /** + * The author of this message (only a valid user in the case where the message is generated by a user or bot user) + * + * If the message is generated by a webhook, the author object corresponds to the webhook's id, + * username, and avatar. You can tell if a message is generated by a webhook by checking for the `webhook_id` property + * + * See https://discord.com/developers/docs/resources/user#user-object + */ + author: APIUser; + /** + * Contents of the message + * + * The `MESSAGE_CONTENT` privileged gateway intent will become required after **August 31, 2022** for verified applications to receive a non-empty value from this field + * + * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot > Privileged Gateway Intents** + * + * See https://support-dev.discord.com/hc/articles/4404772028055 + */ + content: string; + /** + * When this message was sent + */ + timestamp: string; + /** + * When this message was edited (or null if never) + */ + edited_timestamp: string | null; + /** + * Whether this was a TTS message + */ + tts: boolean; + /** + * Whether this message mentions everyone + */ + mention_everyone: boolean; + /** + * Users specifically mentioned in the message + * + * The `member` field is only present in `MESSAGE_CREATE` and `MESSAGE_UPDATE` events + * from text-based guild channels + * + * See https://discord.com/developers/docs/resources/user#user-object + * See https://discord.com/developers/docs/resources/guild#guild-member-object + */ + mentions: APIUser[]; + /** + * Roles specifically mentioned in this message + * + * See https://discord.com/developers/docs/topics/permissions#role-object + */ + mention_roles: APIRole['id'][]; + /** + * Channels specifically mentioned in this message + * + * Not all channel mentions in a message will appear in `mention_channels`. + * - Only textual channels that are visible to everyone in a lurkable guild will ever be included + * - Only crossposted messages (via Channel Following) currently include `mention_channels` at all + * + * If no mentions in the message meet these requirements, this field will not be sent + * + * See https://discord.com/developers/docs/resources/channel#channel-mention-object + */ + mention_channels?: APIChannelMention[]; + /** + * Any attached files + * + * See https://discord.com/developers/docs/resources/channel#attachment-object + * + * The `MESSAGE_CONTENT` privileged gateway intent will become required after **August 31, 2022** for verified applications to receive a non-empty value from this field + * + * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot > Privileged Gateway Intents** + * + * See https://support-dev.discord.com/hc/articles/4404772028055 + */ + attachments: APIAttachment[]; + /** + * Any embedded content + * + * See https://discord.com/developers/docs/resources/channel#embed-object + * + * The `MESSAGE_CONTENT` privileged gateway intent will become required after **August 31, 2022** for verified applications to receive a non-empty value from this field + * + * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot > Privileged Gateway Intents** + * + * See https://support-dev.discord.com/hc/articles/4404772028055 + */ + embeds: APIEmbed[]; + /** + * Reactions to the message + * + * See https://discord.com/developers/docs/resources/channel#reaction-object + */ + reactions?: APIReaction[]; + /** + * A nonce that can be used for optimistic message sending (up to 25 characters) + * + * **You will not receive this from further fetches. This is received only once from a `MESSAGE_CREATE` + * event to ensure it got sent** + */ + nonce?: string | number; + /** + * Whether this message is pinned + */ + pinned: boolean; + /** + * If the message is generated by a webhook, this is the webhook's id + */ + webhook_id?: Snowflake; + /** + * Type of message + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-types + */ + type: MessageType; + /** + * Sent with Rich Presence-related chat embeds + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure + */ + activity?: APIMessageActivity; + /** + * Sent with Rich Presence-related chat embeds + * + * See https://discord.com/developers/docs/resources/application#application-object + */ + application?: Partial; + /** + * If the message is a response to an Interaction, this is the id of the interaction's application + */ + application_id?: Snowflake; + /** + * Reference data sent with crossposted messages, replies, pins, and thread starter messages + * + * See https://discord.com/developers/docs/resources/channel#message-reference-object-message-reference-structure + */ + message_reference?: APIMessageReference; + /** + * Message flags combined as a bitfield + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-flags + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + flags?: MessageFlags; + /** + * The message associated with the `message_reference` + * + * This field is only returned for messages with a `type` of `19` (REPLY). + * + * If the message is a reply but the `referenced_message` field is not present, + * the backend did not attempt to fetch the message that was being replied to, + * so its state is unknown. + * + * If the field exists but is `null`, the referenced message was deleted + * + * See https://discord.com/developers/docs/resources/channel#message-object + */ + referenced_message?: APIMessage | null; + /** + * Sent if the message is a response to an Interaction + */ + interaction?: APIMessageInteraction; + /** + * Sent if a thread was started from this message + */ + thread?: APIChannel; + /** + * Sent if the message contains components like buttons, action rows, or other interactive components + * + * The `MESSAGE_CONTENT` privileged gateway intent will become required after **August 31, 2022** for verified applications to receive a non-empty value from this field + * + * In the Discord Developers Portal, you need to enable the toggle of this intent of your application in **Bot > Privileged Gateway Intents** + * + * See https://support-dev.discord.com/hc/articles/4404772028055 + */ + components?: APIActionRowComponent[]; + /** + * Sent if the message contains stickers + * + * See https://discord.com/developers/docs/resources/sticker#sticker-item-object + */ + sticker_items?: APIStickerItem[]; + /** + * The stickers sent with the message + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + * @deprecated Use `sticker_items` instead + */ + stickers?: APISticker[]; + /** + * A generally increasing integer (there may be gaps or duplicates) that represents the approximate position of the message in a thread + * + * It can be used to estimate the relative position of the message in a thread in company with `total_message_sent` on parent thread + */ + position?: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-types + */ +export enum MessageType { + Default, + RecipientAdd, + RecipientRemove, + Call, + ChannelNameChange, + ChannelIconChange, + ChannelPinnedMessage, + UserJoin, + GuildBoost, + GuildBoostTier1, + GuildBoostTier2, + GuildBoostTier3, + ChannelFollowAdd, + + GuildDiscoveryDisqualified = 14, + GuildDiscoveryRequalified, + GuildDiscoveryGracePeriodInitialWarning, + GuildDiscoveryGracePeriodFinalWarning, + ThreadCreated, + Reply, + ChatInputCommand, + ThreadStarterMessage, + GuildInviteReminder, + ContextMenuCommand, + AutoModerationAction, + RoleSubscriptionPurchase, + InteractionPremiumUpsell, + StageStart, + StageEnd, + StageSpeaker, + StageRaiseHand, + StageTopic, + GuildApplicationPremiumSubscription, +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure + */ +export interface APIMessageActivity { + /** + * Type of message activity + * + * See https://discord.com/developers/docs/resources/channel#message-object-message-activity-types + */ + type: MessageActivityType; + /** + * `party_id` from a Rich Presence event + * + * See https://discord.com/developers/docs/rich-presence/how-to#updating-presence-update-presence-payload-fields + */ + party_id?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#message-reference-object-message-reference-structure + */ +export interface APIMessageReference { + /** + * ID of the originating message + */ + message_id?: Snowflake; + /** + * ID of the originating message's channel + */ + channel_id: Snowflake; + /** + * ID of the originating message's guild + */ + guild_id?: Snowflake; +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-activity-types + */ +export enum MessageActivityType { + Join = 1, + Spectate, + Listen, + JoinRequest = 5, +} + +/** + * https://discord.com/developers/docs/resources/channel#message-object-message-flags + */ +export enum MessageFlags { + /** + * This message has been published to subscribed channels (via Channel Following) + */ + Crossposted = 1 << 0, + /** + * This message originated from a message in another channel (via Channel Following) + */ + IsCrosspost = 1 << 1, + /** + * Do not include any embeds when serializing this message + */ + SuppressEmbeds = 1 << 2, + /** + * The source message for this crosspost has been deleted (via Channel Following) + */ + SourceMessageDeleted = 1 << 3, + /** + * This message came from the urgent message system + */ + Urgent = 1 << 4, + /** + * This message has an associated thread, which shares its id + */ + HasThread = 1 << 5, + /** + * This message is only visible to the user who invoked the Interaction + */ + Ephemeral = 1 << 6, + /** + * This message is an Interaction Response and the bot is "thinking" + */ + Loading = 1 << 7, + /** + * This message failed to mention some roles and add their members to the thread + */ + FailedToMentionSomeRolesInThread = 1 << 8, + /** + * This message will not trigger push and desktop notifications + */ + SuppressNotifications = 1 << 12, +} + +/** + * https://discord.com/developers/docs/resources/channel#followed-channel-object + */ +export interface APIFollowedChannel { + /** + * Source channel id + */ + channel_id: Snowflake; + /** + * Created target webhook id + */ + webhook_id: Snowflake; +} + +/** + * https://discord.com/developers/docs/resources/channel#reaction-object-reaction-structure + */ +export interface APIReaction { + /** + * Times this emoji has been used to react + */ + count: number; + /** + * Whether the current user reacted using this emoji + */ + me: boolean; + /** + * Emoji information + * + * See https://discord.com/developers/docs/resources/emoji#emoji-object + */ + emoji: APIPartialEmoji; +} + +/** + * https://discord.com/developers/docs/resources/channel#overwrite-object-overwrite-structure + */ +export interface APIOverwrite { + /** + * Role or user id + */ + id: Snowflake; + /** + * Either 0 (role) or 1 (member) + * + * {@link OverwriteType} + */ + type: OverwriteType; + /** + * Permission bit set + * + * See https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + allow: Permissions; + /** + * Permission bit set + * + * See https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + deny: Permissions; +} + +export enum OverwriteType { + Role, + Member, +} + +/** + * https://discord.com/developers/docs/resources/channel#thread-metadata-object-thread-metadata-structure + */ +export interface APIThreadMetadata { + /** + * Whether the thread is archived + */ + archived: boolean; + /** + * Duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 + */ + auto_archive_duration: ThreadAutoArchiveDuration; + /** + * An ISO8601 timestamp when the thread's archive status was last changed, used for calculating recent activity + */ + archive_timestamp: string; + /** + * Whether the thread is locked; when a thread is locked, only users with `MANAGE_THREADS` can unarchive it + */ + locked?: boolean; + /** + * Whether non-moderators can add other non-moderators to the thread; only available on private threads + */ + invitable?: boolean; + /** + * Timestamp when the thread was created; only populated for threads created after 2022-01-09 + */ + create_timestamp?: string; +} + +export enum ThreadAutoArchiveDuration { + OneHour = 60, + OneDay = 1440, + ThreeDays = 4320, + OneWeek = 10080, +} + +/** + * https://discord.com/developers/docs/resources/channel#thread-member-object-thread-member-structure + */ +export interface APIThreadMember { + /** + * The id of the thread + * + * **This field is omitted on the member sent within each thread in the `GUILD_CREATE` event** + */ + id?: Snowflake; + /** + * The id of the member + * + * **This field is omitted on the member sent within each thread in the `GUILD_CREATE` event** + */ + user_id?: Snowflake; + /** + * An ISO8601 timestamp for when the member last joined + */ + join_timestamp: string; + /** + * Member flags combined as a bitfield + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + flags: ThreadMemberFlags; + /** + * Additional information about the user + * + * **This field is omitted on the member sent within each thread in the `GUILD_CREATE` event** + * + * **This field is only present when `with_member` is set to true when calling `List Thread Members` or `Get Thread Member`** + */ + member?: APIGuildMember; +} + +export enum ThreadMemberFlags {} + +export interface APIThreadList { + /** + * The threads that were fetched + */ + threads: APIChannel[]; + /** + * The members for the client user in each of the fetched threads + */ + members: APIThreadMember[]; + /** + * Whether there are potentially additional threads + */ + has_more?: boolean; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-structure + * + * Length limit: 6000 characters + */ +export interface APIEmbed { + /** + * Title of embed + * + * Length limit: 256 characters + */ + title?: string; + /** + * Type of embed (always "rich" for webhook embeds) + * + * @deprecated *Embed types should be considered deprecated and might be removed in a future API version* + * + * See https://discord.com/developers/docs/resources/channel#embed-object-embed-types + */ + type?: EmbedType; + /** + * Description of embed + * + * Length limit: 4096 characters + */ + description?: string; + /** + * URL of embed + */ + url?: string; + /** + * Timestamp of embed content + */ + timestamp?: string; + /** + * Color code of the embed + */ + color?: number; + /** + * Footer information + * + * See https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure + */ + footer?: APIEmbedFooter; + /** + * Image information + * + * See https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure + */ + image?: APIEmbedImage; + /** + * Thumbnail information + * + * See https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure + */ + thumbnail?: APIEmbedThumbnail; + /** + * Video information + * + * See https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure + */ + video?: APIEmbedVideo; + /** + * Provider information + * + * See https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure + */ + provider?: APIEmbedProvider; + /** + * Author information + * + * See https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure + */ + author?: APIEmbedAuthor; + /** + * Fields information + * + * Length limit: 25 field objects + * + * See https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure + */ + fields?: APIEmbedField[]; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-types + * @deprecated *Embed types should be considered deprecated and might be removed in a future API version* + */ +export enum EmbedType { + /** + * Generic embed rendered from embed attributes + */ + Rich = 'rich', + /** + * Image embed + */ + Image = 'image', + /** + * Video embed + */ + Video = 'video', + /** + * Animated gif image embed rendered as a video embed + */ + GIFV = 'gifv', + /** + * Article embed + */ + Article = 'article', + /** + * Link embed + */ + Link = 'link', + /** + * Auto moderation alert embed + * + * @unstable This embed type is currently not documented by Discord, but it is returned in the auto moderation system messages. + */ + AutoModerationMessage = 'auto_moderation_message', +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure + */ +export interface APIEmbedThumbnail { + /** + * Source url of thumbnail (only supports http(s) and attachments) + */ + url: string; + /** + * A proxied url of the thumbnail + */ + proxy_url?: string; + /** + * Height of thumbnail + */ + height?: number; + /** + * Width of thumbnail + */ + width?: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure + */ +export interface APIEmbedVideo { + /** + * Source url of video + */ + url?: string; + /** + * A proxied url of the video + */ + proxy_url?: string; + /** + * Height of video + */ + height?: number; + /** + * Width of video + */ + width?: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure + */ +export interface APIEmbedImage { + /** + * Source url of image (only supports http(s) and attachments) + */ + url: string; + /** + * A proxied url of the image + */ + proxy_url?: string; + /** + * Height of image + */ + height?: number; + /** + * Width of image + */ + width?: number; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure + */ +export interface APIEmbedProvider { + /** + * Name of provider + */ + name?: string; + /** + * URL of provider + */ + url?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure + */ +export interface APIEmbedAuthor { + /** + * Name of author + * + * Length limit: 256 characters + */ + name: string; + /** + * URL of author + */ + url?: string; + /** + * URL of author icon (only supports http(s) and attachments) + */ + icon_url?: string; + /** + * A proxied url of author icon + */ + proxy_icon_url?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure + */ +export interface APIEmbedFooter { + /** + * Footer text + * + * Length limit: 2048 characters + */ + text: string; + /** + * URL of footer icon (only supports http(s) and attachments) + */ + icon_url?: string; + /** + * A proxied url of footer icon + */ + proxy_icon_url?: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure + */ +export interface APIEmbedField { + /** + * Name of the field + * + * Length limit: 256 characters + */ + name: string; + /** + * Value of the field + * + * Length limit: 1024 characters + */ + value: string; + /** + * Whether or not this field should display inline + */ + inline?: boolean; +} + +/** + * https://discord.com/developers/docs/resources/channel#attachment-object-attachment-structure + */ +export interface APIAttachment { + /** + * Attachment id + */ + id: Snowflake; + /** + * Name of file attached + */ + filename: string; + /** + * Description for the file + */ + description?: string; + /** + * The attachment's media type + * + * See https://en.wikipedia.org/wiki/Media_type + */ + content_type?: string; + /** + * Size of file in bytes + */ + size: number; + /** + * Source url of file + */ + url: string; + /** + * A proxied url of file + */ + proxy_url: string; + /** + * Height of file (if image) + */ + height?: number | null; + /** + * Width of file (if image) + */ + width?: number | null; + /** + * Whether this attachment is ephemeral + */ + ephemeral?: boolean; +} + +/** + * https://discord.com/developers/docs/resources/channel#channel-mention-object-channel-mention-structure + */ +export interface APIChannelMention { + /** + * ID of the channel + */ + id: Snowflake; + /** + * ID of the guild containing the channel + */ + guild_id: Snowflake; + /** + * The type of channel + * + * See https://discord.com/developers/docs/resources/channel#channel-object-channel-types + */ + type: ChannelType; + /** + * The name of the channel + */ + name: string; +} + +/** + * https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types + */ +export enum AllowedMentionsTypes { + /** + * Controls @everyone and @here mentions + */ + Everyone = 'everyone', + /** + * Controls role mentions + */ + Role = 'roles', + /** + * Controls user mentions + */ + User = 'users', +} + +/** + * https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mentions-structure + */ +export interface APIAllowedMentions { + /** + * An array of allowed mention types to parse from the content + * + * See https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types + */ + parse?: AllowedMentionsTypes[]; + /** + * Array of role_ids to mention (Max size of 100) + */ + roles?: Snowflake[]; + /** + * Array of user_ids to mention (Max size of 100) + */ + users?: Snowflake[]; + /** + * For replies, whether to mention the author of the message being replied to (default false) + * + * @default false + */ + replied_user?: boolean; +} + +/** + * https://discord.com/developers/docs/interactions/message-components#component-object + */ +export interface APIBaseComponent { + /** + * The type of the component + */ + type: T; +} + +/** + * https://discord.com/developers/docs/interactions/message-components#component-object-component-types + */ +export enum ComponentType { + /** + * Action Row component + */ + ActionRow = 1, + /** + * Button component + */ + Button, + /** + * Select menu for picking from defined text options + */ + StringSelect, + /** + * Text Input component + */ + TextInput, + /** + * Select menu for users + */ + UserSelect, + /** + * Select menu for roles + */ + RoleSelect, + /** + * Select menu for users and roles + */ + MentionableSelect, + /** + * Select menu for channels + */ + ChannelSelect, + + // EVERYTHING BELOW THIS LINE SHOULD BE OLD NAMES FOR RENAMED ENUM MEMBERS // + + /** + * Select menu for picking from defined text options + * + * @deprecated This is the old name for {@apilink ComponentType#StringSelect} + */ + SelectMenu = 3, +} + +/** + * https://discord.com/developers/docs/interactions/message-components#action-rows + */ +export interface APIActionRowComponent + extends APIBaseComponent { + /** + * The components in the ActionRow + */ + components: T[]; +} + +/** + * https://discord.com/developers/docs/interactions/message-components#buttons + */ +export interface APIButtonComponentBase