interaction helpers

This commit is contained in:
Skillz
2023-01-14 16:54:03 -06:00
parent f062fe0140
commit 2647ed0798
5 changed files with 1419 additions and 228 deletions

View File

@@ -22,7 +22,7 @@ export class StageInstance extends Base {
super(data.id);
this.client = client;
this.channel = client.getChannel(data.channel_id) || {
this.channel = client.getChannel(data.channel_id) ?? {
id: data.channel_id,
};
this.guild = client.guilds.get(data.guild_id) ?? { id: data.guild_id };

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
// import type { FileContent } from './discordeno.js'
import type { WebhookTypes } from './shared.js'
import type { Localization, WebhookTypes } from './shared.js'
// ActivityTypes,
// AllowedMentionsTypes,
@@ -1895,97 +1895,97 @@ export interface DiscordInviteStageInstance {
topic: string
}
// /** https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure */
// export interface DiscordApplicationCommand
// extends DiscordCreateApplicationCommand {
// /** Unique ID of command */
// id: string
// /** ID of the parent application */
// application_id: string
// /** Guild id of the command, if not global */
// guild_id?: string
// }
/** https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure */
export interface DiscordApplicationCommand
extends DiscordCreateApplicationCommand {
/** Unique ID of command */
id: string
/** ID of the parent application */
application_id: string
/** Guild id of the command, if not global */
guild_id?: string
}
// export interface DiscordCreateApplicationCommand {
// /** Type of command, defaults to `ApplicationCommandTypes.ChatInput` */
// type?: ApplicationCommandTypes
// /**
// * Name of command, 1-32 characters.
// * `ApplicationCommandTypes.ChatInput` command names must match the following regex `^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$` with the unicode flag set.
// * If there is a lowercase variant of any letters used, you must use those.
// * Characters with no lowercase variants and/or uncased letters are still allowed.
// * ApplicationCommandTypes.User` and `ApplicationCommandTypes.Message` commands may be mixed case and can include spaces.
// */
// name: string
// /** Localization object for `name` field. Values follow the same restrictions as `name` */
// name_localizations?: Localization | null
// /** Description for `ApplicationCommandTypes.ChatInput` commands, 1-100 characters. Empty string for `ApplicationCommandTypes.User` and `ApplicationCommandTypes.Message` commands */
// description: string
// /** Localization object for `description` field. Values follow the same restrictions as `description` */
// description_localizations?: Localization | null
// /** Parameters for the command, max of 25 */
// options?: DiscordApplicationCommandOption[]
// /** Set of permissions represented as a bit set */
// default_member_permissions?: string | 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
// /** Indicates whether the command is age-restricted, defaults to false */
// nsfw?: boolean
// /** Auto incrementing version identifier updated during substantial record changes */
// version?: string
// }
export interface DiscordCreateApplicationCommand {
/** Type of command, defaults to `ApplicationCommandTypes.ChatInput` */
type?: ApplicationCommandTypes
/**
* Name of command, 1-32 characters.
* `ApplicationCommandTypes.ChatInput` command names must match the following regex `^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$` with the unicode flag set.
* If there is a lowercase variant of any letters used, you must use those.
* Characters with no lowercase variants and/or uncased letters are still allowed.
* ApplicationCommandTypes.User` and `ApplicationCommandTypes.Message` commands may be mixed case and can include spaces.
*/
name: string
/** Localization object for `name` field. Values follow the same restrictions as `name` */
name_localizations?: Localization | null
/** Description for `ApplicationCommandTypes.ChatInput` commands, 1-100 characters. Empty string for `ApplicationCommandTypes.User` and `ApplicationCommandTypes.Message` commands */
description: string
/** Localization object for `description` field. Values follow the same restrictions as `description` */
description_localizations?: Localization | null
/** Parameters for the command, max of 25 */
options?: DiscordApplicationCommandOption[]
/** Set of permissions represented as a bit set */
default_member_permissions?: string | 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
/** Indicates whether the command is age-restricted, defaults to false */
nsfw?: boolean
/** Auto incrementing version identifier updated during substantial record changes */
version?: string
}
// /** https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure */
// export interface DiscordApplicationCommandOption {
// /** Type of option */
// type: ApplicationCommandOptionTypes
// /**
// * Name of command, 1-32 characters.
// * `ApplicationCommandTypes.ChatInput` command names must match the following regex `^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$` with the unicode flag set.
// * If there is a lowercase variant of any letters used, you must use those.
// * Characters with no lowercase variants and/or uncased letters are still allowed.
// * ApplicationCommandTypes.User` and `ApplicationCommandTypes.Message` commands may be mixed case and can include spaces.
// */
// name: string
// /** Localization object for the `name` field. Values follow the same restrictions as `name` */
// name_localizations?: Localization | null
// /** 1-100 character description */
// description: string
// /** Localization object for the `description` field. Values follow the same restrictions as `description` */
// description_localizations?: Localization | null
// /** If the parameter is required or optional--default `false` */
// required?: boolean
// /** Choices for the option types `ApplicationCommandOptionTypes.String`, `ApplicationCommandOptionTypes.Integer`, and `ApplicationCommandOptionTypes.Number`, from which the user can choose, max 25 */
// choices?: DiscordApplicationCommandOptionChoice[]
// /** If the option is a subcommand or subcommand group type, these nested options will be the parameters */
// options?: DiscordApplicationCommandOption[]
// /**
// * If autocomplete interactions are enabled for this option.
// *
// * Only available for `ApplicationCommandOptionTypes.String`, `ApplicationCommandOptionTypes.Integer` and `ApplicationCommandOptionTypes.Number` option types
// */
// autocomplete?: boolean
// /** If the option is a channel type, the channels shown will be restricted to these types */
// channel_types?: ChannelTypes[]
// /** If the option type is `ApplicationCommandOptionTypes.Integer` or `ApplicationCommandOptionTypes.Number`, the minimum permitted value */
// min_value?: number
// /** If the option type is `ApplicationCommandOptionTypes.Integer` or `ApplicationCommandOptionTypes.Number`, the maximum permitted value */
// max_value?: number
// /** If the option type is `ApplicationCommandOptionTypes.String`, the minimum permitted length */
// min_length?: number
// /** If the option type is `ApplicationCommandOptionTypes.String`, the maximum permitted length */
// max_length?: number
// }
/** https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure */
export interface DiscordApplicationCommandOption {
/** Type of option */
type: ApplicationCommandOptionTypes
/**
* Name of command, 1-32 characters.
* `ApplicationCommandTypes.ChatInput` command names must match the following regex `^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$` with the unicode flag set.
* If there is a lowercase variant of any letters used, you must use those.
* Characters with no lowercase variants and/or uncased letters are still allowed.
* ApplicationCommandTypes.User` and `ApplicationCommandTypes.Message` commands may be mixed case and can include spaces.
*/
name: string
/** Localization object for the `name` field. Values follow the same restrictions as `name` */
name_localizations?: Localization | null
/** 1-100 character description */
description: string
/** Localization object for the `description` field. Values follow the same restrictions as `description` */
description_localizations?: Localization | null
/** If the parameter is required or optional--default `false` */
required?: boolean
/** Choices for the option types `ApplicationCommandOptionTypes.String`, `ApplicationCommandOptionTypes.Integer`, and `ApplicationCommandOptionTypes.Number`, from which the user can choose, max 25 */
choices?: DiscordApplicationCommandOptionChoice[]
/** If the option is a subcommand or subcommand group type, these nested options will be the parameters */
options?: DiscordApplicationCommandOption[]
/**
* If autocomplete interactions are enabled for this option.
*
* Only available for `ApplicationCommandOptionTypes.String`, `ApplicationCommandOptionTypes.Integer` and `ApplicationCommandOptionTypes.Number` option types
*/
autocomplete?: boolean
/** If the option is a channel type, the channels shown will be restricted to these types */
channel_types?: ChannelTypes[]
/** If the option type is `ApplicationCommandOptionTypes.Integer` or `ApplicationCommandOptionTypes.Number`, the minimum permitted value */
min_value?: number
/** If the option type is `ApplicationCommandOptionTypes.Integer` or `ApplicationCommandOptionTypes.Number`, the maximum permitted value */
max_value?: number
/** If the option type is `ApplicationCommandOptionTypes.String`, the minimum permitted length */
min_length?: number
/** If the option type is `ApplicationCommandOptionTypes.String`, the maximum permitted length */
max_length?: number
}
// /** https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object */
// export interface DiscordApplicationCommandOptionChoice {
// /** 1-100 character choice name */
// name: string
// /** Localization object for the `name` field. Values follow the same restrictions as `name` */
// name_localizations?: Localization | null
// /** Value for the choice, up to 100 characters if string */
// value: string | number
// }
/** https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object */
export interface DiscordApplicationCommandOptionChoice {
/** 1-100 character choice name */
name: string
/** Localization object for the `name` field. Values follow the same restrictions as `name` */
name_localizations?: Localization | null
/** Value for the choice, up to 100 characters if string */
value: string | number
}
/** https://discord.com/developers/docs/interactions/slash-commands#guildapplicationcommandpermissions */
export interface DiscordGuildApplicationCommandPermissions {

View File

@@ -8,10 +8,15 @@ import type {
} from './discord'
import type {
AllowedMentionsTypes,
ApplicationCommandOptionTypes,
ApplicationCommandPermissionTypes,
ApplicationCommandTypes,
BigString,
ButtonStyles,
Camelize,
ChannelTypes,
InteractionResponseTypes,
Localization,
MessageComponentTypes,
OverwriteTypes,
PermissionStrings,
@@ -394,45 +399,45 @@ export interface GetInvite {
scheduledEventId?: BigString
}
// export type CreateApplicationCommand =
// | CreateSlashApplicationCommand
// | CreateContextApplicationCommand
export type CreateApplicationCommand =
| CreateSlashApplicationCommand
| CreateContextApplicationCommand
// /** https://discord.com/developers/docs/interactions/application-commands#endpoints-json-params */
// export interface CreateSlashApplicationCommand {
// /**
// * Name of command, 1-32 characters.
// * `ApplicationCommandTypes.ChatInput` command names must match the following regex `^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$` with the unicode flag set.
// * If there is a lowercase variant of any letters used, you must use those.
// * Characters with no lowercase variants and/or uncased letters are still allowed.
// * ApplicationCommandTypes.User` and `ApplicationCommandTypes.Message` commands may be mixed case and can include spaces.
// */
// name: string
// /** Localization object for the `name` field. Values follow the same restrictions as `name` */
// nameLocalizations?: Localization
// /** 1-100 character description */
// description: string
// /** Localization object for the `description` field. Values follow the same restrictions as `description` */
// descriptionLocalizations?: Localization
// /** Type of command, defaults `ApplicationCommandTypes.ChatInput` if not set */
// type?: ApplicationCommandTypes
// /** Parameters for the command */
// options?: ApplicationCommandOption[]
// /** Set of permissions represented as a bit set */
// defaultMemberPermissions?: PermissionStrings[]
// /** Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible. */
// dmPermission?: boolean
// }
/** https://discord.com/developers/docs/interactions/application-commands#endpoints-json-params */
export interface CreateSlashApplicationCommand {
/**
* Name of command, 1-32 characters.
* `ApplicationCommandTypes.ChatInput` command names must match the following regex `^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$` with the unicode flag set.
* If there is a lowercase variant of any letters used, you must use those.
* Characters with no lowercase variants and/or uncased letters are still allowed.
* ApplicationCommandTypes.User` and `ApplicationCommandTypes.Message` commands may be mixed case and can include spaces.
*/
name: string
/** Localization object for the `name` field. Values follow the same restrictions as `name` */
nameLocalizations?: Localization
/** 1-100 character description */
description: string
/** Localization object for the `description` field. Values follow the same restrictions as `description` */
descriptionLocalizations?: Localization
/** Type of command, defaults `ApplicationCommandTypes.ChatInput` if not set */
type?: ApplicationCommandTypes
/** Parameters for the command */
options?: ApplicationCommandOption[]
/** Set of permissions represented as a bit set */
defaultMemberPermissions?: PermissionStrings[]
/** Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible. */
dmPermission?: boolean
}
// /** https://discord.com/developers/docs/interactions/application-commands#endpoints-json-params */
// export interface CreateContextApplicationCommand
// extends Omit<
// CreateSlashApplicationCommand,
// 'options' | 'description' | 'descriptionLocalizations'
// > {
// /** The type of the command */
// type: ApplicationCommandTypes.Message | ApplicationCommandTypes.User
// }
/** https://discord.com/developers/docs/interactions/application-commands#endpoints-json-params */
export interface CreateContextApplicationCommand
extends Omit<
CreateSlashApplicationCommand,
'options' | 'description' | 'descriptionLocalizations'
> {
/** The type of the command */
type: ApplicationCommandTypes.Message | ApplicationCommandTypes.User
}
/** https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata */
export interface InteractionCallbackData {
@@ -465,44 +470,44 @@ export interface ApplicationCommandOptionChoice {
value: string | number
}
// /** https://discord.com/developers/docs/interactions/slash-commands#interaction-response */
// export interface InteractionResponse {
// /** The type of response */
// type: InteractionResponseTypes
// /** An optional response message */
// data?: InteractionCallbackData
// }
/** https://discord.com/developers/docs/interactions/slash-commands#interaction-response */
export interface InteractionResponse {
/** The type of response */
type: InteractionResponseTypes
/** An optional response message */
data?: InteractionCallbackData
}
// export interface ApplicationCommandOption {
// /** Value of Application Command Option Type */
// type: ApplicationCommandOptionTypes
// /** 1-32 character name matching lowercase `^[\w-]{1,32}$` */
// name: string
// /** Localization object for the `name` field. Values follow the same restrictions as `name` */
// nameLocalizations?: Localization
// /** 1-100 character description */
// description: string
// /** Localization object for the `description` field. Values follow the same restrictions as `description` */
// descriptionLocalizations?: Localization
// /** If the parameter is required or optional--default `false` */
// required?: boolean
// /** Choices for `string` and `int` types for the user to pick from */
// choices?: ApplicationCommandOptionChoice[]
// /** If the option is a subcommand or subcommand group type, this nested options will be the parameters */
// options?: ApplicationCommandOption[]
// /** If the option is a channel type, the channels shown will be restricted to these types */
// channelTypes?: ChannelTypes[]
// /** Minimum number desired. */
// minValue?: number
// /** Maximum number desired. */
// maxValue?: number
// /** Minimum length desired. */
// minLength?: number
// /** Maximum length desired. */
// maxLength?: number
// /** if autocomplete interactions are enabled for this `String`, `Integer`, or `Number` type option */
// autocomplete?: boolean
// }
export interface ApplicationCommandOption {
/** Value of Application Command Option Type */
type: ApplicationCommandOptionTypes
/** 1-32 character name matching lowercase `^[\w-]{1,32}$` */
name: string
/** Localization object for the `name` field. Values follow the same restrictions as `name` */
nameLocalizations?: Localization
/** 1-100 character description */
description: string
/** Localization object for the `description` field. Values follow the same restrictions as `description` */
descriptionLocalizations?: Localization
/** If the parameter is required or optional--default `false` */
required?: boolean
/** Choices for `string` and `int` types for the user to pick from */
choices?: ApplicationCommandOptionChoice[]
/** If the option is a subcommand or subcommand group type, this nested options will be the parameters */
options?: ApplicationCommandOption[]
/** If the option is a channel type, the channels shown will be restricted to these types */
channelTypes?: ChannelTypes[]
/** Minimum number desired. */
minValue?: number
/** Maximum number desired. */
maxValue?: number
/** Minimum length desired. */
minLength?: number
/** Maximum length desired. */
maxLength?: number
/** if autocomplete interactions are enabled for this `String`, `Integer`, or `Number` type option */
autocomplete?: boolean
}
/** https://discord.com/developers/docs/resources/emoji#create-guild-emoji */
export interface CreateGuildEmoji extends WithReason {
@@ -913,3 +918,13 @@ export interface EditMessage {
/** The components you would like to have sent in this message */
components?: MessageComponents
}
/** https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions */
export interface ApplicationCommandPermissions {
/** The id of the role or user */
id: string
/** Role or User */
type: ApplicationCommandPermissionTypes
/** `true` to allow, `false`, to disallow */
permission: boolean
}

View File

@@ -1388,40 +1388,40 @@ export type ImageSize = 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096
// YOU_CAN_NOT_DM_THE_BOT_ITSELF = 'YOU_CAN_NOT_DM_THE_BOT_ITSELF',
// }
// export enum Locales {
// Danish = 'da',
// German = 'de',
// EnglishUk = 'en-GB',
// EnglishUs = 'en-US',
// Spanish = 'es-ES',
// French = 'fr',
// Croatian = 'hr',
// Italian = 'it',
// Lithuanian = 'lt',
// Hungarian = 'hu',
// Dutch = 'nl',
// Norwegian = 'no',
// Polish = 'pl',
// PortugueseBrazilian = 'pt-BR',
// RomanianRomania = 'ro',
// Finnish = 'fi',
// Swedish = 'sv-SE',
// Vietnamese = 'vi',
// Turkish = 'tr',
// Czech = 'cs',
// Greek = 'el',
// Bulgarian = 'bg',
// Russian = 'ru',
// Ukrainian = 'uk',
// Hindi = 'hi',
// Thai = 'th',
// ChineseChina = 'zh-CN',
// Japanese = 'ja',
// ChineseTaiwan = 'zh-TW',
// Korean = 'ko',
// }
export enum Locales {
Danish = 'da',
German = 'de',
EnglishUk = 'en-GB',
EnglishUs = 'en-US',
Spanish = 'es-ES',
French = 'fr',
Croatian = 'hr',
Italian = 'it',
Lithuanian = 'lt',
Hungarian = 'hu',
Dutch = 'nl',
Norwegian = 'no',
Polish = 'pl',
PortugueseBrazilian = 'pt-BR',
RomanianRomania = 'ro',
Finnish = 'fi',
Swedish = 'sv-SE',
Vietnamese = 'vi',
Turkish = 'tr',
Czech = 'cs',
Greek = 'el',
Bulgarian = 'bg',
Russian = 'ru',
Ukrainian = 'uk',
Hindi = 'hi',
Thai = 'th',
ChineseChina = 'zh-CN',
Japanese = 'ja',
ChineseTaiwan = 'zh-TW',
Korean = 'ko',
}
// export type Localization = Partial<Record<Locales, string>>
export type Localization = Partial<Record<Locales, string>>
// // UTILS