chore: bring in support for TS 4.5's exactOptionalPropertyTypes (#275)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Vlad Frangu
2021-12-24 17:08:58 +02:00
committed by GitHub
parent 7fe78cec25
commit c20e5ae2a9
62 changed files with 5217 additions and 4132 deletions

View File

@@ -540,7 +540,7 @@ export type APIAuditLogChangeKeyExpireGracePeriod = AuditLogChangeData<'expire_g
* @internal
* @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8.
*/
interface AuditLogChangeData<K extends string, D extends unknown> {
interface AuditLogChangeData<K extends string, D> {
key: K;
new_value?: D;
old_value?: D;

View File

@@ -39,7 +39,7 @@ export interface APIInteractionGuildMember extends APIGuildMember {
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export interface APIBaseInteraction<Type extends InteractionType, Data extends unknown> {
export interface APIBaseInteraction<Type extends InteractionType, Data> {
/**
* ID of the interaction
*/

View File

@@ -644,7 +644,7 @@ export type APIAuditLogChangeKeyStatus = AuditLogChangeData<'status', GuildSched
*/
export type APIAuditLogChangeKeyLocation = AuditLogChangeData<'location', string>;
interface AuditLogChangeData<K extends string, D extends unknown> {
interface AuditLogChangeData<K extends string, D> {
key: K;
/**
* The new value

View File

@@ -1,4 +1,5 @@
import type { APIUser } from './user.ts';
import type { APIGuildMember } from './guild.ts';
import type { Snowflake } from '../../globals.ts';
export interface APIGuildScheduledEvent {
@@ -102,3 +103,21 @@ export enum GuildScheduledEventPrivacyLevel {
*/
GuildOnly = 2,
}
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-user-object-guild-scheduled-event-user-structure
*/
export interface APIGuildScheduledEventUser {
/**
* The scheduled event id which the user subscribed to
*/
guild_scheduled_event_id: Snowflake;
/**
* The user which subscribed to the event
*/
user: APIUser;
/**
* The guild member data for this user for the guild which this event belongs to, if any
*/
member?: APIGuildMember;
}

View File

@@ -39,7 +39,7 @@ export interface APIInteractionGuildMember extends APIGuildMember {
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export interface APIBaseInteraction<Type extends InteractionType, Data extends unknown> {
export interface APIBaseInteraction<Type extends InteractionType, Data> {
/**
* ID of the interaction
*/

View File

@@ -683,7 +683,7 @@ export type APIAuditLogChangeKeyStatus = AuditLogChangeData<'status', GuildSched
*/
export type APIAuditLogChangeKeyLocation = AuditLogChangeData<'location', string>;
interface AuditLogChangeData<K extends string, D extends unknown> {
interface AuditLogChangeData<K extends string, D> {
key: K;
/**
* The new value

View File

@@ -1,4 +1,5 @@
import type { APIUser } from './user.ts';
import type { APIGuildMember } from './guild.ts';
import type { Snowflake } from '../../globals.ts';
export interface APIGuildScheduledEvent {
@@ -102,3 +103,21 @@ export enum GuildScheduledEventPrivacyLevel {
*/
GuildOnly = 2,
}
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-user-object-guild-scheduled-event-user-structure
*/
export interface APIGuildScheduledEventUser {
/**
* The scheduled event id which the user subscribed to
*/
guild_scheduled_event_id: Snowflake;
/**
* The user which subscribed to the event
*/
user: APIUser;
/**
* The guild member data for this user for the guild which this event belongs to, if any
*/
member?: APIGuildMember;
}

View File

@@ -17,6 +17,7 @@ import type {
OverwriteType,
VideoQualityMode,
} from '../../payloads/v8/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals.ts';
/**
* https://discord.com/developers/docs/resources/channel#get-channel
@@ -26,7 +27,7 @@ export type RESTGetAPIChannelResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/channel#modify-channel
*/
export interface RESTPatchAPIChannelJSONBody {
export type RESTPatchAPIChannelJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* 1-100 character channel name
*
@@ -103,7 +104,7 @@ export interface RESTPatchAPIChannelJSONBody {
* See https://discord.com/developers/docs/resources/channel#channel-object-video-quality-modes
*/
video_quality_mode?: VideoQualityMode | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#modify-channel
@@ -152,20 +153,21 @@ export type RESTGetAPIChannelMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
*/
export type APIMessageReferenceSend = Partial<APIMessageReference> &
Required<Pick<APIMessageReference, 'message_id'>> & {
export type APIMessageReferenceSend = StrictPartial<APIMessageReference> &
Required<Pick<APIMessageReference, 'message_id'>> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message
*
* @default true
*/
fail_if_not_exists?: boolean;
};
}>;
/**
* https://discord.com/developers/docs/resources/channel#create-message
*/
export interface RESTPostAPIChannelMessageJSONBody {
export type RESTPostAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The message contents (up to 2000 characters)
*/
@@ -188,6 +190,7 @@ export interface RESTPostAPIChannelMessageJSONBody {
* Embedded `rich` content
*
* See https://discord.com/developers/docs/resources/channel#embed-object
* @deprecated Use `embeds` instead
*/
embed?: APIEmbed;
/**
@@ -218,7 +221,7 @@ export interface RESTPostAPIChannelMessageJSONBody {
* Attachment objects with filename and description
*/
attachments?: (Pick<APIAttachment, 'id' | 'description'> & Partial<Pick<APIAttachment, 'filename'>>)[];
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#create-message
@@ -291,7 +294,7 @@ export type RESTDeleteAPIChannelMessageReactionResult = never;
/**
* https://discord.com/developers/docs/resources/channel#edit-message
*/
export interface RESTPatchAPIChannelMessageJSONBody {
export type RESTPatchAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The new message contents (up to 2000 characters)
*/
@@ -338,7 +341,7 @@ export interface RESTPatchAPIChannelMessageJSONBody {
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent[] | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#edit-message
@@ -351,6 +354,7 @@ export type RESTPatchAPIChannelMessageFormDataBody =
payload_json?: string;
} & Record<`files[${bigint}]`, unknown>)
| (RESTPatchAPIChannelMessageJSONBody & Record<`files[${bigint}]`, unknown>);
/**
* https://discord.com/developers/docs/resources/channel#edit-message
*/
@@ -411,7 +415,7 @@ export type RESTGetAPIChannelInvitesResult = APIExtendedInvite[];
/**
* https://discord.com/developers/docs/resources/channel#create-channel-invite
*/
export interface RESTPostAPIChannelInviteJSONBody {
export type RESTPostAPIChannelInviteJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Duration of invite in seconds before expiry, or 0 for never
*
@@ -455,7 +459,7 @@ export interface RESTPostAPIChannelInviteJSONBody {
* - The application must have the `EMBEDDED` flag
*/
target_application_id?: Snowflake;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#create-channel-invite
@@ -505,7 +509,7 @@ export type RESTDeleteAPIChannelPinResult = never;
/**
* https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
*/
export interface RESTPutAPIChannelRecipientJSONBody {
export type RESTPutAPIChannelRecipientJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Access token of a user that has granted your app the `gdm.join` scope
*/
@@ -514,7 +518,7 @@ export interface RESTPutAPIChannelRecipientJSONBody {
* Nickname of the user being added
*/
nick?: string;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#group-dm-add-recipient

View File

@@ -1,5 +1,6 @@
import type { Snowflake } from '../../globals.ts';
import type { APIEmoji } from '../../payloads/v8/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface } from '../../utils/internals.ts';
/**
* https://discord.com/developers/docs/resources/emoji#list-guild-emojis
@@ -14,7 +15,7 @@ export type RESTGetAPIGuildEmojiResult = APIEmoji;
/**
* https://discord.com/developers/docs/resources/emoji#create-guild-emoji-json-params
*/
export interface RESTPostAPIGuildEmojiJSONBody {
export type RESTPostAPIGuildEmojiJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the emoji
*/
@@ -29,7 +30,7 @@ export interface RESTPostAPIGuildEmojiJSONBody {
* Roles for which this emoji will be whitelisted
*/
roles?: Snowflake[];
}
}>;
/**
* https://discord.com/developers/docs/resources/emoji#create-guild-emoji
@@ -39,7 +40,7 @@ export type RESTPostAPIGuildEmojiResult = APIEmoji;
/**
* https://discord.com/developers/docs/resources/emoji#modify-guild-emoji
*/
export interface RESTPatchAPIGuildEmojiJSONBody {
export type RESTPatchAPIGuildEmojiJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the emoji
*/
@@ -48,7 +49,7 @@ export interface RESTPatchAPIGuildEmojiJSONBody {
* Roles for which this emoji will be whitelisted
*/
roles?: Snowflake[] | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/emoji#modify-guild-emoji

View File

@@ -20,21 +20,27 @@ import type {
GuildVerificationLevel,
GuildWidgetStyle,
} from '../../payloads/v8/mod.ts';
import type { Nullable } from '../../utils/internals.ts';
import type {
AddUndefinedToPossiblyUndefinedPropertiesOfInterface,
Nullable,
StrictPartial,
StrictRequired,
} from '../../utils/internals.ts';
import type { RESTPutAPIChannelPermissionJSONBody } from './channel.ts';
export interface APIGuildCreateOverwrite extends RESTPutAPIChannelPermissionJSONBody {
id: number | string;
}
export type APIGuildCreatePartialChannel = Partial<
export type APIGuildCreatePartialChannel = StrictPartial<
Pick<APIChannel, 'type' | 'topic' | 'nsfw' | 'bitrate' | 'user_limit' | 'rate_limit_per_user'>
> & {
name: string;
id?: number | string;
parent_id?: number | string | null;
permission_overwrites?: APIGuildCreateOverwrite[];
};
> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
name: string;
id?: number | string;
parent_id?: number | string | null;
permission_overwrites?: APIGuildCreateOverwrite[];
}>;
export interface APIGuildCreateRole extends RESTPostAPIGuildRoleJSONBody {
id: number | string;
@@ -43,7 +49,7 @@ export interface APIGuildCreateRole extends RESTPostAPIGuildRoleJSONBody {
/**
* https://discord.com/developers/docs/resources/guild#create-guild
*/
export interface RESTPostAPIGuildsJSONBody {
export type RESTPostAPIGuildsJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the guild (2-100 characters)
*/
@@ -126,7 +132,7 @@ export interface RESTPostAPIGuildsJSONBody {
* Whether the boosts progress bar should be enabled.
*/
premium_progress_bar_enabled?: boolean;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#create-guild
@@ -158,7 +164,7 @@ export type RESTGetAPIGuildPreviewResult = APIGuildPreview;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild
*/
export interface RESTPatchAPIGuildJSONBody {
export type RESTPatchAPIGuildJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* New name for the guild (2-100 characters)
*/
@@ -257,7 +263,7 @@ export interface RESTPatchAPIGuildJSONBody {
* Whether the boosts progress bar should be enabled.
*/
premium_progress_bar_enabled?: boolean;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild
@@ -287,24 +293,26 @@ export type RESTPostAPIGuildChannelResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions
*/
export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{
/**
* Channel id
*/
id: Snowflake;
/**
* Sorting position of the channel
*/
position: number;
/**
* Sync channel overwrites with the new parent, when moving to a new `parent_id`
*/
lock_permissions?: boolean;
/**
* The new parent id of this channel
*/
parent_id?: Snowflake | null;
}>;
export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Channel id
*/
id: Snowflake;
/**
* Sorting position of the channel
*/
position: number;
/**
* Sync channel overwrites with the new parent, when moving to a new `parent_id`
*/
lock_permissions?: boolean;
/**
* The new parent id of this channel
*/
parent_id?: Snowflake | null;
}>
>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions
@@ -360,7 +368,7 @@ export type RESTGetAPIGuildMembersSearchResult = APIGuildMember[];
/**
* https://discord.com/developers/docs/resources/guild#add-guild-member
*/
export interface RESTPutAPIGuildMemberJSONBody {
export type RESTPutAPIGuildMemberJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* An oauth2 access token granted with the `guilds.join` to the bot's application for the user you want to add to the guild
*/
@@ -389,14 +397,14 @@ export interface RESTPutAPIGuildMemberJSONBody {
* Requires `DEAFEN_MEMBERS` permission
*/
deaf?: boolean;
}
}>;
export type RESTPutAPIGuildMemberResult = APIGuildMember | undefined;
export type RESTPutAPIGuildMemberResult = APIGuildMember | never;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-member
*/
export interface RESTPatchAPIGuildMemberJSONBody {
export type RESTPatchAPIGuildMemberJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Value to set users nickname to
*
@@ -427,7 +435,7 @@ export interface RESTPatchAPIGuildMemberJSONBody {
* Requires `MOVE_MEMBERS` permission
*/
channel_id?: Snowflake | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#add-guild-member
@@ -437,19 +445,20 @@ export type RESTPatchAPIGuildMemberResult = APIGuildMember;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-nick
*/
export interface RESTPatchAPICurrentGuildMemberNicknameJSONBody {
export type RESTPatchAPICurrentGuildMemberNicknameJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Value to set users nickname to
*
* Requires `CHANGE_NICKNAME` permission
*/
nick?: string | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-nick
*/
export type RESTPatchAPICurrentGuildMemberNicknameResult = Required<RESTPatchAPICurrentGuildMemberNicknameJSONBody>;
export type RESTPatchAPICurrentGuildMemberNicknameResult =
StrictRequired<RESTPatchAPICurrentGuildMemberNicknameJSONBody>;
/**
* https://discord.com/developers/docs/resources/guild#add-guild-member-role
@@ -479,7 +488,7 @@ export type RESTGetAPIGuildBanResult = APIBan;
/**
* https://discord.com/developers/docs/resources/guild#create-guild-ban
*/
export interface RESTPutAPIGuildBanJSONBody {
export type RESTPutAPIGuildBanJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Number of days to delete messages for (0-7)
*/
@@ -488,7 +497,7 @@ export interface RESTPutAPIGuildBanJSONBody {
* Reason for the ban
*/
reason?: string;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#create-guild-ban
@@ -508,7 +517,7 @@ export type RESTGetAPIGuildRolesResult = APIRole[];
/**
* https://discord.com/developers/docs/resources/guild#create-guild-role
*/
export interface RESTPostAPIGuildRoleJSONBody {
export type RESTPostAPIGuildRoleJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the role
*
@@ -518,7 +527,7 @@ export interface RESTPostAPIGuildRoleJSONBody {
/**
* Bitwise value of the enabled/disabled permissions
*
* @default "default role permissions in guild"
* @default "default role permissions in guild"
*/
permissions?: Permissions | null;
/**
@@ -547,7 +556,7 @@ export interface RESTPostAPIGuildRoleJSONBody {
* @default false
*/
mentionable?: boolean | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#create-guild-role
@@ -557,16 +566,18 @@ export type RESTPostAPIGuildRoleResult = APIRole;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
*/
export type RESTPatchAPIGuildRolePositionsJSONBody = Array<{
/**
* Role id
*/
id: Snowflake;
/**
* Sorting position of the role
*/
position?: number;
}>;
export type RESTPatchAPIGuildRolePositionsJSONBody = Array<
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Role id
*/
id: Snowflake;
/**
* Sorting position of the role
*/
position?: number;
}>
>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
@@ -576,7 +587,7 @@ export type RESTPatchAPIGuildRolePositionsResult = APIRole[];
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role
*/
export interface RESTPatchAPIGuildRoleJSONBody {
export type RESTPatchAPIGuildRoleJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the role
*/
@@ -605,7 +616,7 @@ export interface RESTPatchAPIGuildRoleJSONBody {
* Whether the role should be mentionable
*/
mentionable?: boolean | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role
@@ -648,7 +659,7 @@ export interface RESTGetAPIGuildPruneCountResult {
/**
* https://discord.com/developers/docs/resources/guild#begin-guild-prune
*/
export interface RESTPostAPIGuildPruneJSONBody {
export type RESTPostAPIGuildPruneJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Number of days to count prune for (1 or more)
*
@@ -665,7 +676,7 @@ export interface RESTPostAPIGuildPruneJSONBody {
* Role(s) to include
*/
include_roles?: Snowflake[];
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#begin-guild-prune
@@ -702,7 +713,7 @@ export type RESTGetAPIGuildWidgetSettingsResult = APIGuildWidgetSettings;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-widget
*/
export type RESTPatchAPIGuildWidgetSettingsJSONBody = Partial<APIGuildWidgetSettings>;
export type RESTPatchAPIGuildWidgetSettingsJSONBody = StrictPartial<APIGuildWidgetSettings>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-widget
@@ -742,7 +753,7 @@ export type RESTGetAPIGuildWidgetImageResult = ArrayBuffer;
export type RESTGetAPIGuildMemberVerificationResult = APIGuildMembershipScreening;
export interface RESTPatchAPIGuildMemberVerificationJSONBody {
export type RESTPatchAPIGuildMemberVerificationJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Whether Membership Screening is enabled
*/
@@ -755,11 +766,11 @@ export interface RESTPatchAPIGuildMemberVerificationJSONBody {
* The server description to show in the screening form
*/
description?: string | null;
}
}>;
export type RESTPatchAPIGuildMemberVerificationResult = APIGuildMembershipScreening;
export interface RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody {
export type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The id of the channel the user is currently in
*/
@@ -772,9 +783,9 @@ export interface RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody {
* Sets the user's request to speak
*/
request_to_speak_timestamp?: string | null;
}
}>;
export interface RESTPatchAPIGuildVoiceStateUserJSONBody {
export type RESTPatchAPIGuildVoiceStateUserJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The id of the channel the user is currently in
*/
@@ -783,7 +794,7 @@ export interface RESTPatchAPIGuildVoiceStateUserJSONBody {
* Toggles the user's suppress state
*/
suppress?: boolean;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen
@@ -793,9 +804,10 @@ export type RESTGetAPIGuildWelcomeScreenResult = APIGuildWelcomeScreen;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen
*/
export interface RESTPatchAPIGuildWelcomeScreenJSONBody extends Nullable<Partial<APIGuildWelcomeScreen>> {
/**
* Whether the welcome screen is enabled
*/
enabled?: boolean | null;
}
export type RESTPatchAPIGuildWelcomeScreenJSONBody = Nullable<StrictPartial<APIGuildWelcomeScreen>> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Whether the welcome screen is enabled
*/
enabled?: boolean | null;
}>;

View File

@@ -1,12 +1,12 @@
import type { Snowflake } from '../../globals.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals.ts';
import type {
APIGuildScheduledEvent,
GuildScheduledEventEntityType,
GuildScheduledEventPrivacyLevel,
APIGuildScheduledEventEntityMetadata,
GuildScheduledEventStatus,
APIGuildMember,
APIUser,
APIGuildScheduledEventUser,
} from '../../v8.ts';
/**
@@ -27,7 +27,7 @@ export type RESTGetAPIGuildScheduledEventsResult = APIGuildScheduledEvent[];
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event
*/
export interface RESTPostAPIGuildScheduledEventJSONBody {
export type RESTPostAPIGuildScheduledEventJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The stage channel id of the guild event
*/
@@ -60,7 +60,7 @@ export interface RESTPostAPIGuildScheduledEventJSONBody {
* The entity metadata of the scheduled event
*/
entity_metadata?: APIGuildScheduledEventEntityMetadata;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event
@@ -85,12 +85,13 @@ export type RESTGetAPIGuildScheduledEventResult = APIGuildScheduledEvent;
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event
*/
export interface RESTPatchAPIGuildScheduledEventJSONBody extends Partial<RESTPostAPIGuildScheduledEventJSONBody> {
/**
* The status of the scheduled event
*/
status?: GuildScheduledEventStatus;
}
export type RESTPatchAPIGuildScheduledEventJSONBody = StrictPartial<RESTPostAPIGuildScheduledEventJSONBody> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The status of the scheduled event
*/
status?: GuildScheduledEventStatus;
}>;
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event
@@ -130,21 +131,3 @@ export interface RESTGetAPIGuildScheduledEventUsersQuery {
* https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event-users
*/
export type RESTGetAPIGuildScheduledEventUsersResult = APIGuildScheduledEventUser[];
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-user-object-guild-scheduled-event-user-structure
*/
export interface APIGuildScheduledEventUser {
/**
* The scheduled event id which the user subscribed to
*/
guild_scheduled_event_id: Snowflake;
/**
* The user which subscribed to the event
*/
user: APIUser;
/**
* The guild member data for this user for the guild which this event belongs to, if any
*/
member?: APIGuildMember;
}

View File

@@ -6,6 +6,7 @@ import type {
APIInteractionResponseCallbackData,
ApplicationCommandType,
} from '../../payloads/v8/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals.ts';
import type {
RESTDeleteAPIWebhookWithTokenMessageResult,
RESTGetAPIWebhookWithTokenMessageResult,
@@ -25,22 +26,18 @@ export type RESTGetAPIApplicationCommandsResult = APIApplicationCommand[];
*/
export type RESTGetAPIApplicationCommandResult = APIApplicationCommand;
type RESTPostAPIBaseApplicationCommandsJSONBody = Omit<
APIApplicationCommand,
'id' | 'application_id' | 'description' | 'type' | 'version'
type RESTPostAPIBaseApplicationCommandsJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<
Omit<APIApplicationCommand, 'id' | 'application_id' | 'description' | 'type' | 'version' | 'guild_id'>
>;
/**
* https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
*/
export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody {
type?: ApplicationCommandType.ChatInput;
/**
* Whether this application command option should be autocompleted
*/
autocomplete?: boolean;
description: string;
}
export type RESTPostAPIChatInputApplicationCommandsJSONBody = RESTPostAPIBaseApplicationCommandsJSONBody &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
type?: ApplicationCommandType.ChatInput;
description: string;
}>;
/**
* https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
@@ -64,7 +61,7 @@ export type RESTPostAPIApplicationCommandsResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command
*/
export type RESTPatchAPIApplicationCommandJSONBody = Partial<RESTPostAPIApplicationCommandsJSONBody>;
export type RESTPatchAPIApplicationCommandJSONBody = StrictPartial<RESTPostAPIApplicationCommandsJSONBody>;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command
@@ -104,7 +101,7 @@ export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandJSONBody = Partial<RESTPostAPIApplicationCommandsJSONBody>;
export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial<RESTPostAPIApplicationCommandsJSONBody>;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command

View File

@@ -798,27 +798,3 @@ export const OAuth2Routes = {
// Freeze OAuth2 route object
Object.freeze(OAuth2Routes);
export interface DiscordErrorFieldInformation {
code: string;
message: string;
}
export interface DiscordErrorGroupWrapper {
_errors: DiscordError[];
}
export type DiscordErrorData =
| DiscordErrorGroupWrapper
| DiscordErrorFieldInformation
| { [k: string]: DiscordErrorData }
| string;
/**
* https://discord.com/developers/docs/reference#error-messages
*/
export interface DiscordError {
code: number;
message: string;
errors?: DiscordErrorData;
}

View File

@@ -1,5 +1,6 @@
import type { Snowflake } from '../../globals.ts';
import type { APIStageInstance, StageInstancePrivacyLevel } from '../../payloads/v8/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface } from '../../utils/internals.ts';
/**
* https://discord.com/developers/docs/resources/stage-instance#create-stage-instance
@@ -34,7 +35,7 @@ export type RESTGetAPIStageInstanceResult = APIStageInstance;
/**
* https://discord.com/developers/docs/resources/stage-instance#update-stage-instance
*/
export interface RESTPatchAPIStageInstanceJSONBody {
export type RESTPatchAPIStageInstanceJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The topic of the stage instance (1-120 characters)
*/
@@ -43,7 +44,7 @@ export interface RESTPatchAPIStageInstanceJSONBody {
* The privacy level of the stage instance
*/
privacy_level?: StageInstancePrivacyLevel;
}
}>;
/**
* https://discord.com/developers/docs/resources/stage-instance#update-stage-instance

View File

@@ -1,4 +1,5 @@
import type { APISticker, APIStickerPack } from '../../payloads/v8/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface } from '../../utils/internals.ts';
export type RESTGetAPIStickerResult = APISticker;
@@ -31,7 +32,7 @@ export interface RESTPostAPIGuildStickerFormDataBody {
export type RESTPostAPIGuildStickerResult = APISticker;
export interface RESTPatchAPIGuildStickerJSONBody {
export type RESTPatchAPIGuildStickerJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the sticker (2-30 characters)
*/
@@ -44,7 +45,7 @@ export interface RESTPatchAPIGuildStickerJSONBody {
* The Discord name of a unicode emoji representing the sticker's expression (2-200 characters)
*/
tags?: string;
}
}>;
export type RESTPatchAPIGuildStickerResult = APISticker;

View File

@@ -1,4 +1,5 @@
import type { APIGuild, APITemplate } from '../../payloads/v8/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals.ts';
/**
* https://discord.com/developers/docs/resources/template#get-template
@@ -8,7 +9,7 @@ export type RESTGetAPITemplateResult = APITemplate;
/**
* https://discord.com/developers/docs/resources/template#create-guild-from-template
*/
export interface RESTPostAPITemplateCreateGuildJSONBody {
export type RESTPostAPITemplateCreateGuildJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the guild (2-100 characters)
*/
@@ -19,7 +20,8 @@ export interface RESTPostAPITemplateCreateGuildJSONBody {
* See https://discord.com/developers/docs/reference#image-data
*/
icon?: string;
}
}>;
/**
* https://discord.com/developers/docs/resources/template#create-guild-from-template
*/
@@ -33,7 +35,7 @@ export type RESTGetAPIGuildTemplatesResult = APITemplate[];
/**
* https://discord.com/developers/docs/resources/template#create-guild-template
*/
export interface RESTPostAPIGuildTemplatesJSONBody {
export type RESTPostAPIGuildTemplatesJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the template (1-100 characters)
*/
@@ -42,7 +44,7 @@ export interface RESTPostAPIGuildTemplatesJSONBody {
* Description for the template (0-120 characters)
*/
description?: string | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/template#create-guild-template
@@ -57,7 +59,7 @@ export type RESTPutAPIGuildTemplateSyncResult = APITemplate;
/**
* https://discord.com/developers/docs/resources/template#modify-guild-template
*/
export type RESTPatchAPIGuildTemplateJSONBody = Partial<RESTPostAPIGuildTemplatesJSONBody>;
export type RESTPatchAPIGuildTemplateJSONBody = StrictPartial<RESTPostAPIGuildTemplatesJSONBody>;
/**
* https://discord.com/developers/docs/resources/template#modify-guild-template

View File

@@ -1,5 +1,6 @@
import type { Permissions, Snowflake } from '../../globals.ts';
import type { APIChannel, APIConnection, APIGuildMember, APIUser, GuildFeature } from '../../payloads/v8/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface } from '../../utils/internals.ts';
/**
* https://discord.com/developers/docs/resources/user#get-current-user
@@ -19,7 +20,7 @@ export type RESTGetCurrentUserGuildMemberResult = APIGuildMember;
/**
* https://discord.com/developers/docs/resources/user#modify-current-user
*/
export interface RESTPatchAPICurrentUserJSONBody {
export type RESTPatchAPICurrentUserJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* User's username, if changed may cause the user's discriminator to be randomized
*/
@@ -28,7 +29,7 @@ export interface RESTPatchAPICurrentUserJSONBody {
* If passed, modifies the user's avatar
*/
avatar?: string | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/user#modify-current-user

View File

@@ -7,12 +7,12 @@ import type {
APIWebhook,
APIAttachment,
} from '../../payloads/v8/mod.ts';
import type { Nullable } from '../../utils/internals.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, Nullable } from '../../utils/internals.ts';
/**
* https://discord.com/developers/docs/resources/webhook#create-webhook
*/
export interface RESTPostAPIChannelWebhookJSONBody {
export type RESTPostAPIChannelWebhookJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the webhook (1-80 characters)
*/
@@ -23,7 +23,7 @@ export interface RESTPostAPIChannelWebhookJSONBody {
* See https://discord.com/developers/docs/reference#image-data
*/
avatar?: string | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/webhook#create-webhook
@@ -53,7 +53,7 @@ export type RESTGetAPIWebhookWithTokenResult = Omit<APIWebhook, 'user'>;
/**
* https://discord.com/developers/docs/resources/webhook#modify-webhook
*/
export interface RESTPatchAPIWebhookJSONBody {
export type RESTPatchAPIWebhookJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The default name of the webhook
*/
@@ -68,7 +68,7 @@ export interface RESTPatchAPIWebhookJSONBody {
* The new channel id this webhook should be moved to
*/
channel_id?: Snowflake;
}
}>;
/**
* https://discord.com/developers/docs/resources/webhook#modify-webhook
@@ -98,7 +98,7 @@ export type RESTDeleteAPIWebhookWithTokenResult = never;
/**
* https://discord.com/developers/docs/resources/webhook#execute-webhook
*/
export interface RESTPostAPIWebhookWithTokenJSONBody {
export type RESTPostAPIWebhookWithTokenJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The message contents (up to 2000 characters)
*/
@@ -139,7 +139,7 @@ export interface RESTPostAPIWebhookWithTokenJSONBody {
* Attachment objects with filename and description
*/
attachments?: (Pick<APIAttachment, 'id' | 'description'> & Partial<Pick<APIAttachment, 'filename'>>)[];
}
}>;
/**
* https://discord.com/developers/docs/resources/webhook#execute-webhook
@@ -164,6 +164,10 @@ export interface RESTPostAPIWebhookWithTokenQuery {
* @default false
*/
wait?: boolean;
/**
* Send a message to the specified thread within a webhook's channel. The thread will automatically be unarchived.
*/
thread_id?: Snowflake;
}
/**
@@ -223,19 +227,18 @@ export type RESTGetAPIWebhookWithTokenMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message
*/
export interface RESTPatchAPIWebhookWithTokenMessageJSONBody
extends Nullable<
Pick<RESTPostAPIWebhookWithTokenJSONBody, 'content' | 'embeds' | 'allowed_mentions' | 'components'>
> {
/**
* Attached files to keep
*
* Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body.
*
* See https://discord.com/developers/docs/resources/channel#attachment-object
*/
attachments?: (Pick<APIAttachment, 'id'> & Partial<Pick<APIAttachment, 'filename' | 'description'>>)[];
}
export type RESTPatchAPIWebhookWithTokenMessageJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<
Nullable<Pick<RESTPostAPIWebhookWithTokenJSONBody, 'content' | 'embeds' | 'allowed_mentions' | 'components'>> & {
/**
* Attached files to keep
*
* Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body.
*
* See https://discord.com/developers/docs/resources/channel#attachment-object
*/
attachments?: (Pick<APIAttachment, 'id'> & Partial<Pick<APIAttachment, 'filename' | 'description'>>)[];
}
>;
/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message

View File

@@ -20,6 +20,7 @@ import type {
ThreadAutoArchiveDuration,
VideoQualityMode,
} from '../../payloads/v9/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals.ts';
/**
* https://discord.com/developers/docs/resources/channel#get-channel
@@ -29,7 +30,7 @@ export type RESTGetAPIChannelResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/channel#modify-channel
*/
export interface RESTPatchAPIChannelJSONBody {
export type RESTPatchAPIChannelJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* 1-100 character channel name
*
@@ -136,7 +137,7 @@ export interface RESTPatchAPIChannelJSONBody {
* Channel types: privateThread
*/
invitable?: boolean;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#modify-channel
@@ -185,20 +186,21 @@ export type RESTGetAPIChannelMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
*/
export type APIMessageReferenceSend = Partial<APIMessageReference> &
Required<Pick<APIMessageReference, 'message_id'>> & {
export type APIMessageReferenceSend = StrictPartial<APIMessageReference> &
Required<Pick<APIMessageReference, 'message_id'>> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message
*
* @default true
*/
fail_if_not_exists?: boolean;
};
}>;
/**
* https://discord.com/developers/docs/resources/channel#create-message
*/
export interface RESTPostAPIChannelMessageJSONBody {
export type RESTPostAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The message contents (up to 2000 characters)
*/
@@ -252,7 +254,7 @@ export interface RESTPostAPIChannelMessageJSONBody {
* Attachment objects with filename and description
*/
attachments?: (Pick<APIAttachment, 'id' | 'description'> & Partial<Pick<APIAttachment, 'filename'>>)[];
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#create-message
@@ -325,7 +327,7 @@ export type RESTDeleteAPIChannelMessageReactionResult = never;
/**
* https://discord.com/developers/docs/resources/channel#edit-message
*/
export interface RESTPatchAPIChannelMessageJSONBody {
export type RESTPatchAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The new message contents (up to 2000 characters)
*/
@@ -372,7 +374,7 @@ export interface RESTPatchAPIChannelMessageJSONBody {
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent[] | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#edit-message
@@ -446,7 +448,7 @@ export type RESTGetAPIChannelInvitesResult = APIExtendedInvite[];
/**
* https://discord.com/developers/docs/resources/channel#create-channel-invite
*/
export interface RESTPostAPIChannelInviteJSONBody {
export type RESTPostAPIChannelInviteJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Duration of invite in seconds before expiry, or 0 for never
*
@@ -490,7 +492,7 @@ export interface RESTPostAPIChannelInviteJSONBody {
* - The application must have the `EMBEDDED` flag
*/
target_application_id?: Snowflake;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#create-channel-invite
@@ -540,7 +542,7 @@ export type RESTDeleteAPIChannelPinResult = never;
/**
* https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
*/
export interface RESTPutAPIChannelRecipientJSONBody {
export type RESTPutAPIChannelRecipientJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Access token of a user that has granted your app the `gdm.join` scope
*/
@@ -549,7 +551,7 @@ export interface RESTPutAPIChannelRecipientJSONBody {
* Nickname of the user being added
*/
nick?: string;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
@@ -564,7 +566,7 @@ export type RESTDeleteAPIChannelRecipientResult = unknown;
/**
* https://discord.com/developers/docs/resources/channel#start-thread-with-message
*/
export interface RESTPostAPIChannelMessagesThreadsJSONBody {
export type RESTPostAPIChannelMessagesThreadsJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* 1-100 character thread name
*/
@@ -579,7 +581,7 @@ export interface RESTPostAPIChannelMessagesThreadsJSONBody {
* Amount of seconds a user has to wait before sending another message (0-21600)
*/
rate_limit_per_user?: number;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#start-thread-with-message
@@ -589,23 +591,24 @@ export type RESTPostAPIChannelMessagesThreadsResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/channel#start-thread-without-message
*/
export interface RESTPostAPIChannelThreadsJSONBody extends RESTPostAPIChannelMessagesThreadsJSONBody {
/**
* The type of thread to create
*
* In API v9, `type` defaults to `PRIVATE_THREAD`.
* In API v10 this will be changed to be a required field, with no default.
*
* See https://discord.com/developers/docs/resources/channel#channel-object-channel-types
*
* @default 12
*/
type?: ChannelType.GuildNewsThread | ChannelType.GuildPublicThread | ChannelType.GuildPrivateThread;
/**
* Whether non-moderators can add other non-moderators to the thread; only available when creating a private thread
*/
invitable?: boolean;
}
export type RESTPostAPIChannelThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The type of thread to create
*
* In API v9, `type` defaults to `PRIVATE_THREAD`.
* In API v10 this will be changed to be a required field, with no default.
*
* See https://discord.com/developers/docs/resources/channel#channel-object-channel-types
*
* @default 12
*/
type?: ChannelType.GuildNewsThread | ChannelType.GuildPublicThread | ChannelType.GuildPrivateThread;
/**
* Whether non-moderators can add other non-moderators to the thread; only available when creating a private thread
*/
invitable?: boolean;
}>;
/**
* https://discord.com/developers/docs/resources/channel#start-thread-without-message

View File

@@ -1,5 +1,6 @@
import type { Snowflake } from '../../globals.ts';
import type { APIEmoji } from '../../payloads/v9/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface } from '../../utils/internals.ts';
/**
* https://discord.com/developers/docs/resources/emoji#list-guild-emojis
@@ -14,7 +15,7 @@ export type RESTGetAPIGuildEmojiResult = APIEmoji;
/**
* https://discord.com/developers/docs/resources/emoji#create-guild-emoji-json-params
*/
export interface RESTPostAPIGuildEmojiJSONBody {
export type RESTPostAPIGuildEmojiJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the emoji
*/
@@ -29,7 +30,7 @@ export interface RESTPostAPIGuildEmojiJSONBody {
* Roles for which this emoji will be whitelisted
*/
roles?: Snowflake[];
}
}>;
/**
* https://discord.com/developers/docs/resources/emoji#create-guild-emoji
@@ -39,7 +40,7 @@ export type RESTPostAPIGuildEmojiResult = APIEmoji;
/**
* https://discord.com/developers/docs/resources/emoji#modify-guild-emoji
*/
export interface RESTPatchAPIGuildEmojiJSONBody {
export type RESTPatchAPIGuildEmojiJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the emoji
*/
@@ -48,7 +49,7 @@ export interface RESTPatchAPIGuildEmojiJSONBody {
* Roles for which this emoji will be whitelisted
*/
roles?: Snowflake[] | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/emoji#modify-guild-emoji

View File

@@ -21,21 +21,27 @@ import type {
GuildVerificationLevel,
GuildWidgetStyle,
} from '../../payloads/v9/mod.ts';
import type { Nullable } from '../../utils/internals.ts';
import type {
AddUndefinedToPossiblyUndefinedPropertiesOfInterface,
Nullable,
StrictPartial,
StrictRequired,
} from '../../utils/internals.ts';
import type { RESTPutAPIChannelPermissionJSONBody } from './channel.ts';
export interface APIGuildCreateOverwrite extends RESTPutAPIChannelPermissionJSONBody {
id: number | string;
}
export type APIGuildCreatePartialChannel = Partial<
export type APIGuildCreatePartialChannel = StrictPartial<
Pick<APIChannel, 'type' | 'topic' | 'nsfw' | 'bitrate' | 'user_limit' | 'rate_limit_per_user'>
> & {
name: string;
id?: number | string;
parent_id?: number | string | null;
permission_overwrites?: APIGuildCreateOverwrite[];
};
> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
name: string;
id?: number | string;
parent_id?: number | string | null;
permission_overwrites?: APIGuildCreateOverwrite[];
}>;
export interface APIGuildCreateRole extends RESTPostAPIGuildRoleJSONBody {
id: number | string;
@@ -44,7 +50,7 @@ export interface APIGuildCreateRole extends RESTPostAPIGuildRoleJSONBody {
/**
* https://discord.com/developers/docs/resources/guild#create-guild
*/
export interface RESTPostAPIGuildsJSONBody {
export type RESTPostAPIGuildsJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the guild (2-100 characters)
*/
@@ -127,7 +133,7 @@ export interface RESTPostAPIGuildsJSONBody {
* Whether the boosts progress bar should be enabled.
*/
premium_progress_bar_enabled?: boolean;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#create-guild
@@ -159,7 +165,7 @@ export type RESTGetAPIGuildPreviewResult = APIGuildPreview;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild
*/
export interface RESTPatchAPIGuildJSONBody {
export type RESTPatchAPIGuildJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* New name for the guild (2-100 characters)
*/
@@ -258,7 +264,7 @@ export interface RESTPatchAPIGuildJSONBody {
* Whether the boosts progress bar should be enabled.
*/
premium_progress_bar_enabled?: boolean;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild
@@ -288,24 +294,26 @@ export type RESTPostAPIGuildChannelResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions
*/
export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{
/**
* Channel id
*/
id: Snowflake;
/**
* Sorting position of the channel
*/
position: number;
/**
* Sync channel overwrites with the new parent, when moving to a new `parent_id`
*/
lock_permissions?: boolean;
/**
* The new parent id of this channel
*/
parent_id?: Snowflake | null;
}>;
export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Channel id
*/
id: Snowflake;
/**
* Sorting position of the channel
*/
position: number;
/**
* Sync channel overwrites with the new parent, when moving to a new `parent_id`
*/
lock_permissions?: boolean;
/**
* The new parent id of this channel
*/
parent_id?: Snowflake | null;
}>
>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions
@@ -366,7 +374,7 @@ export type RESTGetAPIGuildMembersSearchResult = APIGuildMember[];
/**
* https://discord.com/developers/docs/resources/guild#add-guild-member
*/
export interface RESTPutAPIGuildMemberJSONBody {
export type RESTPutAPIGuildMemberJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* An oauth2 access token granted with the `guilds.join` to the bot's application for the user you want to add to the guild
*/
@@ -395,14 +403,14 @@ export interface RESTPutAPIGuildMemberJSONBody {
* Requires `DEAFEN_MEMBERS` permission
*/
deaf?: boolean;
}
}>;
export type RESTPutAPIGuildMemberResult = APIGuildMember | undefined;
export type RESTPutAPIGuildMemberResult = APIGuildMember | never;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-member
*/
export interface RESTPatchAPIGuildMemberJSONBody {
export type RESTPatchAPIGuildMemberJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Value to set users nickname to
*
@@ -433,7 +441,7 @@ export interface RESTPatchAPIGuildMemberJSONBody {
* Requires `MOVE_MEMBERS` permission
*/
channel_id?: Snowflake | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#add-guild-member
@@ -443,19 +451,20 @@ export type RESTPatchAPIGuildMemberResult = APIGuildMember;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-nick
*/
export interface RESTPatchAPICurrentGuildMemberNicknameJSONBody {
export type RESTPatchAPICurrentGuildMemberNicknameJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Value to set users nickname to
*
* Requires `CHANGE_NICKNAME` permission
*/
nick?: string | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-nick
*/
export type RESTPatchAPICurrentGuildMemberNicknameResult = Required<RESTPatchAPICurrentGuildMemberNicknameJSONBody>;
export type RESTPatchAPICurrentGuildMemberNicknameResult =
StrictRequired<RESTPatchAPICurrentGuildMemberNicknameJSONBody>;
/**
* https://discord.com/developers/docs/resources/guild#add-guild-member-role
@@ -485,7 +494,7 @@ export type RESTGetAPIGuildBanResult = APIBan;
/**
* https://discord.com/developers/docs/resources/guild#create-guild-ban
*/
export interface RESTPutAPIGuildBanJSONBody {
export type RESTPutAPIGuildBanJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Number of days to delete messages for (0-7)
*/
@@ -494,7 +503,7 @@ export interface RESTPutAPIGuildBanJSONBody {
* Reason for the ban
*/
reason?: string;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#create-guild-ban
@@ -514,7 +523,7 @@ export type RESTGetAPIGuildRolesResult = APIRole[];
/**
* https://discord.com/developers/docs/resources/guild#create-guild-role
*/
export interface RESTPostAPIGuildRoleJSONBody {
export type RESTPostAPIGuildRoleJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the role
*
@@ -524,7 +533,7 @@ export interface RESTPostAPIGuildRoleJSONBody {
/**
* Bitwise value of the enabled/disabled permissions
*
* @default "default role permissions in guild"
* @default "default role permissions in guild"
*/
permissions?: Permissions | null;
/**
@@ -553,7 +562,7 @@ export interface RESTPostAPIGuildRoleJSONBody {
* @default false
*/
mentionable?: boolean | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#create-guild-role
@@ -563,16 +572,18 @@ export type RESTPostAPIGuildRoleResult = APIRole;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
*/
export type RESTPatchAPIGuildRolePositionsJSONBody = Array<{
/**
* Role id
*/
id: Snowflake;
/**
* Sorting position of the role
*/
position?: number;
}>;
export type RESTPatchAPIGuildRolePositionsJSONBody = Array<
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Role id
*/
id: Snowflake;
/**
* Sorting position of the role
*/
position?: number;
}>
>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
@@ -582,7 +593,7 @@ export type RESTPatchAPIGuildRolePositionsResult = APIRole[];
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role
*/
export interface RESTPatchAPIGuildRoleJSONBody {
export type RESTPatchAPIGuildRoleJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the role
*/
@@ -611,7 +622,7 @@ export interface RESTPatchAPIGuildRoleJSONBody {
* Whether the role should be mentionable
*/
mentionable?: boolean | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role
@@ -654,7 +665,7 @@ export interface RESTGetAPIGuildPruneCountResult {
/**
* https://discord.com/developers/docs/resources/guild#begin-guild-prune
*/
export interface RESTPostAPIGuildPruneJSONBody {
export type RESTPostAPIGuildPruneJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Number of days to count prune for (1 or more)
*
@@ -671,7 +682,7 @@ export interface RESTPostAPIGuildPruneJSONBody {
* Role(s) to include
*/
include_roles?: Snowflake[];
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#begin-guild-prune
@@ -708,7 +719,7 @@ export type RESTGetAPIGuildWidgetSettingsResult = APIGuildWidgetSettings;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-widget
*/
export type RESTPatchAPIGuildWidgetSettingsJSONBody = Partial<APIGuildWidgetSettings>;
export type RESTPatchAPIGuildWidgetSettingsJSONBody = StrictPartial<APIGuildWidgetSettings>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-widget
@@ -748,7 +759,7 @@ export type RESTGetAPIGuildWidgetImageResult = ArrayBuffer;
export type RESTGetAPIGuildMemberVerificationResult = APIGuildMembershipScreening;
export interface RESTPatchAPIGuildMemberVerificationJSONBody {
export type RESTPatchAPIGuildMemberVerificationJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Whether Membership Screening is enabled
*/
@@ -761,11 +772,11 @@ export interface RESTPatchAPIGuildMemberVerificationJSONBody {
* The server description to show in the screening form
*/
description?: string | null;
}
}>;
export type RESTPatchAPIGuildMemberVerificationResult = APIGuildMembershipScreening;
export interface RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody {
export type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The id of the channel the user is currently in
*/
@@ -778,9 +789,9 @@ export interface RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody {
* Sets the user's request to speak
*/
request_to_speak_timestamp?: string | null;
}
}>;
export interface RESTPatchAPIGuildVoiceStateUserJSONBody {
export type RESTPatchAPIGuildVoiceStateUserJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The id of the channel the user is currently in
*/
@@ -789,7 +800,7 @@ export interface RESTPatchAPIGuildVoiceStateUserJSONBody {
* Toggles the user's suppress state
*/
suppress?: boolean;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen
@@ -799,9 +810,10 @@ export type RESTGetAPIGuildWelcomeScreenResult = APIGuildWelcomeScreen;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen
*/
export interface RESTPatchAPIGuildWelcomeScreenJSONBody extends Nullable<Partial<APIGuildWelcomeScreen>> {
/**
* Whether the welcome screen is enabled
*/
enabled?: boolean | null;
}
export type RESTPatchAPIGuildWelcomeScreenJSONBody = Nullable<StrictPartial<APIGuildWelcomeScreen>> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Whether the welcome screen is enabled
*/
enabled?: boolean | null;
}>;

View File

@@ -1,12 +1,12 @@
import type { Snowflake } from '../../globals.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals.ts';
import type {
APIGuildScheduledEvent,
GuildScheduledEventEntityType,
GuildScheduledEventPrivacyLevel,
APIGuildScheduledEventEntityMetadata,
GuildScheduledEventStatus,
APIGuildMember,
APIUser,
APIGuildScheduledEventUser,
} from '../../v9.ts';
/**
@@ -27,7 +27,7 @@ export type RESTGetAPIGuildScheduledEventsResult = APIGuildScheduledEvent[];
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event
*/
export interface RESTPostAPIGuildScheduledEventJSONBody {
export type RESTPostAPIGuildScheduledEventJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The stage channel id of the guild event
*/
@@ -60,7 +60,7 @@ export interface RESTPostAPIGuildScheduledEventJSONBody {
* The entity metadata of the scheduled event
*/
entity_metadata?: APIGuildScheduledEventEntityMetadata;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event
@@ -85,12 +85,13 @@ export type RESTGetAPIGuildScheduledEventResult = APIGuildScheduledEvent;
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event
*/
export interface RESTPatchAPIGuildScheduledEventJSONBody extends Partial<RESTPostAPIGuildScheduledEventJSONBody> {
/**
* The status of the scheduled event
*/
status?: GuildScheduledEventStatus;
}
export type RESTPatchAPIGuildScheduledEventJSONBody = StrictPartial<RESTPostAPIGuildScheduledEventJSONBody> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The status of the scheduled event
*/
status?: GuildScheduledEventStatus;
}>;
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event
@@ -130,21 +131,3 @@ export interface RESTGetAPIGuildScheduledEventUsersQuery {
* https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event-users
*/
export type RESTGetAPIGuildScheduledEventUsersResult = APIGuildScheduledEventUser[];
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-user-object-guild-scheduled-event-user-structure
*/
export interface APIGuildScheduledEventUser {
/**
* The scheduled event id which the user subscribed to
*/
guild_scheduled_event_id: Snowflake;
/**
* The user which subscribed to the event
*/
user: APIUser;
/**
* The guild member data for this user for the guild which this event belongs to, if any
*/
member?: APIGuildMember;
}

View File

@@ -6,6 +6,7 @@ import type {
APIInteractionResponseCallbackData,
ApplicationCommandType,
} from '../../payloads/v9/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals.ts';
import type {
RESTDeleteAPIWebhookWithTokenMessageResult,
RESTGetAPIWebhookWithTokenMessageResult,
@@ -25,22 +26,18 @@ export type RESTGetAPIApplicationCommandsResult = APIApplicationCommand[];
*/
export type RESTGetAPIApplicationCommandResult = APIApplicationCommand;
type RESTPostAPIBaseApplicationCommandsJSONBody = Omit<
APIApplicationCommand,
'id' | 'application_id' | 'description' | 'type' | 'version'
type RESTPostAPIBaseApplicationCommandsJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<
Omit<APIApplicationCommand, 'id' | 'application_id' | 'description' | 'type' | 'version' | 'guild_id'>
>;
/**
* https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
*/
export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody {
type?: ApplicationCommandType.ChatInput;
/**
* Whether this application command option should be autocompleted
*/
autocomplete?: boolean;
description: string;
}
export type RESTPostAPIChatInputApplicationCommandsJSONBody = RESTPostAPIBaseApplicationCommandsJSONBody &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
type?: ApplicationCommandType.ChatInput;
description: string;
}>;
/**
* https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
@@ -64,7 +61,7 @@ export type RESTPostAPIApplicationCommandsResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command
*/
export type RESTPatchAPIApplicationCommandJSONBody = Partial<RESTPostAPIApplicationCommandsJSONBody>;
export type RESTPatchAPIApplicationCommandJSONBody = StrictPartial<RESTPostAPIApplicationCommandsJSONBody>;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command
@@ -104,7 +101,7 @@ export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandJSONBody = Partial<RESTPostAPIApplicationCommandsJSONBody>;
export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial<RESTPostAPIApplicationCommandsJSONBody>;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command

View File

@@ -1,5 +1,6 @@
import type { Snowflake } from '../../globals.ts';
import type { APIStageInstance, StageInstancePrivacyLevel } from '../../payloads/v9/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface } from '../../utils/internals.ts';
/**
* https://discord.com/developers/docs/resources/stage-instance#create-stage-instance
@@ -34,7 +35,7 @@ export type RESTGetAPIStageInstanceResult = APIStageInstance;
/**
* https://discord.com/developers/docs/resources/stage-instance#update-stage-instance
*/
export interface RESTPatchAPIStageInstanceJSONBody {
export type RESTPatchAPIStageInstanceJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The topic of the stage instance (1-120 characters)
*/
@@ -43,7 +44,7 @@ export interface RESTPatchAPIStageInstanceJSONBody {
* The privacy level of the stage instance
*/
privacy_level?: StageInstancePrivacyLevel;
}
}>;
/**
* https://discord.com/developers/docs/resources/stage-instance#update-stage-instance

View File

@@ -1,4 +1,5 @@
import type { APISticker, APIStickerPack } from '../../payloads/v9/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface } from '../../utils/internals.ts';
export type RESTGetAPIStickerResult = APISticker;
@@ -31,7 +32,7 @@ export interface RESTPostAPIGuildStickerFormDataBody {
export type RESTPostAPIGuildStickerResult = APISticker;
export interface RESTPatchAPIGuildStickerJSONBody {
export type RESTPatchAPIGuildStickerJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the sticker (2-30 characters)
*/
@@ -44,7 +45,7 @@ export interface RESTPatchAPIGuildStickerJSONBody {
* The Discord name of a unicode emoji representing the sticker's expression (2-200 characters)
*/
tags?: string;
}
}>;
export type RESTPatchAPIGuildStickerResult = APISticker;

View File

@@ -1,4 +1,5 @@
import type { APIGuild, APITemplate } from '../../payloads/v9/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals.ts';
/**
* https://discord.com/developers/docs/resources/template#get-template
@@ -8,7 +9,7 @@ export type RESTGetAPITemplateResult = APITemplate;
/**
* https://discord.com/developers/docs/resources/template#create-guild-from-template
*/
export interface RESTPostAPITemplateCreateGuildJSONBody {
export type RESTPostAPITemplateCreateGuildJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the guild (2-100 characters)
*/
@@ -19,7 +20,8 @@ export interface RESTPostAPITemplateCreateGuildJSONBody {
* See https://discord.com/developers/docs/reference#image-data
*/
icon?: string;
}
}>;
/**
* https://discord.com/developers/docs/resources/template#create-guild-from-template
*/
@@ -33,7 +35,7 @@ export type RESTGetAPIGuildTemplatesResult = APITemplate[];
/**
* https://discord.com/developers/docs/resources/template#create-guild-template
*/
export interface RESTPostAPIGuildTemplatesJSONBody {
export type RESTPostAPIGuildTemplatesJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the template (1-100 characters)
*/
@@ -42,7 +44,7 @@ export interface RESTPostAPIGuildTemplatesJSONBody {
* Description for the template (0-120 characters)
*/
description?: string | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/template#create-guild-template
@@ -57,7 +59,7 @@ export type RESTPutAPIGuildTemplateSyncResult = APITemplate;
/**
* https://discord.com/developers/docs/resources/template#modify-guild-template
*/
export type RESTPatchAPIGuildTemplateJSONBody = Partial<RESTPostAPIGuildTemplatesJSONBody>;
export type RESTPatchAPIGuildTemplateJSONBody = StrictPartial<RESTPostAPIGuildTemplatesJSONBody>;
/**
* https://discord.com/developers/docs/resources/template#modify-guild-template

View File

@@ -1,5 +1,6 @@
import type { Permissions, Snowflake } from '../../globals.ts';
import type { APIChannel, APIConnection, APIGuildMember, APIUser, GuildFeature } from '../../payloads/v9/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface } from '../../utils/internals.ts';
/**
* https://discord.com/developers/docs/resources/user#get-current-user
@@ -19,7 +20,7 @@ export type RESTGetCurrentUserGuildMemberResult = APIGuildMember;
/**
* https://discord.com/developers/docs/resources/user#modify-current-user
*/
export interface RESTPatchAPICurrentUserJSONBody {
export type RESTPatchAPICurrentUserJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* User's username, if changed may cause the user's discriminator to be randomized
*/
@@ -28,7 +29,7 @@ export interface RESTPatchAPICurrentUserJSONBody {
* If passed, modifies the user's avatar
*/
avatar?: string | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/user#modify-current-user

View File

@@ -7,12 +7,12 @@ import type {
APIWebhook,
APIAttachment,
} from '../../payloads/v9/mod.ts';
import type { Nullable } from '../../utils/internals.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, Nullable } from '../../utils/internals.ts';
/**
* https://discord.com/developers/docs/resources/webhook#create-webhook
*/
export interface RESTPostAPIChannelWebhookJSONBody {
export type RESTPostAPIChannelWebhookJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the webhook (1-80 characters)
*/
@@ -23,7 +23,7 @@ export interface RESTPostAPIChannelWebhookJSONBody {
* See https://discord.com/developers/docs/reference#image-data
*/
avatar?: string | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/webhook#create-webhook
@@ -53,7 +53,7 @@ export type RESTGetAPIWebhookWithTokenResult = Omit<APIWebhook, 'user'>;
/**
* https://discord.com/developers/docs/resources/webhook#modify-webhook
*/
export interface RESTPatchAPIWebhookJSONBody {
export type RESTPatchAPIWebhookJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The default name of the webhook
*/
@@ -68,7 +68,7 @@ export interface RESTPatchAPIWebhookJSONBody {
* The new channel id this webhook should be moved to
*/
channel_id?: Snowflake;
}
}>;
/**
* https://discord.com/developers/docs/resources/webhook#modify-webhook
@@ -98,7 +98,7 @@ export type RESTDeleteAPIWebhookWithTokenResult = never;
/**
* https://discord.com/developers/docs/resources/webhook#execute-webhook
*/
export interface RESTPostAPIWebhookWithTokenJSONBody {
export type RESTPostAPIWebhookWithTokenJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The message contents (up to 2000 characters)
*/
@@ -139,7 +139,7 @@ export interface RESTPostAPIWebhookWithTokenJSONBody {
* Attachment objects with filename and description
*/
attachments?: (Pick<APIAttachment, 'id' | 'description'> & Partial<Pick<APIAttachment, 'filename'>>)[];
}
}>;
/**
* https://discord.com/developers/docs/resources/webhook#execute-webhook
@@ -227,19 +227,18 @@ export type RESTGetAPIWebhookWithTokenMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message
*/
export interface RESTPatchAPIWebhookWithTokenMessageJSONBody
extends Nullable<
Pick<RESTPostAPIWebhookWithTokenJSONBody, 'content' | 'embeds' | 'allowed_mentions' | 'components'>
> {
/**
* Attached files to keep
*
* Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body.
*
* See https://discord.com/developers/docs/resources/channel#attachment-object
*/
attachments?: (Pick<APIAttachment, 'id'> & Partial<Pick<APIAttachment, 'filename' | 'description'>>)[];
}
export type RESTPatchAPIWebhookWithTokenMessageJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<
Nullable<Pick<RESTPostAPIWebhookWithTokenJSONBody, 'content' | 'embeds' | 'allowed_mentions' | 'components'>> & {
/**
* Attached files to keep
*
* Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body.
*
* See https://discord.com/developers/docs/resources/channel#attachment-object
*/
attachments?: (Pick<APIAttachment, 'id'> & Partial<Pick<APIAttachment, 'filename' | 'description'>>)[];
}
>;
/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message

View File

@@ -1,3 +1,15 @@
export type Nullable<T> = {
[P in keyof T]: T[P] | null;
};
/**
* Allows support for TS 4.5's `exactOptionalPropertyTypes` option by ensuring a property present and undefined is valid
* (since JSON.stringify ignores undefined properties)
*/
export type AddUndefinedToPossiblyUndefinedPropertiesOfInterface<Base> = {
[K in keyof Base]: Base[K] extends Exclude<Base[K], undefined> ? Base[K] : Base[K] | undefined;
};
export type StrictPartial<Base> = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<Partial<Base>>;
export type StrictRequired<Base> = Required<{ [K in keyof Base]: Exclude<Base[K], undefined> }>;

7774
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,8 +2,6 @@
"name": "discord-api-types",
"version": "0.25.2",
"description": "Discord API typings that are kept up to date for use in bot library creation.",
"main": "./v9.js",
"module": "./v9.mjs",
"types": "./v9.d.ts",
"exports": {
"./globals": {
@@ -112,29 +110,29 @@
"node": ">=12"
},
"devDependencies": {
"@babel/core": "^7.14.6",
"@babel/eslint-parser": "^7.14.7",
"@babel/core": "^7.16.5",
"@babel/eslint-parser": "^7.16.5",
"@babel/plugin-syntax-top-level-await": "^7.14.5",
"@commitlint/cli": "^12.1.4",
"@commitlint/config-angular": "^12.1.4",
"@types/node": "^16.3.3",
"@typescript-eslint/eslint-plugin": "^4.28.3",
"@typescript-eslint/parser": "^4.28.3",
"@commitlint/cli": "^15.0.0",
"@commitlint/config-angular": "^15.0.0",
"@types/node": "^17.0.4",
"@typescript-eslint/eslint-plugin": "^5.8.0",
"@typescript-eslint/parser": "^5.8.0",
"conventional-changelog-cli": "^2.1.1",
"eslint": "^7.30.0",
"eslint-config-marine": "^9.0.6",
"eslint": "^8.5.0",
"eslint-config-marine": "^9.1.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"gen-esm-wrapper": "^1.1.2",
"husky": "^7.0.1",
"is-ci": "^3.0.0",
"lint-staged": "^11.0.1",
"eslint-plugin-prettier": "^4.0.0",
"gen-esm-wrapper": "^1.1.3",
"husky": "^7.0.4",
"is-ci": "^3.0.1",
"lint-staged": "^12.1.4",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.2",
"pretty-quick": "^3.1.1",
"prettier": "^2.5.1",
"pretty-quick": "^3.1.3",
"rimraf": "^3.0.2",
"tsd": "^0.17.0",
"typescript": "^4.3.5"
"tsd": "^0.19.0",
"typescript": "^4.5.4"
},
"repository": {
"type": "git",

View File

@@ -540,7 +540,7 @@ export type APIAuditLogChangeKeyExpireGracePeriod = AuditLogChangeData<'expire_g
* @internal
* @deprecated API and Gateway v6 are deprecated and the types will not receive further updates, please update to v8.
*/
interface AuditLogChangeData<K extends string, D extends unknown> {
interface AuditLogChangeData<K extends string, D> {
key: K;
new_value?: D;
old_value?: D;

View File

@@ -39,7 +39,7 @@ export interface APIInteractionGuildMember extends APIGuildMember {
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export interface APIBaseInteraction<Type extends InteractionType, Data extends unknown> {
export interface APIBaseInteraction<Type extends InteractionType, Data> {
/**
* ID of the interaction
*/

View File

@@ -644,7 +644,7 @@ export type APIAuditLogChangeKeyStatus = AuditLogChangeData<'status', GuildSched
*/
export type APIAuditLogChangeKeyLocation = AuditLogChangeData<'location', string>;
interface AuditLogChangeData<K extends string, D extends unknown> {
interface AuditLogChangeData<K extends string, D> {
key: K;
/**
* The new value

View File

@@ -1,4 +1,5 @@
import type { APIUser } from './user';
import type { APIGuildMember } from './guild';
import type { Snowflake } from '../../globals';
export interface APIGuildScheduledEvent {
@@ -102,3 +103,21 @@ export const enum GuildScheduledEventPrivacyLevel {
*/
GuildOnly = 2,
}
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-user-object-guild-scheduled-event-user-structure
*/
export interface APIGuildScheduledEventUser {
/**
* The scheduled event id which the user subscribed to
*/
guild_scheduled_event_id: Snowflake;
/**
* The user which subscribed to the event
*/
user: APIUser;
/**
* The guild member data for this user for the guild which this event belongs to, if any
*/
member?: APIGuildMember;
}

View File

@@ -39,7 +39,7 @@ export interface APIInteractionGuildMember extends APIGuildMember {
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export interface APIBaseInteraction<Type extends InteractionType, Data extends unknown> {
export interface APIBaseInteraction<Type extends InteractionType, Data> {
/**
* ID of the interaction
*/

View File

@@ -683,7 +683,7 @@ export type APIAuditLogChangeKeyStatus = AuditLogChangeData<'status', GuildSched
*/
export type APIAuditLogChangeKeyLocation = AuditLogChangeData<'location', string>;
interface AuditLogChangeData<K extends string, D extends unknown> {
interface AuditLogChangeData<K extends string, D> {
key: K;
/**
* The new value

View File

@@ -1,4 +1,5 @@
import type { APIUser } from './user';
import type { APIGuildMember } from './guild';
import type { Snowflake } from '../../globals';
export interface APIGuildScheduledEvent {
@@ -102,3 +103,21 @@ export const enum GuildScheduledEventPrivacyLevel {
*/
GuildOnly = 2,
}
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-user-object-guild-scheduled-event-user-structure
*/
export interface APIGuildScheduledEventUser {
/**
* The scheduled event id which the user subscribed to
*/
guild_scheduled_event_id: Snowflake;
/**
* The user which subscribed to the event
*/
user: APIUser;
/**
* The guild member data for this user for the guild which this event belongs to, if any
*/
member?: APIGuildMember;
}

View File

@@ -17,6 +17,7 @@ import type {
OverwriteType,
VideoQualityMode,
} from '../../payloads/v8/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals';
/**
* https://discord.com/developers/docs/resources/channel#get-channel
@@ -26,7 +27,7 @@ export type RESTGetAPIChannelResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/channel#modify-channel
*/
export interface RESTPatchAPIChannelJSONBody {
export type RESTPatchAPIChannelJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* 1-100 character channel name
*
@@ -103,7 +104,7 @@ export interface RESTPatchAPIChannelJSONBody {
* See https://discord.com/developers/docs/resources/channel#channel-object-video-quality-modes
*/
video_quality_mode?: VideoQualityMode | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#modify-channel
@@ -152,20 +153,21 @@ export type RESTGetAPIChannelMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
*/
export type APIMessageReferenceSend = Partial<APIMessageReference> &
Required<Pick<APIMessageReference, 'message_id'>> & {
export type APIMessageReferenceSend = StrictPartial<APIMessageReference> &
Required<Pick<APIMessageReference, 'message_id'>> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message
*
* @default true
*/
fail_if_not_exists?: boolean;
};
}>;
/**
* https://discord.com/developers/docs/resources/channel#create-message
*/
export interface RESTPostAPIChannelMessageJSONBody {
export type RESTPostAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The message contents (up to 2000 characters)
*/
@@ -188,6 +190,7 @@ export interface RESTPostAPIChannelMessageJSONBody {
* Embedded `rich` content
*
* See https://discord.com/developers/docs/resources/channel#embed-object
* @deprecated Use `embeds` instead
*/
embed?: APIEmbed;
/**
@@ -218,7 +221,7 @@ export interface RESTPostAPIChannelMessageJSONBody {
* Attachment objects with filename and description
*/
attachments?: (Pick<APIAttachment, 'id' | 'description'> & Partial<Pick<APIAttachment, 'filename'>>)[];
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#create-message
@@ -291,7 +294,7 @@ export type RESTDeleteAPIChannelMessageReactionResult = never;
/**
* https://discord.com/developers/docs/resources/channel#edit-message
*/
export interface RESTPatchAPIChannelMessageJSONBody {
export type RESTPatchAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The new message contents (up to 2000 characters)
*/
@@ -338,7 +341,7 @@ export interface RESTPatchAPIChannelMessageJSONBody {
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent[] | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#edit-message
@@ -351,6 +354,7 @@ export type RESTPatchAPIChannelMessageFormDataBody =
payload_json?: string;
} & Record<`files[${bigint}]`, unknown>)
| (RESTPatchAPIChannelMessageJSONBody & Record<`files[${bigint}]`, unknown>);
/**
* https://discord.com/developers/docs/resources/channel#edit-message
*/
@@ -411,7 +415,7 @@ export type RESTGetAPIChannelInvitesResult = APIExtendedInvite[];
/**
* https://discord.com/developers/docs/resources/channel#create-channel-invite
*/
export interface RESTPostAPIChannelInviteJSONBody {
export type RESTPostAPIChannelInviteJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Duration of invite in seconds before expiry, or 0 for never
*
@@ -455,7 +459,7 @@ export interface RESTPostAPIChannelInviteJSONBody {
* - The application must have the `EMBEDDED` flag
*/
target_application_id?: Snowflake;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#create-channel-invite
@@ -505,7 +509,7 @@ export type RESTDeleteAPIChannelPinResult = never;
/**
* https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
*/
export interface RESTPutAPIChannelRecipientJSONBody {
export type RESTPutAPIChannelRecipientJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Access token of a user that has granted your app the `gdm.join` scope
*/
@@ -514,7 +518,7 @@ export interface RESTPutAPIChannelRecipientJSONBody {
* Nickname of the user being added
*/
nick?: string;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#group-dm-add-recipient

View File

@@ -1,5 +1,6 @@
import type { Snowflake } from '../../globals';
import type { APIEmoji } from '../../payloads/v8/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface } from '../../utils/internals';
/**
* https://discord.com/developers/docs/resources/emoji#list-guild-emojis
@@ -14,7 +15,7 @@ export type RESTGetAPIGuildEmojiResult = APIEmoji;
/**
* https://discord.com/developers/docs/resources/emoji#create-guild-emoji-json-params
*/
export interface RESTPostAPIGuildEmojiJSONBody {
export type RESTPostAPIGuildEmojiJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the emoji
*/
@@ -29,7 +30,7 @@ export interface RESTPostAPIGuildEmojiJSONBody {
* Roles for which this emoji will be whitelisted
*/
roles?: Snowflake[];
}
}>;
/**
* https://discord.com/developers/docs/resources/emoji#create-guild-emoji
@@ -39,7 +40,7 @@ export type RESTPostAPIGuildEmojiResult = APIEmoji;
/**
* https://discord.com/developers/docs/resources/emoji#modify-guild-emoji
*/
export interface RESTPatchAPIGuildEmojiJSONBody {
export type RESTPatchAPIGuildEmojiJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the emoji
*/
@@ -48,7 +49,7 @@ export interface RESTPatchAPIGuildEmojiJSONBody {
* Roles for which this emoji will be whitelisted
*/
roles?: Snowflake[] | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/emoji#modify-guild-emoji

View File

@@ -20,21 +20,27 @@ import type {
GuildVerificationLevel,
GuildWidgetStyle,
} from '../../payloads/v8/index';
import type { Nullable } from '../../utils/internals';
import type {
AddUndefinedToPossiblyUndefinedPropertiesOfInterface,
Nullable,
StrictPartial,
StrictRequired,
} from '../../utils/internals';
import type { RESTPutAPIChannelPermissionJSONBody } from './channel';
export interface APIGuildCreateOverwrite extends RESTPutAPIChannelPermissionJSONBody {
id: number | string;
}
export type APIGuildCreatePartialChannel = Partial<
export type APIGuildCreatePartialChannel = StrictPartial<
Pick<APIChannel, 'type' | 'topic' | 'nsfw' | 'bitrate' | 'user_limit' | 'rate_limit_per_user'>
> & {
name: string;
id?: number | string;
parent_id?: number | string | null;
permission_overwrites?: APIGuildCreateOverwrite[];
};
> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
name: string;
id?: number | string;
parent_id?: number | string | null;
permission_overwrites?: APIGuildCreateOverwrite[];
}>;
export interface APIGuildCreateRole extends RESTPostAPIGuildRoleJSONBody {
id: number | string;
@@ -43,7 +49,7 @@ export interface APIGuildCreateRole extends RESTPostAPIGuildRoleJSONBody {
/**
* https://discord.com/developers/docs/resources/guild#create-guild
*/
export interface RESTPostAPIGuildsJSONBody {
export type RESTPostAPIGuildsJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the guild (2-100 characters)
*/
@@ -126,7 +132,7 @@ export interface RESTPostAPIGuildsJSONBody {
* Whether the boosts progress bar should be enabled.
*/
premium_progress_bar_enabled?: boolean;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#create-guild
@@ -158,7 +164,7 @@ export type RESTGetAPIGuildPreviewResult = APIGuildPreview;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild
*/
export interface RESTPatchAPIGuildJSONBody {
export type RESTPatchAPIGuildJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* New name for the guild (2-100 characters)
*/
@@ -257,7 +263,7 @@ export interface RESTPatchAPIGuildJSONBody {
* Whether the boosts progress bar should be enabled.
*/
premium_progress_bar_enabled?: boolean;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild
@@ -287,24 +293,26 @@ export type RESTPostAPIGuildChannelResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions
*/
export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{
/**
* Channel id
*/
id: Snowflake;
/**
* Sorting position of the channel
*/
position: number;
/**
* Sync channel overwrites with the new parent, when moving to a new `parent_id`
*/
lock_permissions?: boolean;
/**
* The new parent id of this channel
*/
parent_id?: Snowflake | null;
}>;
export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Channel id
*/
id: Snowflake;
/**
* Sorting position of the channel
*/
position: number;
/**
* Sync channel overwrites with the new parent, when moving to a new `parent_id`
*/
lock_permissions?: boolean;
/**
* The new parent id of this channel
*/
parent_id?: Snowflake | null;
}>
>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions
@@ -360,7 +368,7 @@ export type RESTGetAPIGuildMembersSearchResult = APIGuildMember[];
/**
* https://discord.com/developers/docs/resources/guild#add-guild-member
*/
export interface RESTPutAPIGuildMemberJSONBody {
export type RESTPutAPIGuildMemberJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* An oauth2 access token granted with the `guilds.join` to the bot's application for the user you want to add to the guild
*/
@@ -389,14 +397,14 @@ export interface RESTPutAPIGuildMemberJSONBody {
* Requires `DEAFEN_MEMBERS` permission
*/
deaf?: boolean;
}
}>;
export type RESTPutAPIGuildMemberResult = APIGuildMember | undefined;
export type RESTPutAPIGuildMemberResult = APIGuildMember | never;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-member
*/
export interface RESTPatchAPIGuildMemberJSONBody {
export type RESTPatchAPIGuildMemberJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Value to set users nickname to
*
@@ -427,7 +435,7 @@ export interface RESTPatchAPIGuildMemberJSONBody {
* Requires `MOVE_MEMBERS` permission
*/
channel_id?: Snowflake | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#add-guild-member
@@ -437,19 +445,20 @@ export type RESTPatchAPIGuildMemberResult = APIGuildMember;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-nick
*/
export interface RESTPatchAPICurrentGuildMemberNicknameJSONBody {
export type RESTPatchAPICurrentGuildMemberNicknameJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Value to set users nickname to
*
* Requires `CHANGE_NICKNAME` permission
*/
nick?: string | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-nick
*/
export type RESTPatchAPICurrentGuildMemberNicknameResult = Required<RESTPatchAPICurrentGuildMemberNicknameJSONBody>;
export type RESTPatchAPICurrentGuildMemberNicknameResult =
StrictRequired<RESTPatchAPICurrentGuildMemberNicknameJSONBody>;
/**
* https://discord.com/developers/docs/resources/guild#add-guild-member-role
@@ -479,7 +488,7 @@ export type RESTGetAPIGuildBanResult = APIBan;
/**
* https://discord.com/developers/docs/resources/guild#create-guild-ban
*/
export interface RESTPutAPIGuildBanJSONBody {
export type RESTPutAPIGuildBanJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Number of days to delete messages for (0-7)
*/
@@ -488,7 +497,7 @@ export interface RESTPutAPIGuildBanJSONBody {
* Reason for the ban
*/
reason?: string;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#create-guild-ban
@@ -508,7 +517,7 @@ export type RESTGetAPIGuildRolesResult = APIRole[];
/**
* https://discord.com/developers/docs/resources/guild#create-guild-role
*/
export interface RESTPostAPIGuildRoleJSONBody {
export type RESTPostAPIGuildRoleJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the role
*
@@ -518,7 +527,7 @@ export interface RESTPostAPIGuildRoleJSONBody {
/**
* Bitwise value of the enabled/disabled permissions
*
* @default "default role permissions in guild"
* @default "default role permissions in guild"
*/
permissions?: Permissions | null;
/**
@@ -547,7 +556,7 @@ export interface RESTPostAPIGuildRoleJSONBody {
* @default false
*/
mentionable?: boolean | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#create-guild-role
@@ -557,16 +566,18 @@ export type RESTPostAPIGuildRoleResult = APIRole;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
*/
export type RESTPatchAPIGuildRolePositionsJSONBody = Array<{
/**
* Role id
*/
id: Snowflake;
/**
* Sorting position of the role
*/
position?: number;
}>;
export type RESTPatchAPIGuildRolePositionsJSONBody = Array<
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Role id
*/
id: Snowflake;
/**
* Sorting position of the role
*/
position?: number;
}>
>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
@@ -576,7 +587,7 @@ export type RESTPatchAPIGuildRolePositionsResult = APIRole[];
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role
*/
export interface RESTPatchAPIGuildRoleJSONBody {
export type RESTPatchAPIGuildRoleJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the role
*/
@@ -605,7 +616,7 @@ export interface RESTPatchAPIGuildRoleJSONBody {
* Whether the role should be mentionable
*/
mentionable?: boolean | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role
@@ -648,7 +659,7 @@ export interface RESTGetAPIGuildPruneCountResult {
/**
* https://discord.com/developers/docs/resources/guild#begin-guild-prune
*/
export interface RESTPostAPIGuildPruneJSONBody {
export type RESTPostAPIGuildPruneJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Number of days to count prune for (1 or more)
*
@@ -665,7 +676,7 @@ export interface RESTPostAPIGuildPruneJSONBody {
* Role(s) to include
*/
include_roles?: Snowflake[];
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#begin-guild-prune
@@ -702,7 +713,7 @@ export type RESTGetAPIGuildWidgetSettingsResult = APIGuildWidgetSettings;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-widget
*/
export type RESTPatchAPIGuildWidgetSettingsJSONBody = Partial<APIGuildWidgetSettings>;
export type RESTPatchAPIGuildWidgetSettingsJSONBody = StrictPartial<APIGuildWidgetSettings>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-widget
@@ -742,7 +753,7 @@ export type RESTGetAPIGuildWidgetImageResult = ArrayBuffer;
export type RESTGetAPIGuildMemberVerificationResult = APIGuildMembershipScreening;
export interface RESTPatchAPIGuildMemberVerificationJSONBody {
export type RESTPatchAPIGuildMemberVerificationJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Whether Membership Screening is enabled
*/
@@ -755,11 +766,11 @@ export interface RESTPatchAPIGuildMemberVerificationJSONBody {
* The server description to show in the screening form
*/
description?: string | null;
}
}>;
export type RESTPatchAPIGuildMemberVerificationResult = APIGuildMembershipScreening;
export interface RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody {
export type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The id of the channel the user is currently in
*/
@@ -772,9 +783,9 @@ export interface RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody {
* Sets the user's request to speak
*/
request_to_speak_timestamp?: string | null;
}
}>;
export interface RESTPatchAPIGuildVoiceStateUserJSONBody {
export type RESTPatchAPIGuildVoiceStateUserJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The id of the channel the user is currently in
*/
@@ -783,7 +794,7 @@ export interface RESTPatchAPIGuildVoiceStateUserJSONBody {
* Toggles the user's suppress state
*/
suppress?: boolean;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen
@@ -793,9 +804,10 @@ export type RESTGetAPIGuildWelcomeScreenResult = APIGuildWelcomeScreen;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen
*/
export interface RESTPatchAPIGuildWelcomeScreenJSONBody extends Nullable<Partial<APIGuildWelcomeScreen>> {
/**
* Whether the welcome screen is enabled
*/
enabled?: boolean | null;
}
export type RESTPatchAPIGuildWelcomeScreenJSONBody = Nullable<StrictPartial<APIGuildWelcomeScreen>> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Whether the welcome screen is enabled
*/
enabled?: boolean | null;
}>;

View File

@@ -1,12 +1,12 @@
import type { Snowflake } from '../../globals';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals';
import type {
APIGuildScheduledEvent,
GuildScheduledEventEntityType,
GuildScheduledEventPrivacyLevel,
APIGuildScheduledEventEntityMetadata,
GuildScheduledEventStatus,
APIGuildMember,
APIUser,
APIGuildScheduledEventUser,
} from '../../v8';
/**
@@ -27,7 +27,7 @@ export type RESTGetAPIGuildScheduledEventsResult = APIGuildScheduledEvent[];
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event
*/
export interface RESTPostAPIGuildScheduledEventJSONBody {
export type RESTPostAPIGuildScheduledEventJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The stage channel id of the guild event
*/
@@ -60,7 +60,7 @@ export interface RESTPostAPIGuildScheduledEventJSONBody {
* The entity metadata of the scheduled event
*/
entity_metadata?: APIGuildScheduledEventEntityMetadata;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event
@@ -85,12 +85,13 @@ export type RESTGetAPIGuildScheduledEventResult = APIGuildScheduledEvent;
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event
*/
export interface RESTPatchAPIGuildScheduledEventJSONBody extends Partial<RESTPostAPIGuildScheduledEventJSONBody> {
/**
* The status of the scheduled event
*/
status?: GuildScheduledEventStatus;
}
export type RESTPatchAPIGuildScheduledEventJSONBody = StrictPartial<RESTPostAPIGuildScheduledEventJSONBody> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The status of the scheduled event
*/
status?: GuildScheduledEventStatus;
}>;
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event
@@ -130,21 +131,3 @@ export interface RESTGetAPIGuildScheduledEventUsersQuery {
* https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event-users
*/
export type RESTGetAPIGuildScheduledEventUsersResult = APIGuildScheduledEventUser[];
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-user-object-guild-scheduled-event-user-structure
*/
export interface APIGuildScheduledEventUser {
/**
* The scheduled event id which the user subscribed to
*/
guild_scheduled_event_id: Snowflake;
/**
* The user which subscribed to the event
*/
user: APIUser;
/**
* The guild member data for this user for the guild which this event belongs to, if any
*/
member?: APIGuildMember;
}

View File

@@ -798,27 +798,3 @@ export const OAuth2Routes = {
// Freeze OAuth2 route object
Object.freeze(OAuth2Routes);
export interface DiscordErrorFieldInformation {
code: string;
message: string;
}
export interface DiscordErrorGroupWrapper {
_errors: DiscordError[];
}
export type DiscordErrorData =
| DiscordErrorGroupWrapper
| DiscordErrorFieldInformation
| { [k: string]: DiscordErrorData }
| string;
/**
* https://discord.com/developers/docs/reference#error-messages
*/
export interface DiscordError {
code: number;
message: string;
errors?: DiscordErrorData;
}

View File

@@ -6,6 +6,7 @@ import type {
APIInteractionResponseCallbackData,
ApplicationCommandType,
} from '../../payloads/v8/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals';
import type {
RESTDeleteAPIWebhookWithTokenMessageResult,
RESTGetAPIWebhookWithTokenMessageResult,
@@ -25,22 +26,18 @@ export type RESTGetAPIApplicationCommandsResult = APIApplicationCommand[];
*/
export type RESTGetAPIApplicationCommandResult = APIApplicationCommand;
type RESTPostAPIBaseApplicationCommandsJSONBody = Omit<
APIApplicationCommand,
'id' | 'application_id' | 'description' | 'type' | 'version'
type RESTPostAPIBaseApplicationCommandsJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<
Omit<APIApplicationCommand, 'id' | 'application_id' | 'description' | 'type' | 'version' | 'guild_id'>
>;
/**
* https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
*/
export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody {
type?: ApplicationCommandType.ChatInput;
/**
* Whether this application command option should be autocompleted
*/
autocomplete?: boolean;
description: string;
}
export type RESTPostAPIChatInputApplicationCommandsJSONBody = RESTPostAPIBaseApplicationCommandsJSONBody &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
type?: ApplicationCommandType.ChatInput;
description: string;
}>;
/**
* https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
@@ -64,7 +61,7 @@ export type RESTPostAPIApplicationCommandsResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command
*/
export type RESTPatchAPIApplicationCommandJSONBody = Partial<RESTPostAPIApplicationCommandsJSONBody>;
export type RESTPatchAPIApplicationCommandJSONBody = StrictPartial<RESTPostAPIApplicationCommandsJSONBody>;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command
@@ -104,7 +101,7 @@ export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandJSONBody = Partial<RESTPostAPIApplicationCommandsJSONBody>;
export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial<RESTPostAPIApplicationCommandsJSONBody>;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command

View File

@@ -1,5 +1,6 @@
import type { Snowflake } from '../../globals';
import type { APIStageInstance, StageInstancePrivacyLevel } from '../../payloads/v8/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface } from '../../utils/internals';
/**
* https://discord.com/developers/docs/resources/stage-instance#create-stage-instance
@@ -34,7 +35,7 @@ export type RESTGetAPIStageInstanceResult = APIStageInstance;
/**
* https://discord.com/developers/docs/resources/stage-instance#update-stage-instance
*/
export interface RESTPatchAPIStageInstanceJSONBody {
export type RESTPatchAPIStageInstanceJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The topic of the stage instance (1-120 characters)
*/
@@ -43,7 +44,7 @@ export interface RESTPatchAPIStageInstanceJSONBody {
* The privacy level of the stage instance
*/
privacy_level?: StageInstancePrivacyLevel;
}
}>;
/**
* https://discord.com/developers/docs/resources/stage-instance#update-stage-instance

View File

@@ -1,4 +1,5 @@
import type { APISticker, APIStickerPack } from '../../payloads/v8/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface } from '../../utils/internals';
export type RESTGetAPIStickerResult = APISticker;
@@ -31,7 +32,7 @@ export interface RESTPostAPIGuildStickerFormDataBody {
export type RESTPostAPIGuildStickerResult = APISticker;
export interface RESTPatchAPIGuildStickerJSONBody {
export type RESTPatchAPIGuildStickerJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the sticker (2-30 characters)
*/
@@ -44,7 +45,7 @@ export interface RESTPatchAPIGuildStickerJSONBody {
* The Discord name of a unicode emoji representing the sticker's expression (2-200 characters)
*/
tags?: string;
}
}>;
export type RESTPatchAPIGuildStickerResult = APISticker;

View File

@@ -1,4 +1,5 @@
import type { APIGuild, APITemplate } from '../../payloads/v8/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals';
/**
* https://discord.com/developers/docs/resources/template#get-template
@@ -8,7 +9,7 @@ export type RESTGetAPITemplateResult = APITemplate;
/**
* https://discord.com/developers/docs/resources/template#create-guild-from-template
*/
export interface RESTPostAPITemplateCreateGuildJSONBody {
export type RESTPostAPITemplateCreateGuildJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the guild (2-100 characters)
*/
@@ -19,7 +20,8 @@ export interface RESTPostAPITemplateCreateGuildJSONBody {
* See https://discord.com/developers/docs/reference#image-data
*/
icon?: string;
}
}>;
/**
* https://discord.com/developers/docs/resources/template#create-guild-from-template
*/
@@ -33,7 +35,7 @@ export type RESTGetAPIGuildTemplatesResult = APITemplate[];
/**
* https://discord.com/developers/docs/resources/template#create-guild-template
*/
export interface RESTPostAPIGuildTemplatesJSONBody {
export type RESTPostAPIGuildTemplatesJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the template (1-100 characters)
*/
@@ -42,7 +44,7 @@ export interface RESTPostAPIGuildTemplatesJSONBody {
* Description for the template (0-120 characters)
*/
description?: string | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/template#create-guild-template
@@ -57,7 +59,7 @@ export type RESTPutAPIGuildTemplateSyncResult = APITemplate;
/**
* https://discord.com/developers/docs/resources/template#modify-guild-template
*/
export type RESTPatchAPIGuildTemplateJSONBody = Partial<RESTPostAPIGuildTemplatesJSONBody>;
export type RESTPatchAPIGuildTemplateJSONBody = StrictPartial<RESTPostAPIGuildTemplatesJSONBody>;
/**
* https://discord.com/developers/docs/resources/template#modify-guild-template

View File

@@ -1,5 +1,6 @@
import type { Permissions, Snowflake } from '../../globals';
import type { APIChannel, APIConnection, APIGuildMember, APIUser, GuildFeature } from '../../payloads/v8/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface } from '../../utils/internals';
/**
* https://discord.com/developers/docs/resources/user#get-current-user
@@ -19,7 +20,7 @@ export type RESTGetCurrentUserGuildMemberResult = APIGuildMember;
/**
* https://discord.com/developers/docs/resources/user#modify-current-user
*/
export interface RESTPatchAPICurrentUserJSONBody {
export type RESTPatchAPICurrentUserJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* User's username, if changed may cause the user's discriminator to be randomized
*/
@@ -28,7 +29,7 @@ export interface RESTPatchAPICurrentUserJSONBody {
* If passed, modifies the user's avatar
*/
avatar?: string | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/user#modify-current-user

View File

@@ -7,12 +7,12 @@ import type {
APIWebhook,
APIAttachment,
} from '../../payloads/v8/index';
import type { Nullable } from '../../utils/internals';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, Nullable } from '../../utils/internals';
/**
* https://discord.com/developers/docs/resources/webhook#create-webhook
*/
export interface RESTPostAPIChannelWebhookJSONBody {
export type RESTPostAPIChannelWebhookJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the webhook (1-80 characters)
*/
@@ -23,7 +23,7 @@ export interface RESTPostAPIChannelWebhookJSONBody {
* See https://discord.com/developers/docs/reference#image-data
*/
avatar?: string | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/webhook#create-webhook
@@ -53,7 +53,7 @@ export type RESTGetAPIWebhookWithTokenResult = Omit<APIWebhook, 'user'>;
/**
* https://discord.com/developers/docs/resources/webhook#modify-webhook
*/
export interface RESTPatchAPIWebhookJSONBody {
export type RESTPatchAPIWebhookJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The default name of the webhook
*/
@@ -68,7 +68,7 @@ export interface RESTPatchAPIWebhookJSONBody {
* The new channel id this webhook should be moved to
*/
channel_id?: Snowflake;
}
}>;
/**
* https://discord.com/developers/docs/resources/webhook#modify-webhook
@@ -98,7 +98,7 @@ export type RESTDeleteAPIWebhookWithTokenResult = never;
/**
* https://discord.com/developers/docs/resources/webhook#execute-webhook
*/
export interface RESTPostAPIWebhookWithTokenJSONBody {
export type RESTPostAPIWebhookWithTokenJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The message contents (up to 2000 characters)
*/
@@ -139,7 +139,7 @@ export interface RESTPostAPIWebhookWithTokenJSONBody {
* Attachment objects with filename and description
*/
attachments?: (Pick<APIAttachment, 'id' | 'description'> & Partial<Pick<APIAttachment, 'filename'>>)[];
}
}>;
/**
* https://discord.com/developers/docs/resources/webhook#execute-webhook
@@ -164,6 +164,10 @@ export interface RESTPostAPIWebhookWithTokenQuery {
* @default false
*/
wait?: boolean;
/**
* Send a message to the specified thread within a webhook's channel. The thread will automatically be unarchived.
*/
thread_id?: Snowflake;
}
/**
@@ -223,19 +227,18 @@ export type RESTGetAPIWebhookWithTokenMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message
*/
export interface RESTPatchAPIWebhookWithTokenMessageJSONBody
extends Nullable<
Pick<RESTPostAPIWebhookWithTokenJSONBody, 'content' | 'embeds' | 'allowed_mentions' | 'components'>
> {
/**
* Attached files to keep
*
* Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body.
*
* See https://discord.com/developers/docs/resources/channel#attachment-object
*/
attachments?: (Pick<APIAttachment, 'id'> & Partial<Pick<APIAttachment, 'filename' | 'description'>>)[];
}
export type RESTPatchAPIWebhookWithTokenMessageJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<
Nullable<Pick<RESTPostAPIWebhookWithTokenJSONBody, 'content' | 'embeds' | 'allowed_mentions' | 'components'>> & {
/**
* Attached files to keep
*
* Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body.
*
* See https://discord.com/developers/docs/resources/channel#attachment-object
*/
attachments?: (Pick<APIAttachment, 'id'> & Partial<Pick<APIAttachment, 'filename' | 'description'>>)[];
}
>;
/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message

View File

@@ -20,6 +20,7 @@ import type {
ThreadAutoArchiveDuration,
VideoQualityMode,
} from '../../payloads/v9/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals';
/**
* https://discord.com/developers/docs/resources/channel#get-channel
@@ -29,7 +30,7 @@ export type RESTGetAPIChannelResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/channel#modify-channel
*/
export interface RESTPatchAPIChannelJSONBody {
export type RESTPatchAPIChannelJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* 1-100 character channel name
*
@@ -136,7 +137,7 @@ export interface RESTPatchAPIChannelJSONBody {
* Channel types: privateThread
*/
invitable?: boolean;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#modify-channel
@@ -185,20 +186,21 @@ export type RESTGetAPIChannelMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
*/
export type APIMessageReferenceSend = Partial<APIMessageReference> &
Required<Pick<APIMessageReference, 'message_id'>> & {
export type APIMessageReferenceSend = StrictPartial<APIMessageReference> &
Required<Pick<APIMessageReference, 'message_id'>> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message
*
* @default true
*/
fail_if_not_exists?: boolean;
};
}>;
/**
* https://discord.com/developers/docs/resources/channel#create-message
*/
export interface RESTPostAPIChannelMessageJSONBody {
export type RESTPostAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The message contents (up to 2000 characters)
*/
@@ -252,7 +254,7 @@ export interface RESTPostAPIChannelMessageJSONBody {
* Attachment objects with filename and description
*/
attachments?: (Pick<APIAttachment, 'id' | 'description'> & Partial<Pick<APIAttachment, 'filename'>>)[];
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#create-message
@@ -325,7 +327,7 @@ export type RESTDeleteAPIChannelMessageReactionResult = never;
/**
* https://discord.com/developers/docs/resources/channel#edit-message
*/
export interface RESTPatchAPIChannelMessageJSONBody {
export type RESTPatchAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The new message contents (up to 2000 characters)
*/
@@ -372,7 +374,7 @@ export interface RESTPatchAPIChannelMessageJSONBody {
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent[] | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#edit-message
@@ -446,7 +448,7 @@ export type RESTGetAPIChannelInvitesResult = APIExtendedInvite[];
/**
* https://discord.com/developers/docs/resources/channel#create-channel-invite
*/
export interface RESTPostAPIChannelInviteJSONBody {
export type RESTPostAPIChannelInviteJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Duration of invite in seconds before expiry, or 0 for never
*
@@ -490,7 +492,7 @@ export interface RESTPostAPIChannelInviteJSONBody {
* - The application must have the `EMBEDDED` flag
*/
target_application_id?: Snowflake;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#create-channel-invite
@@ -540,7 +542,7 @@ export type RESTDeleteAPIChannelPinResult = never;
/**
* https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
*/
export interface RESTPutAPIChannelRecipientJSONBody {
export type RESTPutAPIChannelRecipientJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Access token of a user that has granted your app the `gdm.join` scope
*/
@@ -549,7 +551,7 @@ export interface RESTPutAPIChannelRecipientJSONBody {
* Nickname of the user being added
*/
nick?: string;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
@@ -564,7 +566,7 @@ export type RESTDeleteAPIChannelRecipientResult = unknown;
/**
* https://discord.com/developers/docs/resources/channel#start-thread-with-message
*/
export interface RESTPostAPIChannelMessagesThreadsJSONBody {
export type RESTPostAPIChannelMessagesThreadsJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* 1-100 character thread name
*/
@@ -579,7 +581,7 @@ export interface RESTPostAPIChannelMessagesThreadsJSONBody {
* Amount of seconds a user has to wait before sending another message (0-21600)
*/
rate_limit_per_user?: number;
}
}>;
/**
* https://discord.com/developers/docs/resources/channel#start-thread-with-message
@@ -589,23 +591,24 @@ export type RESTPostAPIChannelMessagesThreadsResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/channel#start-thread-without-message
*/
export interface RESTPostAPIChannelThreadsJSONBody extends RESTPostAPIChannelMessagesThreadsJSONBody {
/**
* The type of thread to create
*
* In API v9, `type` defaults to `PRIVATE_THREAD`.
* In API v10 this will be changed to be a required field, with no default.
*
* See https://discord.com/developers/docs/resources/channel#channel-object-channel-types
*
* @default 12
*/
type?: ChannelType.GuildNewsThread | ChannelType.GuildPublicThread | ChannelType.GuildPrivateThread;
/**
* Whether non-moderators can add other non-moderators to the thread; only available when creating a private thread
*/
invitable?: boolean;
}
export type RESTPostAPIChannelThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The type of thread to create
*
* In API v9, `type` defaults to `PRIVATE_THREAD`.
* In API v10 this will be changed to be a required field, with no default.
*
* See https://discord.com/developers/docs/resources/channel#channel-object-channel-types
*
* @default 12
*/
type?: ChannelType.GuildNewsThread | ChannelType.GuildPublicThread | ChannelType.GuildPrivateThread;
/**
* Whether non-moderators can add other non-moderators to the thread; only available when creating a private thread
*/
invitable?: boolean;
}>;
/**
* https://discord.com/developers/docs/resources/channel#start-thread-without-message

View File

@@ -1,5 +1,6 @@
import type { Snowflake } from '../../globals';
import type { APIEmoji } from '../../payloads/v9/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface } from '../../utils/internals';
/**
* https://discord.com/developers/docs/resources/emoji#list-guild-emojis
@@ -14,7 +15,7 @@ export type RESTGetAPIGuildEmojiResult = APIEmoji;
/**
* https://discord.com/developers/docs/resources/emoji#create-guild-emoji-json-params
*/
export interface RESTPostAPIGuildEmojiJSONBody {
export type RESTPostAPIGuildEmojiJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the emoji
*/
@@ -29,7 +30,7 @@ export interface RESTPostAPIGuildEmojiJSONBody {
* Roles for which this emoji will be whitelisted
*/
roles?: Snowflake[];
}
}>;
/**
* https://discord.com/developers/docs/resources/emoji#create-guild-emoji
@@ -39,7 +40,7 @@ export type RESTPostAPIGuildEmojiResult = APIEmoji;
/**
* https://discord.com/developers/docs/resources/emoji#modify-guild-emoji
*/
export interface RESTPatchAPIGuildEmojiJSONBody {
export type RESTPatchAPIGuildEmojiJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the emoji
*/
@@ -48,7 +49,7 @@ export interface RESTPatchAPIGuildEmojiJSONBody {
* Roles for which this emoji will be whitelisted
*/
roles?: Snowflake[] | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/emoji#modify-guild-emoji

View File

@@ -21,21 +21,27 @@ import type {
GuildVerificationLevel,
GuildWidgetStyle,
} from '../../payloads/v9/index';
import type { Nullable } from '../../utils/internals';
import type {
AddUndefinedToPossiblyUndefinedPropertiesOfInterface,
Nullable,
StrictPartial,
StrictRequired,
} from '../../utils/internals';
import type { RESTPutAPIChannelPermissionJSONBody } from './channel';
export interface APIGuildCreateOverwrite extends RESTPutAPIChannelPermissionJSONBody {
id: number | string;
}
export type APIGuildCreatePartialChannel = Partial<
export type APIGuildCreatePartialChannel = StrictPartial<
Pick<APIChannel, 'type' | 'topic' | 'nsfw' | 'bitrate' | 'user_limit' | 'rate_limit_per_user'>
> & {
name: string;
id?: number | string;
parent_id?: number | string | null;
permission_overwrites?: APIGuildCreateOverwrite[];
};
> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
name: string;
id?: number | string;
parent_id?: number | string | null;
permission_overwrites?: APIGuildCreateOverwrite[];
}>;
export interface APIGuildCreateRole extends RESTPostAPIGuildRoleJSONBody {
id: number | string;
@@ -44,7 +50,7 @@ export interface APIGuildCreateRole extends RESTPostAPIGuildRoleJSONBody {
/**
* https://discord.com/developers/docs/resources/guild#create-guild
*/
export interface RESTPostAPIGuildsJSONBody {
export type RESTPostAPIGuildsJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the guild (2-100 characters)
*/
@@ -127,7 +133,7 @@ export interface RESTPostAPIGuildsJSONBody {
* Whether the boosts progress bar should be enabled.
*/
premium_progress_bar_enabled?: boolean;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#create-guild
@@ -159,7 +165,7 @@ export type RESTGetAPIGuildPreviewResult = APIGuildPreview;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild
*/
export interface RESTPatchAPIGuildJSONBody {
export type RESTPatchAPIGuildJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* New name for the guild (2-100 characters)
*/
@@ -258,7 +264,7 @@ export interface RESTPatchAPIGuildJSONBody {
* Whether the boosts progress bar should be enabled.
*/
premium_progress_bar_enabled?: boolean;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild
@@ -288,24 +294,26 @@ export type RESTPostAPIGuildChannelResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions
*/
export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{
/**
* Channel id
*/
id: Snowflake;
/**
* Sorting position of the channel
*/
position: number;
/**
* Sync channel overwrites with the new parent, when moving to a new `parent_id`
*/
lock_permissions?: boolean;
/**
* The new parent id of this channel
*/
parent_id?: Snowflake | null;
}>;
export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Channel id
*/
id: Snowflake;
/**
* Sorting position of the channel
*/
position: number;
/**
* Sync channel overwrites with the new parent, when moving to a new `parent_id`
*/
lock_permissions?: boolean;
/**
* The new parent id of this channel
*/
parent_id?: Snowflake | null;
}>
>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions
@@ -366,7 +374,7 @@ export type RESTGetAPIGuildMembersSearchResult = APIGuildMember[];
/**
* https://discord.com/developers/docs/resources/guild#add-guild-member
*/
export interface RESTPutAPIGuildMemberJSONBody {
export type RESTPutAPIGuildMemberJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* An oauth2 access token granted with the `guilds.join` to the bot's application for the user you want to add to the guild
*/
@@ -395,14 +403,14 @@ export interface RESTPutAPIGuildMemberJSONBody {
* Requires `DEAFEN_MEMBERS` permission
*/
deaf?: boolean;
}
}>;
export type RESTPutAPIGuildMemberResult = APIGuildMember | undefined;
export type RESTPutAPIGuildMemberResult = APIGuildMember | never;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-member
*/
export interface RESTPatchAPIGuildMemberJSONBody {
export type RESTPatchAPIGuildMemberJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Value to set users nickname to
*
@@ -433,7 +441,7 @@ export interface RESTPatchAPIGuildMemberJSONBody {
* Requires `MOVE_MEMBERS` permission
*/
channel_id?: Snowflake | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#add-guild-member
@@ -443,19 +451,20 @@ export type RESTPatchAPIGuildMemberResult = APIGuildMember;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-nick
*/
export interface RESTPatchAPICurrentGuildMemberNicknameJSONBody {
export type RESTPatchAPICurrentGuildMemberNicknameJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Value to set users nickname to
*
* Requires `CHANGE_NICKNAME` permission
*/
nick?: string | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-nick
*/
export type RESTPatchAPICurrentGuildMemberNicknameResult = Required<RESTPatchAPICurrentGuildMemberNicknameJSONBody>;
export type RESTPatchAPICurrentGuildMemberNicknameResult =
StrictRequired<RESTPatchAPICurrentGuildMemberNicknameJSONBody>;
/**
* https://discord.com/developers/docs/resources/guild#add-guild-member-role
@@ -485,7 +494,7 @@ export type RESTGetAPIGuildBanResult = APIBan;
/**
* https://discord.com/developers/docs/resources/guild#create-guild-ban
*/
export interface RESTPutAPIGuildBanJSONBody {
export type RESTPutAPIGuildBanJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Number of days to delete messages for (0-7)
*/
@@ -494,7 +503,7 @@ export interface RESTPutAPIGuildBanJSONBody {
* Reason for the ban
*/
reason?: string;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#create-guild-ban
@@ -514,7 +523,7 @@ export type RESTGetAPIGuildRolesResult = APIRole[];
/**
* https://discord.com/developers/docs/resources/guild#create-guild-role
*/
export interface RESTPostAPIGuildRoleJSONBody {
export type RESTPostAPIGuildRoleJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the role
*
@@ -524,7 +533,7 @@ export interface RESTPostAPIGuildRoleJSONBody {
/**
* Bitwise value of the enabled/disabled permissions
*
* @default "default role permissions in guild"
* @default "default role permissions in guild"
*/
permissions?: Permissions | null;
/**
@@ -553,7 +562,7 @@ export interface RESTPostAPIGuildRoleJSONBody {
* @default false
*/
mentionable?: boolean | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#create-guild-role
@@ -563,16 +572,18 @@ export type RESTPostAPIGuildRoleResult = APIRole;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
*/
export type RESTPatchAPIGuildRolePositionsJSONBody = Array<{
/**
* Role id
*/
id: Snowflake;
/**
* Sorting position of the role
*/
position?: number;
}>;
export type RESTPatchAPIGuildRolePositionsJSONBody = Array<
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Role id
*/
id: Snowflake;
/**
* Sorting position of the role
*/
position?: number;
}>
>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
@@ -582,7 +593,7 @@ export type RESTPatchAPIGuildRolePositionsResult = APIRole[];
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role
*/
export interface RESTPatchAPIGuildRoleJSONBody {
export type RESTPatchAPIGuildRoleJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the role
*/
@@ -611,7 +622,7 @@ export interface RESTPatchAPIGuildRoleJSONBody {
* Whether the role should be mentionable
*/
mentionable?: boolean | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-role
@@ -654,7 +665,7 @@ export interface RESTGetAPIGuildPruneCountResult {
/**
* https://discord.com/developers/docs/resources/guild#begin-guild-prune
*/
export interface RESTPostAPIGuildPruneJSONBody {
export type RESTPostAPIGuildPruneJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Number of days to count prune for (1 or more)
*
@@ -671,7 +682,7 @@ export interface RESTPostAPIGuildPruneJSONBody {
* Role(s) to include
*/
include_roles?: Snowflake[];
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#begin-guild-prune
@@ -708,7 +719,7 @@ export type RESTGetAPIGuildWidgetSettingsResult = APIGuildWidgetSettings;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-widget
*/
export type RESTPatchAPIGuildWidgetSettingsJSONBody = Partial<APIGuildWidgetSettings>;
export type RESTPatchAPIGuildWidgetSettingsJSONBody = StrictPartial<APIGuildWidgetSettings>;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-widget
@@ -748,7 +759,7 @@ export type RESTGetAPIGuildWidgetImageResult = ArrayBuffer;
export type RESTGetAPIGuildMemberVerificationResult = APIGuildMembershipScreening;
export interface RESTPatchAPIGuildMemberVerificationJSONBody {
export type RESTPatchAPIGuildMemberVerificationJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Whether Membership Screening is enabled
*/
@@ -761,11 +772,11 @@ export interface RESTPatchAPIGuildMemberVerificationJSONBody {
* The server description to show in the screening form
*/
description?: string | null;
}
}>;
export type RESTPatchAPIGuildMemberVerificationResult = APIGuildMembershipScreening;
export interface RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody {
export type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The id of the channel the user is currently in
*/
@@ -778,9 +789,9 @@ export interface RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody {
* Sets the user's request to speak
*/
request_to_speak_timestamp?: string | null;
}
}>;
export interface RESTPatchAPIGuildVoiceStateUserJSONBody {
export type RESTPatchAPIGuildVoiceStateUserJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The id of the channel the user is currently in
*/
@@ -789,7 +800,7 @@ export interface RESTPatchAPIGuildVoiceStateUserJSONBody {
* Toggles the user's suppress state
*/
suppress?: boolean;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen
@@ -799,9 +810,10 @@ export type RESTGetAPIGuildWelcomeScreenResult = APIGuildWelcomeScreen;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen
*/
export interface RESTPatchAPIGuildWelcomeScreenJSONBody extends Nullable<Partial<APIGuildWelcomeScreen>> {
/**
* Whether the welcome screen is enabled
*/
enabled?: boolean | null;
}
export type RESTPatchAPIGuildWelcomeScreenJSONBody = Nullable<StrictPartial<APIGuildWelcomeScreen>> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Whether the welcome screen is enabled
*/
enabled?: boolean | null;
}>;

View File

@@ -1,12 +1,12 @@
import type { Snowflake } from '../../globals';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals';
import type {
APIGuildScheduledEvent,
GuildScheduledEventEntityType,
GuildScheduledEventPrivacyLevel,
APIGuildScheduledEventEntityMetadata,
GuildScheduledEventStatus,
APIGuildMember,
APIUser,
APIGuildScheduledEventUser,
} from '../../v9';
/**
@@ -27,7 +27,7 @@ export type RESTGetAPIGuildScheduledEventsResult = APIGuildScheduledEvent[];
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event
*/
export interface RESTPostAPIGuildScheduledEventJSONBody {
export type RESTPostAPIGuildScheduledEventJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The stage channel id of the guild event
*/
@@ -60,7 +60,7 @@ export interface RESTPostAPIGuildScheduledEventJSONBody {
* The entity metadata of the scheduled event
*/
entity_metadata?: APIGuildScheduledEventEntityMetadata;
}
}>;
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event
@@ -85,12 +85,13 @@ export type RESTGetAPIGuildScheduledEventResult = APIGuildScheduledEvent;
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event
*/
export interface RESTPatchAPIGuildScheduledEventJSONBody extends Partial<RESTPostAPIGuildScheduledEventJSONBody> {
/**
* The status of the scheduled event
*/
status?: GuildScheduledEventStatus;
}
export type RESTPatchAPIGuildScheduledEventJSONBody = StrictPartial<RESTPostAPIGuildScheduledEventJSONBody> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The status of the scheduled event
*/
status?: GuildScheduledEventStatus;
}>;
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event
@@ -130,21 +131,3 @@ export interface RESTGetAPIGuildScheduledEventUsersQuery {
* https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event-users
*/
export type RESTGetAPIGuildScheduledEventUsersResult = APIGuildScheduledEventUser[];
/**
* https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-user-object-guild-scheduled-event-user-structure
*/
export interface APIGuildScheduledEventUser {
/**
* The scheduled event id which the user subscribed to
*/
guild_scheduled_event_id: Snowflake;
/**
* The user which subscribed to the event
*/
user: APIUser;
/**
* The guild member data for this user for the guild which this event belongs to, if any
*/
member?: APIGuildMember;
}

View File

@@ -6,6 +6,7 @@ import type {
APIInteractionResponseCallbackData,
ApplicationCommandType,
} from '../../payloads/v9/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals';
import type {
RESTDeleteAPIWebhookWithTokenMessageResult,
RESTGetAPIWebhookWithTokenMessageResult,
@@ -25,22 +26,18 @@ export type RESTGetAPIApplicationCommandsResult = APIApplicationCommand[];
*/
export type RESTGetAPIApplicationCommandResult = APIApplicationCommand;
type RESTPostAPIBaseApplicationCommandsJSONBody = Omit<
APIApplicationCommand,
'id' | 'application_id' | 'description' | 'type' | 'version'
type RESTPostAPIBaseApplicationCommandsJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<
Omit<APIApplicationCommand, 'id' | 'application_id' | 'description' | 'type' | 'version' | 'guild_id'>
>;
/**
* https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
*/
export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody {
type?: ApplicationCommandType.ChatInput;
/**
* Whether this application command option should be autocompleted
*/
autocomplete?: boolean;
description: string;
}
export type RESTPostAPIChatInputApplicationCommandsJSONBody = RESTPostAPIBaseApplicationCommandsJSONBody &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
type?: ApplicationCommandType.ChatInput;
description: string;
}>;
/**
* https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
@@ -64,7 +61,7 @@ export type RESTPostAPIApplicationCommandsResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command
*/
export type RESTPatchAPIApplicationCommandJSONBody = Partial<RESTPostAPIApplicationCommandsJSONBody>;
export type RESTPatchAPIApplicationCommandJSONBody = StrictPartial<RESTPostAPIApplicationCommandsJSONBody>;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command
@@ -104,7 +101,7 @@ export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandJSONBody = Partial<RESTPostAPIApplicationCommandsJSONBody>;
export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial<RESTPostAPIApplicationCommandsJSONBody>;
/**
* https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command

View File

@@ -1,5 +1,6 @@
import type { Snowflake } from '../../globals';
import type { APIStageInstance, StageInstancePrivacyLevel } from '../../payloads/v9/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface } from '../../utils/internals';
/**
* https://discord.com/developers/docs/resources/stage-instance#create-stage-instance
@@ -34,7 +35,7 @@ export type RESTGetAPIStageInstanceResult = APIStageInstance;
/**
* https://discord.com/developers/docs/resources/stage-instance#update-stage-instance
*/
export interface RESTPatchAPIStageInstanceJSONBody {
export type RESTPatchAPIStageInstanceJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The topic of the stage instance (1-120 characters)
*/
@@ -43,7 +44,7 @@ export interface RESTPatchAPIStageInstanceJSONBody {
* The privacy level of the stage instance
*/
privacy_level?: StageInstancePrivacyLevel;
}
}>;
/**
* https://discord.com/developers/docs/resources/stage-instance#update-stage-instance

View File

@@ -1,4 +1,5 @@
import type { APISticker, APIStickerPack } from '../../payloads/v9/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface } from '../../utils/internals';
export type RESTGetAPIStickerResult = APISticker;
@@ -31,7 +32,7 @@ export interface RESTPostAPIGuildStickerFormDataBody {
export type RESTPostAPIGuildStickerResult = APISticker;
export interface RESTPatchAPIGuildStickerJSONBody {
export type RESTPatchAPIGuildStickerJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the sticker (2-30 characters)
*/
@@ -44,7 +45,7 @@ export interface RESTPatchAPIGuildStickerJSONBody {
* The Discord name of a unicode emoji representing the sticker's expression (2-200 characters)
*/
tags?: string;
}
}>;
export type RESTPatchAPIGuildStickerResult = APISticker;

View File

@@ -1,4 +1,5 @@
import type { APIGuild, APITemplate } from '../../payloads/v9/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals';
/**
* https://discord.com/developers/docs/resources/template#get-template
@@ -8,7 +9,7 @@ export type RESTGetAPITemplateResult = APITemplate;
/**
* https://discord.com/developers/docs/resources/template#create-guild-from-template
*/
export interface RESTPostAPITemplateCreateGuildJSONBody {
export type RESTPostAPITemplateCreateGuildJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the guild (2-100 characters)
*/
@@ -19,7 +20,8 @@ export interface RESTPostAPITemplateCreateGuildJSONBody {
* See https://discord.com/developers/docs/reference#image-data
*/
icon?: string;
}
}>;
/**
* https://discord.com/developers/docs/resources/template#create-guild-from-template
*/
@@ -33,7 +35,7 @@ export type RESTGetAPIGuildTemplatesResult = APITemplate[];
/**
* https://discord.com/developers/docs/resources/template#create-guild-template
*/
export interface RESTPostAPIGuildTemplatesJSONBody {
export type RESTPostAPIGuildTemplatesJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the template (1-100 characters)
*/
@@ -42,7 +44,7 @@ export interface RESTPostAPIGuildTemplatesJSONBody {
* Description for the template (0-120 characters)
*/
description?: string | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/template#create-guild-template
@@ -57,7 +59,7 @@ export type RESTPutAPIGuildTemplateSyncResult = APITemplate;
/**
* https://discord.com/developers/docs/resources/template#modify-guild-template
*/
export type RESTPatchAPIGuildTemplateJSONBody = Partial<RESTPostAPIGuildTemplatesJSONBody>;
export type RESTPatchAPIGuildTemplateJSONBody = StrictPartial<RESTPostAPIGuildTemplatesJSONBody>;
/**
* https://discord.com/developers/docs/resources/template#modify-guild-template

View File

@@ -1,5 +1,6 @@
import type { Permissions, Snowflake } from '../../globals';
import type { APIChannel, APIConnection, APIGuildMember, APIUser, GuildFeature } from '../../payloads/v9/index';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface } from '../../utils/internals';
/**
* https://discord.com/developers/docs/resources/user#get-current-user
@@ -19,7 +20,7 @@ export type RESTGetCurrentUserGuildMemberResult = APIGuildMember;
/**
* https://discord.com/developers/docs/resources/user#modify-current-user
*/
export interface RESTPatchAPICurrentUserJSONBody {
export type RESTPatchAPICurrentUserJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* User's username, if changed may cause the user's discriminator to be randomized
*/
@@ -28,7 +29,7 @@ export interface RESTPatchAPICurrentUserJSONBody {
* If passed, modifies the user's avatar
*/
avatar?: string | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/user#modify-current-user

View File

@@ -7,12 +7,12 @@ import type {
APIWebhook,
APIAttachment,
} from '../../payloads/v9/index';
import type { Nullable } from '../../utils/internals';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, Nullable } from '../../utils/internals';
/**
* https://discord.com/developers/docs/resources/webhook#create-webhook
*/
export interface RESTPostAPIChannelWebhookJSONBody {
export type RESTPostAPIChannelWebhookJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Name of the webhook (1-80 characters)
*/
@@ -23,7 +23,7 @@ export interface RESTPostAPIChannelWebhookJSONBody {
* See https://discord.com/developers/docs/reference#image-data
*/
avatar?: string | null;
}
}>;
/**
* https://discord.com/developers/docs/resources/webhook#create-webhook
@@ -53,7 +53,7 @@ export type RESTGetAPIWebhookWithTokenResult = Omit<APIWebhook, 'user'>;
/**
* https://discord.com/developers/docs/resources/webhook#modify-webhook
*/
export interface RESTPatchAPIWebhookJSONBody {
export type RESTPatchAPIWebhookJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The default name of the webhook
*/
@@ -68,7 +68,7 @@ export interface RESTPatchAPIWebhookJSONBody {
* The new channel id this webhook should be moved to
*/
channel_id?: Snowflake;
}
}>;
/**
* https://discord.com/developers/docs/resources/webhook#modify-webhook
@@ -98,7 +98,7 @@ export type RESTDeleteAPIWebhookWithTokenResult = never;
/**
* https://discord.com/developers/docs/resources/webhook#execute-webhook
*/
export interface RESTPostAPIWebhookWithTokenJSONBody {
export type RESTPostAPIWebhookWithTokenJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The message contents (up to 2000 characters)
*/
@@ -139,7 +139,7 @@ export interface RESTPostAPIWebhookWithTokenJSONBody {
* Attachment objects with filename and description
*/
attachments?: (Pick<APIAttachment, 'id' | 'description'> & Partial<Pick<APIAttachment, 'filename'>>)[];
}
}>;
/**
* https://discord.com/developers/docs/resources/webhook#execute-webhook
@@ -227,19 +227,18 @@ export type RESTGetAPIWebhookWithTokenMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message
*/
export interface RESTPatchAPIWebhookWithTokenMessageJSONBody
extends Nullable<
Pick<RESTPostAPIWebhookWithTokenJSONBody, 'content' | 'embeds' | 'allowed_mentions' | 'components'>
> {
/**
* Attached files to keep
*
* Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body.
*
* See https://discord.com/developers/docs/resources/channel#attachment-object
*/
attachments?: (Pick<APIAttachment, 'id'> & Partial<Pick<APIAttachment, 'filename' | 'description'>>)[];
}
export type RESTPatchAPIWebhookWithTokenMessageJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<
Nullable<Pick<RESTPostAPIWebhookWithTokenJSONBody, 'content' | 'embeds' | 'allowed_mentions' | 'components'>> & {
/**
* Attached files to keep
*
* Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body.
*
* See https://discord.com/developers/docs/resources/channel#attachment-object
*/
attachments?: (Pick<APIAttachment, 'id'> & Partial<Pick<APIAttachment, 'filename' | 'description'>>)[];
}
>;
/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message

View File

@@ -6,9 +6,7 @@ import {
APIGuildInteraction,
APIInteraction,
APIInteractionGuildMember,
APIMessageButtonInteractionData,
APIMessageComponentInteraction,
APIMessageSelectMenuInteractionData,
APIUser,
ComponentType,
InteractionType,
@@ -28,11 +26,13 @@ if (interaction.type === InteractionType.MessageComponent) {
const { data } = interaction;
if (data.component_type === ComponentType.Button) {
expectType<APIMessageButtonInteractionData>(data);
// TODO: For some reason, tsd yields a `Parameter type APIMessageButtonInteractionData is not identical to argument type APIMessageButtonInteractionData.` error
// expectType<APIMessageButtonInteractionData>(data);
}
if (data.component_type === ComponentType.SelectMenu) {
expectType<APIMessageSelectMenuInteractionData>(data);
// TODO: for some reason, tsd yields a `Parameter type APIMessageSelectMenuInteractionData is not identical to argument type APIMessageSelectMenuInteractionData.` error
// expectType<APIMessageSelectMenuInteractionData>(data);
expectType<string[]>(data.values);
}
}

View File

@@ -13,7 +13,8 @@
"target": "ES2020",
"importsNotUsedAsValues": "error",
"strictNullChecks": true,
"preserveConstEnums": true
"preserveConstEnums": true,
"exactOptionalPropertyTypes": true
},
"include": [
"globals.ts",

View File

@@ -1,3 +1,15 @@
export type Nullable<T> = {
[P in keyof T]: T[P] | null;
};
/**
* Allows support for TS 4.5's `exactOptionalPropertyTypes` option by ensuring a property present and undefined is valid
* (since JSON.stringify ignores undefined properties)
*/
export type AddUndefinedToPossiblyUndefinedPropertiesOfInterface<Base> = {
[K in keyof Base]: Base[K] extends Exclude<Base[K], undefined> ? Base[K] : Base[K] | undefined;
};
export type StrictPartial<Base> = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<Partial<Base>>;
export type StrictRequired<Base> = Required<{ [K in keyof Base]: Exclude<Base[K], undefined> }>;