mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
feat(GuildAuditLogs): add threads (#6195)
This commit is contained in:
@@ -23,6 +23,7 @@ const Util = require('../util/Util');
|
|||||||
* * INTEGRATION
|
* * INTEGRATION
|
||||||
* * STAGE_INSTANCE
|
* * STAGE_INSTANCE
|
||||||
* * STICKER
|
* * STICKER
|
||||||
|
* * THREAD
|
||||||
* @typedef {string} AuditLogTargetType
|
* @typedef {string} AuditLogTargetType
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -44,6 +45,7 @@ const Targets = {
|
|||||||
INTEGRATION: 'INTEGRATION',
|
INTEGRATION: 'INTEGRATION',
|
||||||
STAGE_INSTANCE: 'STAGE_INSTANCE',
|
STAGE_INSTANCE: 'STAGE_INSTANCE',
|
||||||
STICKER: 'STICKER',
|
STICKER: 'STICKER',
|
||||||
|
THREAD: 'THREAD',
|
||||||
UNKNOWN: 'UNKNOWN',
|
UNKNOWN: 'UNKNOWN',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -91,6 +93,9 @@ const Targets = {
|
|||||||
* * STICKER_CREATE: 90
|
* * STICKER_CREATE: 90
|
||||||
* * STICKER_UPDATE: 91
|
* * STICKER_UPDATE: 91
|
||||||
* * STICKER_DELETE: 92
|
* * STICKER_DELETE: 92
|
||||||
|
* * THREAD_CREATE: 110
|
||||||
|
* * THREAD_UPDATE: 111
|
||||||
|
* * THREAD_DELETE: 112
|
||||||
* @typedef {?(number|string)} AuditLogAction
|
* @typedef {?(number|string)} AuditLogAction
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -142,6 +147,9 @@ const Actions = {
|
|||||||
STICKER_CREATE: 90,
|
STICKER_CREATE: 90,
|
||||||
STICKER_UPDATE: 91,
|
STICKER_UPDATE: 91,
|
||||||
STICKER_DELETE: 92,
|
STICKER_DELETE: 92,
|
||||||
|
THREAD_CREATE: 110,
|
||||||
|
THREAD_UPDATE: 111,
|
||||||
|
THREAD_DELETE: 112,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,6 +158,7 @@ const Actions = {
|
|||||||
class GuildAuditLogs {
|
class GuildAuditLogs {
|
||||||
constructor(guild, data) {
|
constructor(guild, data) {
|
||||||
if (data.users) for (const user of data.users) guild.client.users._add(user);
|
if (data.users) for (const user of data.users) guild.client.users._add(user);
|
||||||
|
if (data.threads) for (const thread of data.threads) guild.client.channels._add(thread, guild);
|
||||||
/**
|
/**
|
||||||
* Cached webhooks
|
* Cached webhooks
|
||||||
* @type {Collection<Snowflake, Webhook>}
|
* @type {Collection<Snowflake, Webhook>}
|
||||||
@@ -207,6 +216,7 @@ class GuildAuditLogs {
|
|||||||
* * An integration
|
* * An integration
|
||||||
* * A stage instance
|
* * A stage instance
|
||||||
* * A sticker
|
* * A sticker
|
||||||
|
* * A thread
|
||||||
* * An object with an id key if target was deleted
|
* * An object with an id key if target was deleted
|
||||||
* * An object where the keys represent either the new value or the old value
|
* * An object where the keys represent either the new value or the old value
|
||||||
* @typedef {?(Object|Guild|Channel|User|Role|Invite|Webhook|GuildEmoji|Message|Integration|StageInstance|Sticker)}
|
* @typedef {?(Object|Guild|Channel|User|Role|Invite|Webhook|GuildEmoji|Message|Integration|StageInstance|Sticker)}
|
||||||
@@ -230,6 +240,8 @@ class GuildAuditLogs {
|
|||||||
if (target < 83) return Targets.INTEGRATION;
|
if (target < 83) return Targets.INTEGRATION;
|
||||||
if (target < 86) return Targets.STAGE_INSTANCE;
|
if (target < 86) return Targets.STAGE_INSTANCE;
|
||||||
if (target < 100) return Targets.STICKER;
|
if (target < 100) return Targets.STICKER;
|
||||||
|
if (target < 110) return Targets.UNKNOWN;
|
||||||
|
if (target < 120) return Targets.THREAD;
|
||||||
return Targets.UNKNOWN;
|
return Targets.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,6 +274,7 @@ class GuildAuditLogs {
|
|||||||
Actions.INTEGRATION_CREATE,
|
Actions.INTEGRATION_CREATE,
|
||||||
Actions.STAGE_INSTANCE_CREATE,
|
Actions.STAGE_INSTANCE_CREATE,
|
||||||
Actions.STICKER_CREATE,
|
Actions.STICKER_CREATE,
|
||||||
|
Actions.THREAD_CREATE,
|
||||||
].includes(action)
|
].includes(action)
|
||||||
) {
|
) {
|
||||||
return 'CREATE';
|
return 'CREATE';
|
||||||
@@ -285,6 +298,7 @@ class GuildAuditLogs {
|
|||||||
Actions.INTEGRATION_DELETE,
|
Actions.INTEGRATION_DELETE,
|
||||||
Actions.STAGE_INSTANCE_DELETE,
|
Actions.STAGE_INSTANCE_DELETE,
|
||||||
Actions.STICKER_DELETE,
|
Actions.STICKER_DELETE,
|
||||||
|
Actions.THREAD_DELETE,
|
||||||
].includes(action)
|
].includes(action)
|
||||||
) {
|
) {
|
||||||
return 'DELETE';
|
return 'DELETE';
|
||||||
@@ -305,6 +319,7 @@ class GuildAuditLogs {
|
|||||||
Actions.INTEGRATION_UPDATE,
|
Actions.INTEGRATION_UPDATE,
|
||||||
Actions.STAGE_INSTANCE_UPDATE,
|
Actions.STAGE_INSTANCE_UPDATE,
|
||||||
Actions.STICKER_UPDATE,
|
Actions.STICKER_UPDATE,
|
||||||
|
Actions.THREAD_UPDATE,
|
||||||
].includes(action)
|
].includes(action)
|
||||||
) {
|
) {
|
||||||
return 'UPDATE';
|
return 'UPDATE';
|
||||||
@@ -520,7 +535,7 @@ class GuildAuditLogsEntry {
|
|||||||
),
|
),
|
||||||
guild,
|
guild,
|
||||||
);
|
);
|
||||||
} else if (targetType === Targets.CHANNEL) {
|
} else if (targetType === Targets.CHANNEL || targetType === Targets.THREAD) {
|
||||||
this.target =
|
this.target =
|
||||||
guild.channels.cache.get(data.target_id) ??
|
guild.channels.cache.get(data.target_id) ??
|
||||||
this.changes.reduce(
|
this.changes.reduce(
|
||||||
|
|||||||
5
typings/index.d.ts
vendored
5
typings/index.d.ts
vendored
@@ -661,6 +661,7 @@ export class GuildAuditLogsEntry {
|
|||||||
| Integration
|
| Integration
|
||||||
| StageInstance
|
| StageInstance
|
||||||
| Sticker
|
| Sticker
|
||||||
|
| ThreadChannel
|
||||||
| { id: Snowflake }
|
| { id: Snowflake }
|
||||||
| null;
|
| null;
|
||||||
public targetType: GuildAuditLogsTarget;
|
public targetType: GuildAuditLogsTarget;
|
||||||
@@ -3443,6 +3444,9 @@ export interface GuildAuditLogsActions {
|
|||||||
STICKER_CREATE?: number;
|
STICKER_CREATE?: number;
|
||||||
STICKER_UPDATE?: number;
|
STICKER_UPDATE?: number;
|
||||||
STICKER_DELETE?: number;
|
STICKER_DELETE?: number;
|
||||||
|
THREAD_CREATE?: number;
|
||||||
|
THREAD_UPDATE?: number;
|
||||||
|
THREAD_DELETE?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GuildAuditLogsActionType = 'CREATE' | 'DELETE' | 'UPDATE' | 'ALL';
|
export type GuildAuditLogsActionType = 'CREATE' | 'DELETE' | 'UPDATE' | 'ALL';
|
||||||
@@ -3469,6 +3473,7 @@ export interface GuildAuditLogsTargets {
|
|||||||
INTEGRATION?: string;
|
INTEGRATION?: string;
|
||||||
STAGE_INSTANCE?: string;
|
STAGE_INSTANCE?: string;
|
||||||
STICKER?: string;
|
STICKER?: string;
|
||||||
|
THREAD?: string;
|
||||||
UNKNOWN?: string;
|
UNKNOWN?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user