diff --git a/deno/payloads/v9/auditLog.ts b/deno/payloads/v9/auditLog.ts index 2c721145..783c4aa8 100644 --- a/deno/payloads/v9/auditLog.ts +++ b/deno/payloads/v9/auditLog.ts @@ -3,7 +3,7 @@ */ import type { Snowflake } from '../../globals.ts'; -import type { APIOverwrite } from './channel.ts'; +import type { APIChannel, APIOverwrite } from './channel.ts'; import type { APIGuildIntegration, GuildDefaultMessageNotifications, @@ -46,6 +46,14 @@ export interface APIAuditLog { * See https://discord.com/developers/docs/resources/guild#integration-object */ integrations: APIGuildIntegration[]; + /** + * Threads found in the audit log + * + * Threads referenced in THREAD_CREATE and THREAD_UPDATE events are included in the threads map, since archived threads might not be kept in memory by clients. + * + * See https://discord.com/developers/docs/resources/channel#channel-object + */ + threads: APIChannel[]; } /** @@ -144,6 +152,10 @@ export enum AuditLogEvent { StickerCreate = 90, StickerUpdate, StickerDelete, + + ThreadCreate = 110, + ThreadUpdate, + ThreadDelete, } /** @@ -302,7 +314,11 @@ export type APIAuditLogChange = | APIAuditLogChangeKeyFormatType | APIAuditLogChangeKeyAsset | APIAuditLogChangeKeyAvailable - | APIAuditLogChangeKeyGuildId; + | APIAuditLogChangeKeyGuildId + | APIAuditLogChangeKeyArchived + | APIAuditLogChangeKeyLocked + | APIAuditLogChangeKeyAutoArchiveDuration + | APIAuditLogChangeKeyDefaultAutoArchiveDuration; /** * Returned when an entity's name is changed @@ -611,6 +627,29 @@ export type APIAuditLogChangeKeyAvailable = AuditLogChangeData<'available', bool */ export type APIAuditLogChangeKeyGuildId = AuditLogChangeData<'guild_id', Snowflake>; +/* + * Returned when a thread's archive status is changed + */ +export type APIAuditLogChangeKeyArchived = AuditLogChangeData<'archived', boolean>; + +/* + * Returned when a thread's lock status is changed + */ +export type APIAuditLogChangeKeyLocked = AuditLogChangeData<'locked', boolean>; + +/* + * Returned when a thread's auto archive duration is changed + */ +export type APIAuditLogChangeKeyAutoArchiveDuration = AuditLogChangeData<'auto_archive_duration', number>; + +/* + * Returned when a channel's default auto archive duration for newly created threads is changed + */ +export type APIAuditLogChangeKeyDefaultAutoArchiveDuration = AuditLogChangeData< + 'default_auto_archive_duration', + number +>; + interface AuditLogChangeData { key: K; /** diff --git a/deno/payloads/v9/channel.ts b/deno/payloads/v9/channel.ts index 8fb4f451..9d4d39af 100644 --- a/deno/payloads/v9/channel.ts +++ b/deno/payloads/v9/channel.ts @@ -72,6 +72,11 @@ export interface APIChannel extends APIPartialChannel { /** * Amount of seconds a user has to wait before sending another message (0-21600); * bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected + * + * `rate_limit_per_user` also applies to thread creation. Users can send one message and create one thread during each `rate_limit_per_user` interval. + * + * For thread channels, `rate_limit_per_user` is only returned if the field is set to a non-zero and non-null value. + * The absence of this field in API calls and Gateway events should indicate that slowmode has been reset to the default value. */ rate_limit_per_user?: number; /** diff --git a/deno/rest/v9/channel.ts b/deno/rest/v9/channel.ts index 210a1698..92653d14 100644 --- a/deno/rest/v9/channel.ts +++ b/deno/rest/v9/channel.ts @@ -577,6 +577,8 @@ export interface RESTPostAPIChannelMessagesThreadsJSONBody { name: string; /** * The amount of time in minutes to wait before automatically archiving the thread + * + * The 3 day and 7 day archive durations require the server to be boosted. The [guild features](https://discord.com/developers/docs/resources/guild#guild-object-guild-features) will indicate if a server is able to use those settings. */ auto_archive_duration: ThreadAutoArchiveDuration; } @@ -592,8 +594,15 @@ export type RESTPostAPIChannelMessagesThreadsResult = APIChannel; 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; + type?: ChannelType.GuildNewsThread | ChannelType.GuildPublicThread | ChannelType.GuildPrivateThread; } /** @@ -632,6 +641,8 @@ export interface RESTGetAPIChannelThreadsArchivedQuery { /** * https://discord.com/developers/docs/resources/channel#list-active-threads + * + * @deprecated Use [List Active Guild Threads](https://discord.com/developers/docs/resources/guild#list-active-threads) instead. Will be removed in v10. */ export type RESTGetAPIChannelThreadsResult = APIThreadList; diff --git a/deno/rest/v9/guild.ts b/deno/rest/v9/guild.ts index c8496b30..1230b11d 100644 --- a/deno/rest/v9/guild.ts +++ b/deno/rest/v9/guild.ts @@ -12,6 +12,7 @@ import type { APIGuildWidget, APIGuildWidgetSettings, APIRole, + APIThreadList, APIVoiceRegion, GuildDefaultMessageNotifications, GuildExplicitContentFilter, @@ -303,6 +304,11 @@ export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{ */ export type RESTPatchAPIGuildChannelPositionsResult = never; +/** + * https://discord.com/developers/docs/resources/guild#list-active-threads + */ +export type RESTGetAPIGuildThreadsResult = Omit; + /** * https://discord.com/developers/docs/resources/guild#get-guild-member */ diff --git a/deno/rest/v9/mod.ts b/deno/rest/v9/mod.ts index 32d294c9..b7a503d2 100644 --- a/deno/rest/v9/mod.ts +++ b/deno/rest/v9/mod.ts @@ -435,9 +435,19 @@ export const Routes = { return parts.join('/') as `/channels/${Snowflake}/threads` | `/channels/${Snowflake}/messages/${Snowflake}/threads`; }, + /** + * Route for: + * - GET `/guilds/{guild.id}/threads/active` + */ + guildActiveThreads(guildId: Snowflake) { + return `/guilds/${guildId}/threads/active` as const; + }, + /** * Route for: * - GET `/channels/{channel.id}/threads/active` + * (deprecated, use [List Active Guild Threads](https://discord.com/developers/docs/resources/guild#list-active-threads) instead. + * Will be removed in v10.) * - GET `/channels/{channel.id}/threads/archived/public` * - GET `/channels/{channel.id}/threads/archived/private` */ @@ -456,7 +466,7 @@ export const Routes = { * Route for: * - GET `/channels/{channel.id}/users/@me/threads/archived/prviate` */ - channelJoinedArhivedThreads(channelId: Snowflake) { + channelJoinedArchivedThreads(channelId: Snowflake) { return `/channels/${channelId}/users/@me/threads/archived/private` as const; }, diff --git a/payloads/v9/auditLog.ts b/payloads/v9/auditLog.ts index 02a96c3a..4ae9f274 100644 --- a/payloads/v9/auditLog.ts +++ b/payloads/v9/auditLog.ts @@ -3,7 +3,7 @@ */ import type { Snowflake } from '../../globals'; -import type { APIOverwrite } from './channel'; +import type { APIChannel, APIOverwrite } from './channel'; import type { APIGuildIntegration, GuildDefaultMessageNotifications, @@ -46,6 +46,14 @@ export interface APIAuditLog { * See https://discord.com/developers/docs/resources/guild#integration-object */ integrations: APIGuildIntegration[]; + /** + * Threads found in the audit log + * + * Threads referenced in THREAD_CREATE and THREAD_UPDATE events are included in the threads map, since archived threads might not be kept in memory by clients. + * + * See https://discord.com/developers/docs/resources/channel#channel-object + */ + threads: APIChannel[]; } /** @@ -144,6 +152,10 @@ export const enum AuditLogEvent { StickerCreate = 90, StickerUpdate, StickerDelete, + + ThreadCreate = 110, + ThreadUpdate, + ThreadDelete, } /** @@ -302,7 +314,11 @@ export type APIAuditLogChange = | APIAuditLogChangeKeyFormatType | APIAuditLogChangeKeyAsset | APIAuditLogChangeKeyAvailable - | APIAuditLogChangeKeyGuildId; + | APIAuditLogChangeKeyGuildId + | APIAuditLogChangeKeyArchived + | APIAuditLogChangeKeyLocked + | APIAuditLogChangeKeyAutoArchiveDuration + | APIAuditLogChangeKeyDefaultAutoArchiveDuration; /** * Returned when an entity's name is changed @@ -611,6 +627,29 @@ export type APIAuditLogChangeKeyAvailable = AuditLogChangeData<'available', bool */ export type APIAuditLogChangeKeyGuildId = AuditLogChangeData<'guild_id', Snowflake>; +/* + * Returned when a thread's archive status is changed + */ +export type APIAuditLogChangeKeyArchived = AuditLogChangeData<'archived', boolean>; + +/* + * Returned when a thread's lock status is changed + */ +export type APIAuditLogChangeKeyLocked = AuditLogChangeData<'locked', boolean>; + +/* + * Returned when a thread's auto archive duration is changed + */ +export type APIAuditLogChangeKeyAutoArchiveDuration = AuditLogChangeData<'auto_archive_duration', number>; + +/* + * Returned when a channel's default auto archive duration for newly created threads is changed + */ +export type APIAuditLogChangeKeyDefaultAutoArchiveDuration = AuditLogChangeData< + 'default_auto_archive_duration', + number +>; + interface AuditLogChangeData { key: K; /** diff --git a/payloads/v9/channel.ts b/payloads/v9/channel.ts index 5e55d725..d7db2d5a 100644 --- a/payloads/v9/channel.ts +++ b/payloads/v9/channel.ts @@ -72,6 +72,11 @@ export interface APIChannel extends APIPartialChannel { /** * Amount of seconds a user has to wait before sending another message (0-21600); * bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected + * + * `rate_limit_per_user` also applies to thread creation. Users can send one message and create one thread during each `rate_limit_per_user` interval. + * + * For thread channels, `rate_limit_per_user` is only returned if the field is set to a non-zero and non-null value. + * The absence of this field in API calls and Gateway events should indicate that slowmode has been reset to the default value. */ rate_limit_per_user?: number; /** diff --git a/rest/v9/channel.ts b/rest/v9/channel.ts index b93b160d..74462592 100644 --- a/rest/v9/channel.ts +++ b/rest/v9/channel.ts @@ -577,6 +577,8 @@ export interface RESTPostAPIChannelMessagesThreadsJSONBody { name: string; /** * The amount of time in minutes to wait before automatically archiving the thread + * + * The 3 day and 7 day archive durations require the server to be boosted. The [guild features](https://discord.com/developers/docs/resources/guild#guild-object-guild-features) will indicate if a server is able to use those settings. */ auto_archive_duration: ThreadAutoArchiveDuration; } @@ -592,8 +594,15 @@ export type RESTPostAPIChannelMessagesThreadsResult = APIChannel; 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; + type?: ChannelType.GuildNewsThread | ChannelType.GuildPublicThread | ChannelType.GuildPrivateThread; } /** @@ -632,6 +641,8 @@ export interface RESTGetAPIChannelThreadsArchivedQuery { /** * https://discord.com/developers/docs/resources/channel#list-active-threads + * + * @deprecated Use [List Active Guild Threads](https://discord.com/developers/docs/resources/guild#list-active-threads) instead. Will be removed in v10. */ export type RESTGetAPIChannelThreadsResult = APIThreadList; diff --git a/rest/v9/guild.ts b/rest/v9/guild.ts index f566fccd..e8897429 100644 --- a/rest/v9/guild.ts +++ b/rest/v9/guild.ts @@ -12,6 +12,7 @@ import type { APIGuildWidget, APIGuildWidgetSettings, APIRole, + APIThreadList, APIVoiceRegion, GuildDefaultMessageNotifications, GuildExplicitContentFilter, @@ -303,6 +304,11 @@ export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{ */ export type RESTPatchAPIGuildChannelPositionsResult = never; +/** + * https://discord.com/developers/docs/resources/guild#list-active-threads + */ +export type RESTGetAPIGuildThreadsResult = Omit; + /** * https://discord.com/developers/docs/resources/guild#get-guild-member */ diff --git a/rest/v9/index.ts b/rest/v9/index.ts index d7067c56..644fd896 100644 --- a/rest/v9/index.ts +++ b/rest/v9/index.ts @@ -435,9 +435,19 @@ export const Routes = { return parts.join('/') as `/channels/${Snowflake}/threads` | `/channels/${Snowflake}/messages/${Snowflake}/threads`; }, + /** + * Route for: + * - GET `/guilds/{guild.id}/threads/active` + */ + guildActiveThreads(guildId: Snowflake) { + return `/guilds/${guildId}/threads/active` as const; + }, + /** * Route for: * - GET `/channels/{channel.id}/threads/active` + * (deprecated, use [List Active Guild Threads](https://discord.com/developers/docs/resources/guild#list-active-threads) instead. + * Will be removed in v10.) * - GET `/channels/{channel.id}/threads/archived/public` * - GET `/channels/{channel.id}/threads/archived/private` */ @@ -456,7 +466,7 @@ export const Routes = { * Route for: * - GET `/channels/{channel.id}/users/@me/threads/archived/prviate` */ - channelJoinedArhivedThreads(channelId: Snowflake) { + channelJoinedArchivedThreads(channelId: Snowflake) { return `/channels/${channelId}/users/@me/threads/archived/private` as const; },