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