Skip to content

Commit

Permalink
feat(Attachments): multi uploads and alt text (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
advaith1 committed Oct 29, 2021
1 parent 7c36a6c commit fdf133e
Show file tree
Hide file tree
Showing 16 changed files with 136 additions and 288 deletions.
4 changes: 4 additions & 0 deletions deno/payloads/v8/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,10 @@ export interface APIAttachment {
* Name of file attached
*/
filename: string;
/**
* Description for the file
*/
description?: string;
/**
* The attachment's media type
*
Expand Down
4 changes: 4 additions & 0 deletions deno/payloads/v9/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,10 @@ export interface APIAttachment {
* Name of file attached
*/
filename: string;
/**
* Description for the file
*/
description?: string;
/**
* The attachment's media type
*
Expand Down
36 changes: 12 additions & 24 deletions deno/rest/v8/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,28 +214,23 @@ export interface RESTPostAPIChannelMessageJSONBody {
* See https://discord.com/developers/docs/resources/sticker#sticker-object
*/
sticker_ids?: [Snowflake] | [Snowflake, Snowflake] | [Snowflake, Snowflake, Snowflake];
/**
* Attachment objects with filename and description
*/
attachments?: Pick<APIAttachment, 'id' | 'description'> & Partial<Pick<APIAttachment, 'filename'>>[];
}

/**
* https://discord.com/developers/docs/resources/channel#create-message
*/
export type RESTPostAPIChannelMessageFormDataBody =
| {
| ({
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPostAPIChannelMessageJSONBody & {
/**
* The file contents
*/
file: unknown;
});
} & Record<`files[${bigint}]`, unknown>)
| (RESTPostAPIChannelMessageJSONBody & Record<`files[${bigint}]`, unknown>);

/**
* https://discord.com/developers/docs/resources/channel#create-message
Expand Down Expand Up @@ -332,6 +327,8 @@ export interface RESTPatchAPIChannelMessageJSONBody {
/**
* 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?: APIAttachment[] | null;
Expand All @@ -347,22 +344,13 @@ export interface RESTPatchAPIChannelMessageJSONBody {
* https://discord.com/developers/docs/resources/channel#edit-message
*/
export type RESTPatchAPIChannelMessageFormDataBody =
| {
| ({
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPatchAPIChannelMessageJSONBody & {
/**
* The file contents
*/
file: unknown;
});
} & Record<`files[${bigint}]`, unknown>)
| (RESTPatchAPIChannelMessageJSONBody & Record<`files[${bigint}]`, unknown>);
/**
* https://discord.com/developers/docs/resources/channel#edit-message
*/
Expand Down
30 changes: 6 additions & 24 deletions deno/rest/v8/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,13 @@ export type RESTPostAPIInteractionCallbackJSONBody = APIInteractionResponse;
* https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response
*/
export type RESTPostAPIInteractionCallbackFormDataBody =
| {
| ({
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPostAPIInteractionCallbackJSONBody & {
/**
* The file contents
*/
file: unknown;
});
} & Record<`files[${bigint}]`, unknown>)
| (RESTPostAPIInteractionCallbackJSONBody & Record<`files[${bigint}]`, unknown>);

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response
Expand Down Expand Up @@ -177,22 +168,13 @@ export type RESTPostAPIInteractionFollowupJSONBody = APIInteractionResponseCallb
* https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message
*/
export type RESTPostAPIInteractionFollowupFormDataBody =
| {
| ({
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPostAPIInteractionFollowupJSONBody & {
/**
* The file contents
*/
file: unknown;
});
} & Record<`files[${bigint}]`, unknown>)
| (RESTPostAPIInteractionFollowupJSONBody & Record<`files[${bigint}]`, unknown>);

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message
Expand Down
36 changes: 12 additions & 24 deletions deno/rest/v8/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,28 +135,23 @@ export interface RESTPostAPIWebhookWithTokenJSONBody {
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent[];
/**
* Attachment objects with filename and description
*/
attachments?: Pick<APIAttachment, 'id' | 'description'> & Partial<Pick<APIAttachment, 'filename'>>[];
}

/**
* https://discord.com/developers/docs/resources/webhook#execute-webhook
*/
export type RESTPostAPIWebhookWithTokenFormDataBody =
| {
| ({
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPostAPIWebhookWithTokenJSONBody & {
/**
* The file contents
*/
file: unknown;
});
} & Record<`files[${bigint}]`, unknown>)
| (RESTPostAPIWebhookWithTokenJSONBody & Record<`files[${bigint}]`, unknown>);

/**
* https://discord.com/developers/docs/resources/webhook#execute-webhook-querystring-params
Expand Down Expand Up @@ -235,6 +230,8 @@ export interface RESTPatchAPIWebhookWithTokenMessageJSONBody
/**
* 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?: APIAttachment[] | null;
Expand All @@ -244,22 +241,13 @@ export interface RESTPatchAPIWebhookWithTokenMessageJSONBody
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message
*/
export type RESTPatchAPIWebhookWithTokenMessageFormDataBody =
| {
| ({
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPatchAPIWebhookWithTokenMessageJSONBody & {
/**
* The file contents
*/
file: unknown;
});
} & Record<`files[${bigint}]`, unknown>)
| (RESTPatchAPIWebhookWithTokenMessageJSONBody & Record<`files[${bigint}]`, unknown>);

/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message
Expand Down
36 changes: 12 additions & 24 deletions deno/rest/v9/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,28 +248,23 @@ export interface RESTPostAPIChannelMessageJSONBody {
* See https://discord.com/developers/docs/resources/sticker#sticker-object
*/
sticker_ids?: [Snowflake] | [Snowflake, Snowflake] | [Snowflake, Snowflake, Snowflake];
/**
* Attachment objects with filename and description
*/
attachments?: Pick<APIAttachment, 'id' | 'description'> & Partial<Pick<APIAttachment, 'filename'>>[];
}

/**
* https://discord.com/developers/docs/resources/channel#create-message
*/
export type RESTPostAPIChannelMessageFormDataBody =
| {
| ({
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPostAPIChannelMessageJSONBody & {
/**
* The file contents
*/
file: unknown;
});
} & Record<`files[${bigint}]`, unknown>)
| (RESTPostAPIChannelMessageJSONBody & Record<`files[${bigint}]`, unknown>);

/**
* https://discord.com/developers/docs/resources/channel#create-message
Expand Down Expand Up @@ -366,6 +361,8 @@ export interface RESTPatchAPIChannelMessageJSONBody {
/**
* 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?: APIAttachment[] | null;
Expand All @@ -381,22 +378,13 @@ export interface RESTPatchAPIChannelMessageJSONBody {
* https://discord.com/developers/docs/resources/channel#edit-message
*/
export type RESTPatchAPIChannelMessageFormDataBody =
| {
| ({
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPatchAPIChannelMessageJSONBody & {
/**
* The file contents
*/
file: unknown;
});
} & Record<`files[${bigint}]`, unknown>)
| (RESTPatchAPIChannelMessageJSONBody & Record<`files[${bigint}]`, unknown>);

/**
* https://discord.com/developers/docs/resources/channel#edit-message
Expand Down
30 changes: 6 additions & 24 deletions deno/rest/v9/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,13 @@ export type RESTPostAPIInteractionCallbackJSONBody = APIInteractionResponse;
* https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response
*/
export type RESTPostAPIInteractionCallbackFormDataBody =
| {
| ({
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPostAPIInteractionCallbackJSONBody & {
/**
* The file contents
*/
file: unknown;
});
} & Record<`files[${bigint}]`, unknown>)
| (RESTPostAPIInteractionCallbackJSONBody & Record<`files[${bigint}]`, unknown>);

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response
Expand Down Expand Up @@ -177,22 +168,13 @@ export type RESTPostAPIInteractionFollowupJSONBody = APIInteractionResponseCallb
* https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message
*/
export type RESTPostAPIInteractionFollowupFormDataBody =
| {
| ({
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPostAPIInteractionFollowupJSONBody & {
/**
* The file contents
*/
file: unknown;
});
} & Record<`files[${bigint}]`, unknown>)
| (RESTPostAPIInteractionFollowupJSONBody & Record<`files[${bigint}]`, unknown>);

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message
Expand Down
Loading

0 comments on commit fdf133e

Please sign in to comment.