diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..37441bee --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "files.eol": "\n" +} \ No newline at end of file diff --git a/common/index.ts b/common/index.ts index 2d1815b3..73280d01 100644 --- a/common/index.ts +++ b/common/index.ts @@ -147,3 +147,14 @@ export interface GatewayConnectQuery { encoding: 'json' | 'etf'; compress?: 'zlib-stream'; } + +/** + * https://discord.com/developers/docs/reference#snowflakes + */ +export type Snowflake = `${bigint}`; + +/** + * https://discord.com/developers/docs/topics/permissions + * @internal + */ +export type Permissions = `${bigint}`; diff --git a/v8/gateway/index.ts b/v8/gateway/index.ts index fcb18f93..140a91df 100644 --- a/v8/gateway/index.ts +++ b/v8/gateway/index.ts @@ -2,6 +2,7 @@ * Types extracted from https://discord.com/developers/docs/topics/gateway */ +import type { Snowflake } from '../../common/index'; import type { APIChannel, APIEmoji, @@ -550,11 +551,11 @@ export interface GatewayChannelPinsUpdateDispatchData { /** * The id of the guild */ - guild_id?: string; + guild_id?: Snowflake; /** * The id of the channel */ - channel_id: string; + channel_id: Snowflake; /** * The time at which the most recent pinned message was pinned */ @@ -623,7 +624,7 @@ export interface GatewayGuildBanModifyDispatchData { /** * ID of the guild */ - guild_id: string; + guild_id: Snowflake; /** * The banned user * @@ -667,7 +668,7 @@ export interface GatewayGuildEmojisUpdateDispatchData { /** * ID of the guild */ - guild_id: string; + guild_id: Snowflake; /** * Array of emojis * @@ -691,7 +692,7 @@ export interface GatewayGuildIntegrationsUpdateDispatchData { /** * ID of the guild whose integrations were updated */ - guild_id: string; + guild_id: Snowflake; } /** @@ -709,7 +710,7 @@ export interface GatewayGuildMemberAddDispatchData extends APIGuildMember { /** * The id of the guild */ - guild_id: string; + guild_id: Snowflake; } /** @@ -727,7 +728,7 @@ export interface GatewayGuildMemberRemoveDispatchData { /** * The id of the guild */ - guild_id: string; + guild_id: Snowflake; /** * The user who was removed * @@ -751,7 +752,7 @@ export type GatewayGuildMemberUpdateDispatchData = Omit; /** @@ -1021,15 +1022,15 @@ export interface GatewayMessageDeleteDispatchData { /** * The id of the message */ - id: string; + id: Snowflake; /** * The id of the channel */ - channel_id: string; + channel_id: Snowflake; /** * The id of the guild */ - guild_id?: string; + guild_id?: Snowflake; } /** @@ -1047,15 +1048,15 @@ export interface GatewayMessageDeleteBulkDispatchData { /** * The ids of the messages */ - ids: string[]; + ids: Snowflake[]; /** * The id of the channel */ - channel_id: string; + channel_id: Snowflake; /** * The id of the guild */ - guild_id?: string; + guild_id?: Snowflake; } /** @@ -1134,15 +1135,15 @@ export interface GatewayTypingStartDispatchData { /** * The id of the channel */ - channel_id: string; + channel_id: Snowflake; /** * The id of the guild */ - guild_id?: string; + guild_id?: Snowflake; /** * The id of the user */ - user_id: string; + user_id: Snowflake; /** * Unix time (in seconds) of when the user started typing */ @@ -1197,7 +1198,7 @@ export interface GatewayVoiceServerUpdateDispatchData { /** * The guild this voice server update is for */ - guild_id: string; + guild_id: Snowflake; /** * The voice server host */ @@ -1219,11 +1220,11 @@ export interface GatewayWebhooksUpdateDispatchData { /** * The id of the guild */ - guild_id: string; + guild_id: Snowflake; /** * The id of the channel */ - channel_id: string; + channel_id: Snowflake; } // #endregion Dispatch Payloads @@ -1364,7 +1365,7 @@ export interface GatewayRequestGuildMembersData { /** * ID of the guild to get members for */ - guild_id: string | string[]; + guild_id: Snowflake; /** * String that username starts with, or an empty string to return all members */ @@ -1381,7 +1382,7 @@ export interface GatewayRequestGuildMembersData { /** * Used to specify which users you wish to fetch */ - user_ids?: string | string[]; + user_ids?: Snowflake | Snowflake[]; /** * Nonce to identify the Guild Members Chunk response * @@ -1405,11 +1406,11 @@ export interface GatewayVoiceStateUpdateData { /** * ID of the guild */ - guild_id: string; + guild_id: Snowflake; /** * ID of the voice channel client wants to join (`null` if disconnecting) */ - channel_id: string | null; + channel_id: Snowflake | null; /** * Is the client muted */ @@ -1496,19 +1497,19 @@ type ReactionData = D /** * The id of the user */ - user_id: string; + user_id: Snowflake; /** * The id of the channel */ - channel_id: string; + channel_id: Snowflake; /** * The id of the message */ - message_id: string; + message_id: Snowflake; /** * The id of the guild */ - guild_id?: string; + guild_id?: Snowflake; /** * The member who reacted if this happened in a guild * @@ -1530,14 +1531,14 @@ interface MessageReactionRemoveData { /** * The id of the channel */ - channel_id: string; + channel_id: Snowflake; /** * The id of the message */ - message_id: string; + message_id: Snowflake; /** * The id of the guild */ - guild_id?: string; + guild_id?: Snowflake; } // #endregion Shared diff --git a/v8/payloads/auditLog.ts b/v8/payloads/auditLog.ts index 76b942f7..12cfdd3f 100644 --- a/v8/payloads/auditLog.ts +++ b/v8/payloads/auditLog.ts @@ -2,6 +2,7 @@ * Types extracted from https://discord.com/developers/docs/resources/audit-log */ +import type { Snowflake } from '../../common/index'; import type { APIOverwrite, ChannelType } from './channel'; import type { APIGuildIntegration, @@ -65,11 +66,11 @@ export interface APIAuditLogEntry { * *Against all odds, this can be `null` in some cases (webhooks deleting themselves * by using their own token, for example)* */ - user_id: string | null; + user_id: Snowflake | null; /** * ID of the entry */ - id: string; + id: Snowflake; /** * Type of action that occurred * @@ -165,7 +166,7 @@ export interface APIAuditLogOptions { * - MESSAGE_UNPIN * - MESSAGE_DELETE */ - channel_id?: string; + channel_id?: Snowflake; /** * ID of the message that was targeted @@ -174,7 +175,7 @@ export interface APIAuditLogOptions { * - MESSAGE_PIN * - MESSAGE_UNPIN */ - message_id?: string; + message_id?: Snowflake; /** * Number of entities that were targeted @@ -195,7 +196,7 @@ export interface APIAuditLogOptions { * - CHANNEL_OVERWRITE_UPDATE * - CHANNEL_OVERWRITE_DELETE */ - id?: string; + id?: Snowflake; /** * Type of overwritten entity - "0" for "role" or "1" for "member" @@ -297,7 +298,7 @@ export type APIAuditLogChangeKeySplashHash = AuditLogChangeData<'splash_hash', s /** * Returned when a guild's owner ID is changed */ -export type APIAuditLogChangeKeyOwnerID = AuditLogChangeData<'owner_id', string>; +export type APIAuditLogChangeKeyOwnerID = AuditLogChangeData<'owner_id', Snowflake>; /** * Returned when a guild's region is changed @@ -307,7 +308,7 @@ export type APIAuditLogChangeKeyRegion = AuditLogChangeData<'region', string>; /** * Returned when a guild's afk_channel_id is changed */ -export type APIAuditLogChangeKeyAFKChannelID = AuditLogChangeData<'afk_channel_id', string>; +export type APIAuditLogChangeKeyAFKChannelID = AuditLogChangeData<'afk_channel_id', Snowflake>; /** * Returned when a guild's afk_timeout is changed @@ -368,12 +369,12 @@ export type APIAuditLogChangeKeyWidgetEnabled = AuditLogChangeData<'widget_enabl /** * Returned when a guild's widget_channel_id is changed */ -export type APIAuditLogChangeKeyWidgetChannelID = AuditLogChangeData<'widget_channel_id', string>; +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', string>; +export type APIAuditLogChangeKeySystemChannelID = AuditLogChangeData<'system_channel_id', Snowflake>; /** * Returned when a channel's position is changed @@ -403,7 +404,7 @@ export type APIAuditLogChangeKeyNSFW = AuditLogChangeData<'nsfw', boolean>; /** * The application ID of the added or removed Webhook or Bot */ -export type APIAuditLogChangeKeyApplicationID = AuditLogChangeData<'application_id', string>; +export type APIAuditLogChangeKeyApplicationID = AuditLogChangeData<'application_id', Snowflake>; /** * Returned when a channel's amount of seconds a user has to wait before sending another message @@ -449,12 +450,12 @@ export type APIAuditLogChangeKeyCode = AuditLogChangeData<'code', string>; /** * Returned when an invite's channel_id is changed */ -export type APIAuditLogChangeKeyChannelID = AuditLogChangeData<'channel_id', string>; +export type APIAuditLogChangeKeyChannelID = AuditLogChangeData<'channel_id', Snowflake>; /** * Returned when an invite's inviter_id is changed */ -export type APIAuditLogChangeKeyInviterID = AuditLogChangeData<'inviter_id', string>; +export type APIAuditLogChangeKeyInviterID = AuditLogChangeData<'inviter_id', Snowflake>; /** * Returned when an invite's max_uses is changed @@ -499,7 +500,7 @@ export type APIAuditLogChangeKeyAvatarHash = AuditLogChangeData<'avatar_hash', s /** * The ID of the changed entity - sometimes used in conjunction with other keys */ -export type APIAuditLogChangeKeyID = AuditLogChangeData<'id', string>; +export type APIAuditLogChangeKeyID = AuditLogChangeData<'id', Snowflake>; /** * The type of entity created diff --git a/v8/payloads/channel.ts b/v8/payloads/channel.ts index c6f67037..7ede6d2c 100644 --- a/v8/payloads/channel.ts +++ b/v8/payloads/channel.ts @@ -2,8 +2,10 @@ * Types extracted from https://discord.com/developers/docs/resources/channel */ +import type { Permissions, Snowflake } from '../../common/index'; import type { APIPartialEmoji } from './emoji'; import type { APIGuildMember } from './guild'; +import type { APIRole } from './permissions'; import type { APIUser } from './user'; /** @@ -13,7 +15,7 @@ export interface APIPartialChannel { /** * The id of the channel */ - id: string; + id: Snowflake; /** * The type of the channel * @@ -33,7 +35,7 @@ export interface APIChannel extends APIPartialChannel { /** * The id of the guild */ - guild_id?: string; + guild_id?: Snowflake; /** * Sorting position of the channel */ @@ -55,7 +57,7 @@ export interface APIChannel extends APIPartialChannel { /** * The id of the last message sent in this channel (may not point to an existing or valid message) */ - last_message_id?: string | null; + last_message_id?: Snowflake | null; /** * The bitrate (in bits) of the voice channel */ @@ -82,15 +84,15 @@ export interface APIChannel extends APIPartialChannel { /** * ID of the DM creator */ - owner_id?: string; + owner_id?: Snowflake; /** * Application id of the group DM creator if it is bot-created */ - application_id?: string; + application_id?: Snowflake; /** * ID of the parent category for a channel (each parent category can contain up to 50 channels) */ - parent_id?: string | null; + parent_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 @@ -145,15 +147,15 @@ export interface APIMessage { /** * ID of the message */ - id: string; + id: Snowflake; /** * ID of the channel the message was sent in */ - channel_id: string; + channel_id: Snowflake; /** * ID of the guild the message was sent in */ - guild_id?: string; + guild_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) * @@ -207,7 +209,7 @@ export interface APIMessage { * * See https://discord.com/developers/docs/topics/permissions#role-object */ - mention_roles: string[]; + mention_roles: APIRole['id'][]; /** * Channels specifically mentioned in this message * @@ -252,7 +254,7 @@ export interface APIMessage { /** * If the message is generated by a webhook, this is the webhook's id */ - webhook_id?: string; + webhook_id?: Snowflake; /** * Type of message * @@ -357,7 +359,7 @@ export interface APIMessageApplication { /** * ID of the application */ - id: string; + id: Snowflake; /** * ID of the embed's image asset */ @@ -383,15 +385,15 @@ export interface APIMessageReference { /** * ID of the originating message */ - message_id?: string; + message_id?: Snowflake; /** * ID of the originating message's channel */ - channel_id: string; + channel_id: Snowflake; /** * ID of the originating message's guild */ - guild_id?: string; + guild_id?: Snowflake; } /** @@ -438,11 +440,11 @@ export interface APISticker { /** * ID of the sticker */ - id: string; + id: Snowflake; /** * ID of the pack the sticker is from */ - pack_id: string; + pack_id: Snowflake; /** * Name of the sticker */ @@ -487,11 +489,11 @@ export interface APIFollowedChannel { /** * Source channel id */ - channel_id: string; + channel_id: Snowflake; /** * Created target webhook id */ - webhook_id: string; + webhook_id: Snowflake; } /** @@ -521,7 +523,7 @@ export interface APIOverwrite { /** * Role or user id */ - id: string; + id: Snowflake; /** * Either 0 (role) or 1 (member) * @@ -535,7 +537,7 @@ export interface APIOverwrite { * * See https://en.wikipedia.org/wiki/Bit_field */ - allow: string; + allow: Permissions; /** * Permission bit set * @@ -543,7 +545,7 @@ export interface APIOverwrite { * * See https://en.wikipedia.org/wiki/Bit_field */ - deny: string; + deny: Permissions; } export const enum OverwriteType { @@ -815,7 +817,7 @@ export interface APIAttachment { /** * Attachment id */ - id: string; + id: Snowflake; /** * Name of file attached */ @@ -849,11 +851,11 @@ export interface APIChannelMention { /** * ID of the channel */ - id: string; + id: Snowflake; /** * ID of the guild containing the channel */ - guild_id: string; + guild_id: Snowflake; /** * The type of channel * @@ -897,11 +899,11 @@ export interface APIAllowedMentions { /** * Array of role_ids to mention (Max size of 100) */ - roles?: string[]; + roles?: Snowflake[]; /** * Array of user_ids to mention (Max size of 100) */ - users?: string[]; + users?: Snowflake[]; /** * For replies, whether to mention the author of the message being replied to (default false) * diff --git a/v8/payloads/emoji.ts b/v8/payloads/emoji.ts index 51f91b87..c3418db5 100644 --- a/v8/payloads/emoji.ts +++ b/v8/payloads/emoji.ts @@ -2,6 +2,8 @@ * Types extracted from https://discord.com/developers/docs/resources/emoji */ +import type { Snowflake } from '../../common/index'; +import type { APIRole } from './permissions'; import type { APIUser } from './user'; /** @@ -11,7 +13,7 @@ export interface APIPartialEmoji { /** * Emoji id */ - id: string | null; + id: Snowflake | null; /** * Emoji name (can be null only in reaction emoji objects) */ @@ -29,7 +31,7 @@ export interface APIEmoji extends APIPartialEmoji { /** * Roles this emoji is whitelisted to */ - roles?: string[]; + roles?: APIRole['id'][]; /** * User that created this emoji */ diff --git a/v8/payloads/gateway.ts b/v8/payloads/gateway.ts index 74423e04..24597c0d 100644 --- a/v8/payloads/gateway.ts +++ b/v8/payloads/gateway.ts @@ -2,6 +2,7 @@ * Types extracted from https://discord.com/developers/docs/topics/gateway */ +import type { Snowflake } from '../../common/index'; import type { APIEmoji } from './emoji'; import type { APIUser } from './user'; @@ -67,13 +68,11 @@ export interface GatewayPresenceUpdate { * * See https://discord.com/developers/docs/resources/user#user-object */ - user: Partial & { - id: string; - }; + user: Partial & Pick; /** * ID of the guild */ - guild_id: string; + guild_id: Snowflake; /** * Either "idle", "dnd", "online", or "offline" */ @@ -156,7 +155,7 @@ export interface GatewayActivity { /** * Application id for the game */ - application_id?: string; + application_id?: Snowflake; /** * What the player is currently doing */ diff --git a/v8/payloads/guild.ts b/v8/payloads/guild.ts index f307029e..77f5078c 100644 --- a/v8/payloads/guild.ts +++ b/v8/payloads/guild.ts @@ -2,6 +2,7 @@ * Types extracted from https://discord.com/developers/docs/resources/guild */ +import type { Permissions, Snowflake } from '../../common/index'; import type { APIChannel } from './channel'; import type { APIEmoji } from './emoji'; import type { GatewayPresenceUpdate, PresenceUpdateStatus } from './gateway'; @@ -16,7 +17,7 @@ export interface APIUnavailableGuild { /** * Guild id */ - id: string; + id: Snowflake; /** * `true` if this guild is unavailable due to an outage */ @@ -100,7 +101,7 @@ export interface APIGuild extends APIPartialGuild { /** * ID of owner */ - owner_id: string; + owner_id: Snowflake; /** * Total permissions for the user in the guild (excludes overrides) * @@ -108,7 +109,7 @@ export interface APIGuild extends APIPartialGuild { * * See https://en.wikipedia.org/wiki/Bit_field */ - permissions?: string; + permissions?: Permissions; /** * Voice region id for the guild * @@ -118,7 +119,7 @@ export interface APIGuild extends APIPartialGuild { /** * ID of afk channel */ - afk_channel_id: string | null; + afk_channel_id: Snowflake | null; /** * afk timeout in seconds */ @@ -130,7 +131,7 @@ export interface APIGuild extends APIPartialGuild { /** * The channel id that the widget will generate an invite to, or `null` if set to no invite */ - widget_channel_id?: string | null; + widget_channel_id?: Snowflake | null; /** * Verification level required for the guild * @@ -176,11 +177,11 @@ export interface APIGuild extends APIPartialGuild { /** * Application id of the guild creator if it is bot-created */ - application_id: string | null; + application_id: Snowflake | null; /** * The id of the channel where guild notices such as welcome messages and boost events are posted */ - system_channel_id: string | null; + system_channel_id: Snowflake | null; /** * System channel flags * @@ -190,7 +191,7 @@ export interface APIGuild extends APIPartialGuild { /** * The id of the channel where Community guilds can display rules and/or guidelines */ - rules_channel_id: string | null; + rules_channel_id: Snowflake | null; /** * When this guild was joined at * @@ -282,7 +283,7 @@ export interface APIGuild extends APIPartialGuild { /** * The id of the channel where admins and moderators of Community guilds receive notices from Discord */ - public_updates_channel_id: string | null; + public_updates_channel_id: Snowflake | null; /** * The maximum amount of users in a video channel */ @@ -447,7 +448,7 @@ export interface APIGuildPreview { /** * Guild id */ - id: string; + id: Snowflake; /** * Guild name (2-100 characters) */ @@ -507,7 +508,7 @@ export interface APIGuildWidgetSettings { /** * The widget channel id */ - channel_id: string | null; + channel_id: Snowflake | null; } /** @@ -531,7 +532,7 @@ export interface APIGuildMember { * * See https://discord.com/developers/docs/topics/permissions#role-object */ - roles: string[]; + roles: Snowflake[]; /** * When the user joined the guild */ @@ -565,7 +566,7 @@ export interface APIGuildIntegration { /** * Integration id */ - id: string; + id: Snowflake; /** * Integration name */ @@ -589,7 +590,7 @@ export interface APIGuildIntegration { * * **This field is not provided for `discord` bot integrations.** */ - role_id?: string; + role_id?: Snowflake; /** * Whether emoticons should be synced for this integration (`twitch` only currently) * @@ -683,7 +684,7 @@ export interface APIGuildIntegrationApplication { /** * The id of the app */ - id: string; + id: Snowflake; /** * The name of the app */ @@ -728,7 +729,7 @@ export interface APIBan { * https://discord.com/developers/docs/resources/guild#get-guild-widget-example-get-guild-widget */ export interface APIGuildWidget { - id: string; + id: Snowflake; name: string; instant_invite: string | null; channels: APIGuildWidgetChannel[]; @@ -740,7 +741,7 @@ export interface APIGuildWidget { * https://discord.com/developers/docs/resources/guild#get-guild-widget-example-get-guild-widget */ export interface APIGuildWidgetChannel { - id: string; + id: Snowflake; name: string; position: number; } @@ -800,11 +801,11 @@ export interface APIGuildWelcomeScreenChannel { /** * The channel id that is suggested */ - channel_id: string; + channel_id: Snowflake; /** * The emoji id of the emoji that is shown on the left of the channel */ - emoji_id: string | null; + emoji_id: Snowflake | null; /** * The emoji name of the emoji that is shown on the left of the channel */ diff --git a/v8/payloads/interactions.ts b/v8/payloads/interactions.ts index 2c299b4f..41d99c20 100644 --- a/v8/payloads/interactions.ts +++ b/v8/payloads/interactions.ts @@ -1,3 +1,4 @@ +import type { Permissions, Snowflake } from '../../common/index'; import type { APIGuildMember, APIUser, MessageFlags } from './index'; import type { RESTPostAPIWebhookWithTokenJSONBody } from '../rest/index'; @@ -5,8 +6,8 @@ import type { RESTPostAPIWebhookWithTokenJSONBody } from '../rest/index'; * https://discord.com/developers/docs/interactions/slash-commands#applicationcommand */ export interface APIApplicationCommand { - id: string; - application_id: string; + id: Snowflake; + application_id: Snowflake; name: string; description: string; options?: APIApplicationCommandOption[]; @@ -79,12 +80,12 @@ export interface APIApplicationCommandOptionChoice { * https://discord.com/developers/docs/interactions/slash-commands#interaction */ export interface APIInteraction { - id: string; + id: Snowflake; type: InteractionType; data?: APIApplicationCommandInteractionData; - guild_id: string; - channel_id: string; - member: APIGuildMember & { permissions: string; user: APIUser }; + guild_id: Snowflake; + channel_id: Snowflake; + member: APIGuildMember & { permissions: Permissions; user: APIUser }; token: string; version: 1; } @@ -106,7 +107,7 @@ export const enum InteractionType { * https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata */ export interface APIApplicationCommandInteractionData { - id: string; + id: Snowflake; name: string; options?: APIApplicationCommandInteractionDataOption[]; } diff --git a/v8/payloads/oauth2.ts b/v8/payloads/oauth2.ts index 4d3abc4c..50cbabba 100644 --- a/v8/payloads/oauth2.ts +++ b/v8/payloads/oauth2.ts @@ -2,6 +2,7 @@ * Types extracted from https://discord.com/developers/docs/topics/oauth2 */ +import type { Snowflake } from '../../common/index'; import type { APITeam } from './teams'; import type { APIUser } from './user'; @@ -12,7 +13,7 @@ export interface APIApplication { /** * The id of the app */ - id: string; + id: Snowflake; /** * The name of the app */ @@ -63,11 +64,11 @@ export interface APIApplication { /** * If this application is a game sold on Discord, this field will be the guild to which it has been linked */ - guild_id?: string; + 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?: string; + 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 */ diff --git a/v8/payloads/permissions.ts b/v8/payloads/permissions.ts index 7282a7ad..aff78f9a 100644 --- a/v8/payloads/permissions.ts +++ b/v8/payloads/permissions.ts @@ -2,6 +2,8 @@ * Types extracted from https://discord.com/developers/docs/topics/permissions */ +import type { Permissions, Snowflake } from '../../common/index'; + /** * https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags * @@ -57,7 +59,7 @@ export interface APIRole { /** * Role id */ - id: string; + id: Snowflake; /** * Role name */ @@ -79,7 +81,7 @@ export interface APIRole { * * See https://en.wikipedia.org/wiki/Bit_field */ - permissions: string; + permissions: Permissions; /** * Whether this role is managed by an integration */ @@ -101,7 +103,7 @@ export interface APIRoleTags { /** * The id of the bot this role belongs to */ - bot_id?: string; + bot_id?: Snowflake; /** * Whether this is the guild's premium subscriber role */ @@ -109,5 +111,5 @@ export interface APIRoleTags { /** * The id of the integration this role belongs to */ - integration_id?: string; + integration_id?: Snowflake; } diff --git a/v8/payloads/teams.ts b/v8/payloads/teams.ts index 2b93b255..8bc09f28 100644 --- a/v8/payloads/teams.ts +++ b/v8/payloads/teams.ts @@ -2,6 +2,7 @@ * Types extracted from https://discord.com/developers/docs/topics/teams */ +import type { Snowflake } from '../../common/index'; import type { APIUser } from './user'; /** @@ -15,7 +16,7 @@ export interface APITeam { /** * The unique id of the team */ - id: string; + id: Snowflake; /** * The members of the team */ @@ -23,7 +24,7 @@ export interface APITeam { /** * The user id of the current team owner */ - owner_user_id: string; + owner_user_id: Snowflake; } /** @@ -43,7 +44,7 @@ export interface APITeamMember { /** * The id of the parent team of which they are a member */ - team_id: string; + team_id: Snowflake; /** * The avatar, discriminator, id, and username of the user * diff --git a/v8/payloads/template.ts b/v8/payloads/template.ts index 1921aab9..c6cbcea2 100644 --- a/v8/payloads/template.ts +++ b/v8/payloads/template.ts @@ -2,6 +2,7 @@ * Types extracted from https://discord.com/developers/docs/resources/template */ +import type { Snowflake } from '../../common/index'; import type { APIUser } from './user'; import type { RESTPostAPIGuildsJSONBody } from '../rest/index'; @@ -28,7 +29,7 @@ export interface APITemplate { /** * The ID of the user who created the template */ - creator_id: string; + creator_id: Snowflake; /** * The user who created the template * @@ -46,7 +47,7 @@ export interface APITemplate { /** * The ID of the guild this template is based on */ - source_guild_id: string; + source_guild_id: Snowflake; /** * The guild snapshot this template contains */ diff --git a/v8/payloads/user.ts b/v8/payloads/user.ts index 55546052..452237f2 100644 --- a/v8/payloads/user.ts +++ b/v8/payloads/user.ts @@ -2,6 +2,7 @@ * Types extracted from https://discord.com/developers/docs/resources/user */ +import type { Snowflake } from '../../common/index'; import type { APIGuildIntegration } from './guild'; /** @@ -11,7 +12,7 @@ export interface APIUser { /** * The user's id */ - id: string; + id: Snowflake; /** * The user's username, not unique across the platform */ diff --git a/v8/payloads/voice.ts b/v8/payloads/voice.ts index 7952174b..f98882d8 100644 --- a/v8/payloads/voice.ts +++ b/v8/payloads/voice.ts @@ -2,6 +2,7 @@ * Types extracted from https://discord.com/developers/docs/resources/voice */ +import type { Snowflake } from '../../common/index'; import type { APIGuildMember } from './guild'; /** @@ -11,15 +12,15 @@ export interface GatewayVoiceState { /** * The guild id this voice state is for */ - guild_id?: string; + guild_id?: Snowflake; /** * The channel id this user is connected to */ - channel_id: string | null; + channel_id: Snowflake | null; /** * The user id this voice state is for */ - user_id: string; + user_id: Snowflake; /** * The guild member this voice state is for * diff --git a/v8/payloads/webhook.ts b/v8/payloads/webhook.ts index 2a756991..6d90857e 100644 --- a/v8/payloads/webhook.ts +++ b/v8/payloads/webhook.ts @@ -2,6 +2,7 @@ * Types extracted from https://discord.com/developers/docs/resources/webhook */ +import type { Snowflake } from '../../common/index'; import type { APIPartialChannel, APIPartialGuild, APIUser } from './index'; /** @@ -11,7 +12,7 @@ export interface APIWebhook { /** * The id of the webhook */ - id: string; + id: Snowflake; /** * The type of the webhook * @@ -21,11 +22,11 @@ export interface APIWebhook { /** * The guild id this webhook is for */ - guild_id?: string; + guild_id?: Snowflake; /** * The channel id this webhook is for */ - channel_id: string; + channel_id: Snowflake; /** * The user this webhook was created by (not returned when getting a webhook with its token) * @@ -47,7 +48,7 @@ export interface APIWebhook { /** * The bot/OAuth2 application that created this webhook */ - application_id: string | null; + application_id: Snowflake | null; source_guild?: APIPartialGuild; source_channel?: APIPartialChannel; } diff --git a/v8/rest/auditLog.ts b/v8/rest/auditLog.ts index e5aa95e8..70b006c0 100644 --- a/v8/rest/auditLog.ts +++ b/v8/rest/auditLog.ts @@ -1,3 +1,4 @@ +import type { Snowflake } from '../../common/index'; import type { APIAuditLog, AuditLogEvent } from '../payloads/auditLog'; /** @@ -7,7 +8,7 @@ export interface RESTGetAPIAuditLogQuery { /** * Filter the log for actions made by a user */ - user_id?: string; + user_id?: Snowflake; /** * The type of audit log events */ @@ -15,7 +16,7 @@ export interface RESTGetAPIAuditLogQuery { /** * Filter the log before a certain entry ID */ - before?: string; + before?: Snowflake; /** * How many entries are returned (default 50, minimum 1, maximum 100) * diff --git a/v8/rest/channel.ts b/v8/rest/channel.ts index a58acfaa..13b955e7 100644 --- a/v8/rest/channel.ts +++ b/v8/rest/channel.ts @@ -1,3 +1,4 @@ +import type { Permissions, Snowflake } from '../../common/index'; import type { APIAllowedMentions, APIChannel, @@ -86,7 +87,7 @@ export interface RESTPatchAPIChannelJSONBody { * * Channel types: text, news, store, voice */ - parent_id?: string | null; + parent_id?: Snowflake | null; } /** @@ -106,15 +107,15 @@ export interface RESTGetAPIChannelMessagesQuery { /** * Get messages around this message ID */ - around?: string; + around?: Snowflake; /** * Get messages before this message ID */ - before?: string; + before?: Snowflake; /** * Get messages after this message ID */ - after?: string; + after?: Snowflake; /** * Max number of messages to return (1-100) * @@ -224,11 +225,11 @@ export interface RESTGetAPIChannelMessageReactionUsersQuery { /** * Get users before this user ID */ - before?: string; + before?: Snowflake; /** * Get users after this user ID */ - after?: string; + after?: Snowflake; /** * Max number of users to return (1-100) * @@ -294,7 +295,7 @@ export interface RESTPostAPIChannelMessagesBulkDeleteJSONBody { /** * An array of message ids to delete (2-100) */ - messages: string[]; + messages: Snowflake[]; } /** @@ -311,13 +312,13 @@ export interface RESTPutAPIChannelPermissionJSONBody { * * See https://en.wikipedia.org/wiki/Bit_field */ - allow: string; + allow: Permissions; /** * The bitwise value of all disallowed permissions * * See https://en.wikipedia.org/wiki/Bit_field */ - deny: string; + deny: Permissions; /** * `0` for a role or `1` for a member */ @@ -390,7 +391,7 @@ export interface RESTPostAPIChannelFollowersJSONBody { /** * ID of target channel */ - webhook_channel_id: string; + webhook_channel_id: Snowflake; } /** diff --git a/v8/rest/emoji.ts b/v8/rest/emoji.ts index ac469fc1..9c895fd9 100644 --- a/v8/rest/emoji.ts +++ b/v8/rest/emoji.ts @@ -1,3 +1,4 @@ +import type { Snowflake } from '../../common/index'; import type { APIEmoji } from '../payloads/index'; /** @@ -27,7 +28,7 @@ export interface RESTPostAPIGuildEmojiJSONBody { /** * Roles for which this emoji will be whitelisted */ - roles?: string[]; + roles?: Snowflake[]; } /** @@ -46,7 +47,7 @@ export interface RESTPatchAPIGuildEmojiJSONBody { /** * Roles for which this emoji will be whitelisted */ - roles?: string[] | null; + roles?: Snowflake[] | null; } /** diff --git a/v8/rest/guild.ts b/v8/rest/guild.ts index 18426ce4..9804a974 100644 --- a/v8/rest/guild.ts +++ b/v8/rest/guild.ts @@ -1,3 +1,4 @@ +import type { Permissions, Snowflake } from '../../common/index'; import type { APIBan, APIChannel, @@ -105,7 +106,7 @@ export interface RESTPostAPIGuildsJSONBody { /** * ID for afk channel */ - afk_channel_id?: number | string; + afk_channel_id?: number | Snowflake; /** * AFK timeout in seconds */ @@ -113,7 +114,7 @@ export interface RESTPostAPIGuildsJSONBody { /** * The id of the channel where guild notices such as welcome messages and boost events are posted */ - system_channel_id?: number | string; + system_channel_id?: number | Snowflake; /** * System channel flags * @@ -184,7 +185,7 @@ export interface RESTPatchAPIGuildJSONBody { /** * ID for afk channel */ - afk_channel_id?: string | null; + afk_channel_id?: Snowflake | null; /** * AFK timeout in seconds */ @@ -198,7 +199,7 @@ export interface RESTPatchAPIGuildJSONBody { /** * User id to transfer guild ownership to (must be owner) */ - owner_id?: string; + owner_id?: Snowflake; /** * base64 16:9 png/jpeg image for the guild splash (when the guild has `INVITE_SPLASH` feature) * @@ -216,7 +217,7 @@ export interface RESTPatchAPIGuildJSONBody { /** * The id of the channel where guild notices such as welcome messages and boost events are posted */ - system_channel_id?: string | null; + system_channel_id?: Snowflake | null; /** * System channel flags * @@ -226,11 +227,11 @@ export interface RESTPatchAPIGuildJSONBody { /** * The id of the channel where Community guilds display rules and/or guidelines */ - rules_channel_id?: string | null; + rules_channel_id?: Snowflake | null; /** * The id of the channel where admins and moderators of Community guilds receive notices from Discord */ - public_updates_channel_id?: string | null; + public_updates_channel_id?: Snowflake | null; /** * The preferred locale of a Community guild used in server discovery and notices from Discord; defaults to "en-US" * @@ -281,7 +282,7 @@ export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{ /** * Channel id */ - id: string; + id: Snowflake; /** * Sorting position of the channel */ @@ -293,7 +294,7 @@ export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{ /** * The new parent id of this channel */ - parent_id?: string | null; + parent_id?: Snowflake | null; }>; /** @@ -321,7 +322,7 @@ export interface RESTGetAPIGuildMembersQuery { * * @default 0 */ - after?: string; + after?: Snowflake; } /** @@ -363,7 +364,7 @@ export interface RESTPutAPIGuildMemberJSONBody { * * Requires `MANAGE_ROLES` permission */ - roles?: string[]; + roles?: Snowflake[]; /** * Whether the user is muted in voice channels * @@ -395,7 +396,7 @@ export interface RESTPatchAPIGuildMemberJSONBody { * * Requires `MANAGE_ROLES` permission */ - roles?: string[] | null; + roles?: Snowflake[] | null; /** * Whether the user is muted in voice channels. Will throw a 400 if the user is not in a voice channel * @@ -413,7 +414,7 @@ export interface RESTPatchAPIGuildMemberJSONBody { * * Requires `MOVE_MEMBERS` permission */ - channel_id?: string | null; + channel_id?: Snowflake | null; } /** @@ -507,7 +508,7 @@ export interface RESTPostAPIGuildRoleJSONBody { * * @default "​default role permissions in guild" */ - permissions?: string | null; + permissions?: Permissions | null; /** * RGB color value * @@ -540,7 +541,7 @@ export type RESTPatchAPIGuildRolePositionsJSONBody = Array<{ /** * Role id */ - id: string; + id: Snowflake; /** * Sorting position of the role */ @@ -563,7 +564,7 @@ export interface RESTPatchAPIGuildRoleJSONBody { /** * Bitwise value of the enabled/disabled permissions */ - permissions?: string | null; + permissions?: Permissions | null; /** * RGB color value */ @@ -635,7 +636,7 @@ export interface RESTPostAPIGuildPruneJSONBody { /** * Role(s) to include */ - include_roles?: string[]; + include_roles?: Snowflake[]; } /** @@ -665,7 +666,7 @@ export type RESTGetAPIGuildIntegrationsResult = APIGuildIntegration[]; */ export interface RESTPostAPIGuildIntegrationJSONBody { type: string; - id: string; + id: Snowflake; } export type RESTPostAPIGuildIntegrationResult = never; diff --git a/v8/rest/index.ts b/v8/rest/index.ts index a5e0da04..0a7f36bb 100644 --- a/v8/rest/index.ts +++ b/v8/rest/index.ts @@ -1,3 +1,5 @@ +import type { Snowflake } from '../../common/index'; + export * from './auditLog'; export * from './channel'; export * from './emoji'; @@ -17,7 +19,7 @@ export const Routes = { * Route for: * - GET `/guilds/{guild.id}/audit-logs` */ - guildAuditLog(guildID: string) { + guildAuditLog(guildID: Snowflake) { return `/guilds/${guildID}/audit-logs`; }, @@ -27,7 +29,7 @@ export const Routes = { * - PATCH `/channels/{channel.id}` * - DELETE `/channels/{channel.id}` */ - channel(channelID: string) { + channel(channelID: Snowflake) { return `/channels/${channelID}`; }, @@ -36,7 +38,7 @@ export const Routes = { * - GET `/channels/{channel.id}/messages` * - POST `/channels/{channel.id}/messages` */ - channelMessages(channelID: string) { + channelMessages(channelID: Snowflake) { return `/channels/${channelID}/messages`; }, @@ -46,7 +48,7 @@ export const Routes = { * - PATCH `/channels/{channel.id}/messages/{message.id}` * - DELETE `/channels/{channel.id}/messages/{message.id}` */ - channelMessage(channelID: string, messageID: string) { + channelMessage(channelID: Snowflake, messageID: Snowflake) { return `/channels/${channelID}/messages/${messageID}`; }, @@ -54,7 +56,7 @@ export const Routes = { * Route for: * - POST `/channels/{channel.id}/messages/{message.id}/crosspost` */ - channelMessageCrosspost(channelID: string, messageID: string) { + channelMessageCrosspost(channelID: Snowflake, messageID: Snowflake) { return `/channels/${channelID}/messages/${messageID}/crosspost`; }, @@ -65,7 +67,7 @@ export const Routes = { * * **Note**: You need to URL encode the emoji yourself */ - channelMessageOwnReaction(channelID: string, messageID: string, emoji: string) { + channelMessageOwnReaction(channelID: Snowflake, messageID: Snowflake, emoji: string) { return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/@me`; }, @@ -75,7 +77,7 @@ export const Routes = { * * **Note**: You need to URL encode the emoji yourself */ - channelMessageUserReaction(channelID: string, messageID: string, emoji: string, userID: string) { + channelMessageUserReaction(channelID: Snowflake, messageID: Snowflake, emoji: string, userID: Snowflake) { return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/${userID}`; }, @@ -86,7 +88,7 @@ export const Routes = { * * **Note**: You need to URL encode the emoji yourself */ - channelMessageReaction(channelID: string, messageID: string, emoji: string) { + channelMessageReaction(channelID: Snowflake, messageID: Snowflake, emoji: string) { return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}`; }, @@ -94,7 +96,7 @@ export const Routes = { * Route for: * - DELETE `/channels/{channel.id}/messages/{message.id}/reactions` */ - channelMessageAllReactions(channelID: string, messageID: string) { + channelMessageAllReactions(channelID: Snowflake, messageID: Snowflake) { return `/channels/${channelID}/messages/${messageID}/reactions`; }, @@ -102,7 +104,7 @@ export const Routes = { * Route for: * - POST `/channels/{channel.id}/messages/bulk-delete` */ - channelBulkDelete(channelID: string) { + channelBulkDelete(channelID: Snowflake) { return `/channels/${channelID}/messages/bulk-delete`; }, @@ -111,7 +113,7 @@ export const Routes = { * - PUT `/channels/{channel.id}/permissions/{overwrite.id}` * - DELETE `/channels/{channel.id}/permissions/{overwrite.id}` */ - channelPermission(channelID: string, overwriteID: string) { + channelPermission(channelID: Snowflake, overwriteID: Snowflake) { return `/channels/${channelID}/permissions/${overwriteID}`; }, @@ -120,7 +122,7 @@ export const Routes = { * - GET `/channels/{channel.id}/invites` * - POST `/channels/{channel.id}/invites` */ - channelInvites(channelID: string) { + channelInvites(channelID: Snowflake) { return `/channels/${channelID}/invites`; }, @@ -128,7 +130,7 @@ export const Routes = { * Route for: * - POST `/channels/{channel.id}/followers` */ - channelFollowers(channelID: string) { + channelFollowers(channelID: Snowflake) { return `/channels/${channelID}/followers`; }, @@ -136,7 +138,7 @@ export const Routes = { * Route for: * - POST `/channels/{channel.id}/typing` */ - channelTyping(channelID: string) { + channelTyping(channelID: Snowflake) { return `/channels/${channelID}/typing`; }, @@ -144,7 +146,7 @@ export const Routes = { * Route for: * - GET `/channels/{channel.id}/pins` */ - channelPins(channelID: string) { + channelPins(channelID: Snowflake) { return `/channels/${channelID}/pins`; }, @@ -153,7 +155,7 @@ export const Routes = { * - PUT `/channels/{channel.id}/pins/{message.id}` * - DELETE `/channels/{channel.id}/pins/{message.id}` */ - channelPin(channelID: string, messageID: string) { + channelPin(channelID: Snowflake, messageID: Snowflake) { return `/channels/${channelID}/pins/${messageID}`; }, @@ -162,7 +164,7 @@ export const Routes = { * - PUT `/channels/{channel.id}/recipients/{user.id}` * - DELETE `/channels/{channel.id}/recipients/{user.id}` */ - channelRecipient(channelID: string, userID: string) { + channelRecipient(channelID: Snowflake, userID: Snowflake) { return `/channels/${channelID}/recipients/${userID}`; }, @@ -171,7 +173,7 @@ export const Routes = { * - GET `/guilds/{guild.id}/emojis` * - POST `/guilds/{guild.id}/emojis` */ - guildEmojis(guildID: string) { + guildEmojis(guildID: Snowflake) { return `/guilds/${guildID}/emojis`; }, @@ -181,7 +183,7 @@ export const Routes = { * - PATCH `/guilds/{guild.id}/emojis/{emoji.id}` * - DELETE `/guilds/{guild.id}/emojis/{emoji.id}` */ - guildEmoji(guildID: string, emojiID: string) { + guildEmoji(guildID: Snowflake, emojiID: Snowflake) { return `/guilds/${guildID}/emojis/${emojiID}`; }, @@ -199,7 +201,7 @@ export const Routes = { * - PATCH `/guilds/{guild.id}` * - DELETE `/guilds/{guild.id}` */ - guild(guildID: string) { + guild(guildID: Snowflake) { return `/guilds/${guildID}`; }, @@ -207,7 +209,7 @@ export const Routes = { * Route for: * - GET `/guilds/{guild.id}/preview` */ - guildPreview(guildID: string) { + guildPreview(guildID: Snowflake) { return `/guilds/${guildID}/preview`; }, @@ -217,7 +219,7 @@ export const Routes = { * - POST `/guilds/{guild.id}/channels` * - PATCH `/guilds/{guild.id}/channels` */ - guildChannels(guildID: string) { + guildChannels(guildID: Snowflake) { return `/guilds/${guildID}/channels`; }, @@ -228,7 +230,7 @@ export const Routes = { * - PATCH `/guilds/{guild.id}/members/{user.id}` * - DELETE `/guilds/{guild.id}/members/{user.id}` */ - guildMember(guildID: string, userID: string) { + guildMember(guildID: Snowflake, userID: Snowflake) { return `/guilds/${guildID}/members/${userID}`; }, @@ -236,7 +238,7 @@ export const Routes = { * Route for: * - GET `/guilds/{guild.id}/members` */ - guildMembers(guildID: string) { + guildMembers(guildID: Snowflake) { return `/guilds/${guildID}/members`; }, @@ -244,7 +246,7 @@ export const Routes = { * Route for: * - GET `/guilds/{guild.id}/members/search` */ - guildMembersSearch(guildID: string) { + guildMembersSearch(guildID: Snowflake) { return `/guilds/${guildID}/members/search`; }, @@ -252,7 +254,7 @@ export const Routes = { * Route for: * - PATCH `/guilds/{guild.id}/members/@me/nick` */ - guildCurrentMemberNickname(guildID: string) { + guildCurrentMemberNickname(guildID: Snowflake) { return `/guilds/${guildID}/members/@me/nick`; }, @@ -261,7 +263,7 @@ export const Routes = { * - PUT `/guilds/{guild.id}/members/{user.id}/roles/{role.id}` * - DELETE `/guilds/{guild.id}/members/{user.id}/roles/{role.id}` */ - guildMemberRole(guildID: string, memberID: string, roleID: string) { + guildMemberRole(guildID: Snowflake, memberID: Snowflake, roleID: Snowflake) { return `/guilds/${guildID}/members/${memberID}/roles/${roleID}`; }, @@ -269,7 +271,7 @@ export const Routes = { * Route for: * - GET `/guilds/{guild.id}/bans` */ - guildBans(guildID: string) { + guildBans(guildID: Snowflake) { return `/guilds/${guildID}/bans`; }, @@ -279,7 +281,7 @@ export const Routes = { * - PUT `/guilds/{guild.id}/bans/{user.id}` * - DELETE `/guilds/{guild.id}/bans/{user.id}` */ - guildBan(guildID: string, userID: string) { + guildBan(guildID: Snowflake, userID: Snowflake) { return `/guilds/${guildID}/bans/${userID}`; }, @@ -289,7 +291,7 @@ export const Routes = { * - POST `/guilds/{guild.id}/roles` * - PATCH `/guilds/{guild.id}/roles` */ - guildRoles(guildID: string) { + guildRoles(guildID: Snowflake) { return `/guilds/${guildID}/roles`; }, @@ -298,7 +300,7 @@ export const Routes = { * - PATCH `/guilds/{guild.id}/roles/{role.id}` * - DELETE `/guilds/{guild.id}/roles/{role.id}` */ - guildRole(guildID: string, roleID: string) { + guildRole(guildID: Snowflake, roleID: Snowflake) { return `/guilds/${guildID}/roles/${roleID}`; }, @@ -307,7 +309,7 @@ export const Routes = { * - GET `/guilds/{guild.id}/prune` * - POST `/guilds/{guild.id}/prune` */ - guildPrune(guildID: string) { + guildPrune(guildID: Snowflake) { return `/guilds/${guildID}/prune`; }, @@ -315,7 +317,7 @@ export const Routes = { * Route for: * - GET `/guilds/{guild.id}/regions` */ - guildVoiceRegions(guildID: string) { + guildVoiceRegions(guildID: Snowflake) { return `/guilds/${guildID}/regions`; }, @@ -323,7 +325,7 @@ export const Routes = { * Route for: * - GET `/guilds/{guild.id}/invites` */ - guildInvites(guildID: string) { + guildInvites(guildID: Snowflake) { return `/guilds/${guildID}/invites`; }, @@ -332,7 +334,7 @@ export const Routes = { * - GET `/guilds/{guild.id}/integrations` * - POST `/guilds/{guild.id}/integrations` */ - guildIntegrations(guildID: string) { + guildIntegrations(guildID: Snowflake) { return `/guilds/${guildID}/integrations`; }, @@ -341,7 +343,7 @@ export const Routes = { * - PATCH `/guilds/{guild.id}/integrations/{integration.id}` * - DELETE `/guilds/{guild.id}/integrations/{integration.id}` */ - guildIntegration(guildID: string, integrationID: string) { + guildIntegration(guildID: Snowflake, integrationID: Snowflake) { return `/guilds/${guildID}/integrations/${integrationID}`; }, @@ -349,7 +351,7 @@ export const Routes = { * Route for: * - POST `/guilds/{guild.id}/integrations/{integration.id}/sync` */ - guildIntegrationSync(guildID: string, integrationID: string) { + guildIntegrationSync(guildID: Snowflake, integrationID: Snowflake) { return `/guilds/${guildID}/integrations/${integrationID}/sync`; }, @@ -358,7 +360,7 @@ export const Routes = { * - GET `/guilds/{guild.id}/widget` * - PATCH `/guilds/{guild.id}/widget` */ - guildWidgetSettings(guildID: string) { + guildWidgetSettings(guildID: Snowflake) { return `/guilds/${guildID}/widget`; }, @@ -366,7 +368,7 @@ export const Routes = { * Route for: * - GET `/guilds/{guild.id}/widget.json` */ - guildWidgetJSON(guildID: string) { + guildWidgetJSON(guildID: Snowflake) { return `/guilds/${guildID}/widget.json`; }, @@ -374,7 +376,7 @@ export const Routes = { * Route for: * - GET `/guilds/{guild.id}/vanity-url` */ - guildVanityUrl(guildID: string) { + guildVanityUrl(guildID: Snowflake) { return `/guilds/${guildID}/vanity-url`; }, @@ -382,7 +384,7 @@ export const Routes = { * Route for: * - GET `/guilds/{guild.id}/widget.png` */ - guildWidgetImage(guildID: string) { + guildWidgetImage(guildID: Snowflake) { return `/guilds/${guildID}/widget.png`; }, @@ -409,7 +411,7 @@ export const Routes = { * - GET `/guilds/{guild.id}/templates` * - POST `/guilds/{guild.id}/templates` */ - guildTemplates(guildID: string) { + guildTemplates(guildID: Snowflake) { return `/guilds/${guildID}/templates`; }, @@ -419,7 +421,7 @@ export const Routes = { * - PATCH `/guilds/{guild.id}/templates/{template.code}` * - DELETE `/guilds/{guild.id}/templates/{template.code}` */ - guildTemplate(guildID: string, code: string) { + guildTemplate(guildID: Snowflake, code: string) { return `/guilds/${guildID}/templates/${code}`; }, @@ -447,7 +449,7 @@ export const Routes = { * Route for: * - DELETE `/users/@me/guilds/{guild.id}` */ - userGuild(guildID: string) { + userGuild(guildID: Snowflake) { return `/users/@me/guilds/${guildID}`; }, @@ -480,7 +482,7 @@ export const Routes = { * - GET `/channels/{channel.id}/webhooks` * - POST `/channels/{channel.id}/webhooks` */ - channelWebhooks(channelID: string) { + channelWebhooks(channelID: Snowflake) { return `/channels/${channelID}/webhooks`; }, @@ -488,7 +490,7 @@ export const Routes = { * Route for: * - GET `/guilds/{guild.id}/webhooks` */ - guildWebhooks(guildID: string) { + guildWebhooks(guildID: Snowflake) { return `/guilds/${guildID}/webhooks`; }, @@ -504,7 +506,7 @@ export const Routes = { * * - POST `/webhooks/{application.id}/{interaction.token}` */ - webhook(webhookID: string, webhookToken?: string) { + webhook(webhookID: Snowflake, webhookToken?: string) { const parts = ['', 'webhooks', webhookID]; if (webhookToken) parts.push(webhookToken); @@ -525,7 +527,7 @@ export const Routes = { * * @param [messageID='@original'] The message ID to change, defaulted to `@original` */ - webhookMessage(webhookID: string, webhookToken: string, messageID = '@original') { + webhookMessage(webhookID: Snowflake, webhookToken: string, messageID = '@original') { return `/webhooks/${webhookID}/${webhookToken}/messages/${messageID}`; }, @@ -534,7 +536,7 @@ export const Routes = { * - POST `/webhooks/{webhook.id}/{webhook.token}/github` * - POST `/webhooks/{webhook.id}/{webhook.token}/slack` */ - webhookPlatform(webhookID: string, webhookToken: string, platform: 'github' | 'slack') { + webhookPlatform(webhookID: Snowflake, webhookToken: string, platform: 'github' | 'slack') { return `/webhooks/${webhookID}/${webhookToken}/${platform}`; }, @@ -567,7 +569,7 @@ export const Routes = { * - GET `/applications/{application.id}/commands` * - POST `/applications/{application.id}/commands` */ - applicationCommands(applicationID: string) { + applicationCommands(applicationID: Snowflake) { return `/applications/${applicationID}/commands`; }, @@ -576,7 +578,7 @@ export const Routes = { * - PATCH `/applications/{application.id}/commands/{command.id}` * - DELETE `/applications/{application.id}/commands/{command.id}` */ - applicationCommand(applicationID: string, commandID: string) { + applicationCommand(applicationID: Snowflake, commandID: Snowflake) { return `/applications/${applicationID}/commands/${commandID}`; }, @@ -585,7 +587,7 @@ export const Routes = { * - GET `/applications/{application.id}/guilds/{guild.id}/commands` * - POST `/applications/{application.id}/guilds/{guild.id}/commands` */ - applicationGuildCommands(applicationID: string, guildID: string) { + applicationGuildCommands(applicationID: Snowflake, guildID: Snowflake) { return `/applications/${applicationID}/guilds/${guildID}/commands`; }, @@ -594,7 +596,7 @@ export const Routes = { * - PATCH `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}` * - DELETE `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}` */ - applicationGuildCommand(applicationID: string, guildID: string, commandID: string) { + applicationGuildCommand(applicationID: Snowflake, guildID: Snowflake, commandID: Snowflake) { return `/applications/${applicationID}/guilds/${guildID}/commands/${commandID}`; }, @@ -602,7 +604,7 @@ export const Routes = { * Route for: * - POST `/interactions/{interaction.id}/{interaction.token}/callback` */ - interactionCallback(interactionID: string, interactionToken: string) { + interactionCallback(interactionID: Snowflake, interactionToken: string) { return `/interactions/${interactionID}/${interactionToken}/callback`; }, @@ -611,7 +613,7 @@ export const Routes = { * - GET `/guilds/{guild.id}/member-verification` * - PATCH `/guilds/{guild.id}/member-verification` */ - guildMemberVerification(guildID: string) { + guildMemberVerification(guildID: Snowflake) { return `/guilds/${guildID}/member-verification`; }, }; diff --git a/v8/rest/oauth2.ts b/v8/rest/oauth2.ts index 60cf533a..0eeb6869 100644 --- a/v8/rest/oauth2.ts +++ b/v8/rest/oauth2.ts @@ -1,3 +1,4 @@ +import type { Permissions, Snowflake } from '../../common/index'; import type { APIApplication, APIGuild, APIWebhook, OAuth2Scopes } from '../payloads/index'; /** @@ -10,7 +11,7 @@ export type RESTGetAPIOauth2CurrentApplicationResult = Omit