Skip to content

Commit dc8defc

Browse files
committed
1 parent 8a87287 commit dc8defc

File tree

6 files changed

+80
-3
lines changed

6 files changed

+80
-3
lines changed

lib/Constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,12 @@ export enum MessageTypes {
759759
PRIVATE_CHANNEL_INTEGRATION_ADDED = 33,
760760
PRIVATE_CHANNEL_INTEGRATION_REMOVED = 34,
761761
PREMIUM_REFERRAL = 35,
762+
GUILD_INCIDENT_ALERT_MODE_ENABLED = 36,
763+
GUILD_INCIDENT_ALERT_MODE_DISABLED = 37,
764+
GUILD_INCIDENT_REPORT_RAID = 38,
765+
GUILD_INCIDENT_REPORT_FALSE_ALARM = 39,
766+
GUILD_DEADCHAT_REVIVE_PROMPT = 40,
767+
CUSTOM_GIFT = 41,
762768
}
763769

764770
export enum MessageActivityTypes {

lib/routes/Guilds.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ import type {
4646
EditStickerOptions,
4747
RawOnboarding,
4848
Onboarding,
49-
EditOnboardingOptions
49+
EditOnboardingOptions,
50+
EditIncidentActionsOptions,
51+
IncidentActions,
52+
RawIncidentActions
5053
} from "../types/guilds";
5154
import * as Routes from "../util/Routes";
5255
import type { CreateAutoModerationRuleOptions, EditAutoModerationRuleOptions, RawAutoModerationRule } from "../types/auto-moderation";
@@ -751,6 +754,30 @@ export default class Guilds {
751754
}).then(data => this.#manager.client.guilds.get(guildID)?.emojis.update(data) ?? this.#manager.client.util.convertEmoji(data));
752755
}
753756

757+
/**
758+
* Edit the incident actions for a guild.
759+
* @param guildID The ID of the guild.
760+
* @param options The options for editing the incident actions.
761+
*/
762+
async editIncidentActions(guildID: string, options: EditIncidentActionsOptions): Promise<IncidentActions> {
763+
const reason = options.reason;
764+
if (options.reason) {
765+
delete options.reason;
766+
}
767+
return this.#manager.authRequest<RawIncidentActions>({
768+
method: "PUT",
769+
path: Routes.GUILD_INCIDENT_ACTIONS(guildID),
770+
json: {
771+
dmsDisabledUntil: options.dmsDisabledUntil,
772+
invitesDisabledUntil: options.invitesDisabledUntil
773+
},
774+
reason
775+
}).then(data => ({
776+
dmsDisabledUntil: data.dms_disabled_until,
777+
invitesDisabledUntil: data.invites_disabled_until
778+
}));
779+
}
780+
754781
/**
755782
* Edit the [mfa level](https://discord.com/developers/docs/resources/guild#guild-object-mfa-level) of a guild. This can only be used by the guild owner.
756783
* @param guildID The ID of the guild.

lib/structures/Guild.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ import type {
9595
EditOnboardingOptions,
9696
RawGuildEmoji,
9797
RawSticker,
98-
InventorySettings
98+
InventorySettings,
99+
EditIncidentActionsOptions,
100+
IncidentActions
99101
} from "../types/guilds";
100102
import type {
101103
CreateScheduledEventOptions,
@@ -159,6 +161,7 @@ export default class Guild extends Base {
159161
features: Array<GuildFeature>;
160162
/** The icon hash of this guild. */
161163
icon: string | null;
164+
incidentActions: IncidentActions | null;
162165
/** The integrations in this guild. */
163166
integrations: TypedCollection<RawIntegration, Integration, [guildID?: string]>;
164167
/** The guild's inventory settings. */
@@ -272,6 +275,7 @@ export default class Guild extends Base {
272275
this.explicitContentFilter = data.explicit_content_filter;
273276
this.features = [];
274277
this.icon = null;
278+
this.incidentActions = null;
275279
this.integrations = new TypedCollection(Integration, client, client.util._getLimit("integrations", this.id));
276280
this.inventorySettings = null;
277281
this.invites = new SimpleCollection(rawInvite => new Invite(rawInvite, client), client.util._getLimit("invites", this.id), "update", "code");
@@ -497,6 +501,12 @@ export default class Guild extends Base {
497501
if (data.icon !== undefined) {
498502
this.icon = data.icon;
499503
}
504+
if (data.incident_actions !== undefined) {
505+
this.incidentActions = {
506+
dmsDisabledUntil: data.incident_actions!.dms_disabled_until,
507+
invitesDisabledUntil: data.incident_actions!.invites_disabled_until
508+
};
509+
}
500510
if (data.inventory_settings !== undefined) {
501511
this.inventorySettings = data.inventory_settings === null ? null : {
502512
isEmojiPackCollectible: data.inventory_settings.is_emoji_pack_collectible
@@ -927,6 +937,14 @@ export default class Guild extends Base {
927937
return this.client.rest.guilds.editEmoji(this.id, emojiID, options);
928938
}
929939

940+
/**
941+
* Edit the incident actions for this guild.
942+
* @param options The options for editing the incident actions.
943+
*/
944+
async editIncidentActions(options: EditIncidentActionsOptions): Promise<IncidentActions> {
945+
return this.client.rest.guilds.editIncidentActions(this.id, options);
946+
}
947+
930948
/**
931949
* Edit the [mfa level](https://discord.com/developers/docs/resources/guild#guild-object-mfa-level) of this guild. This can only be used by the guild owner.
932950
* @param options The options for editing the MFA level.
@@ -1431,6 +1449,7 @@ export default class Guild extends Base {
14311449
explicitContentFilter: this.explicitContentFilter,
14321450
features: this.features,
14331451
icon: this.icon,
1452+
incidentActions: this.incidentActions,
14341453
joinedAt: this.joinedAt?.getTime() ?? null,
14351454
large: this.large,
14361455
maxMembers: this.maxMembers,

lib/types/guilds.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export interface RawGuild {
5858
icon: string | null;
5959
icon_hash?: string | null;
6060
id: string;
61+
incident_actions: RawIncidentActions | null;
6162
inventory_settings: RawInventorySettings | null;
6263
joined_at: string | null;
6364
large: boolean;
@@ -810,3 +811,24 @@ export interface RawInventorySettings {
810811
export interface InventorySettings {
811812
isEmojiPackCollectible: boolean;
812813
}
814+
815+
export interface EditIncidentActionsOptions {
816+
/** When disabled direct messages will expire (up to 24 hours in the future) */
817+
dmsDisabledUntil?: string | null;
818+
/** When disabled invites will expire (up to 24 hours in the future). */
819+
invitesDisabledUntil?: string | null;
820+
/** The reason for editing the incident actions. */
821+
reason?: string;
822+
}
823+
824+
export interface RawIncidentActions {
825+
dms_disabled_until: string | null;
826+
invites_disabled_until: string | null;
827+
}
828+
829+
export interface IncidentActions {
830+
/** When disabled direct messages will expire (up to 24 hours in the future) */
831+
dmsDisabledUntil: string | null;
832+
/** When disabled invites will expire (up to 24 hours in the future). */
833+
invitesDisabledUntil: string | null;
834+
}

lib/types/json.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import type {
1818
RawSticker,
1919
WelcomeScreen,
2020
Sticker,
21-
Presence
21+
Presence,
22+
IncidentActions
2223
} from "./guilds";
2324
import type {
2425
ChannelMention,
@@ -242,6 +243,7 @@ export interface JSONGuild extends JSONBase {
242243
explicitContentFilter: ExplicitContentFilterLevels;
243244
features: Array<GuildFeature>;
244245
icon: string | null;
246+
incidentActions: IncidentActions | null;
245247
joinedAt: number | null;
246248
large: boolean;
247249
maxMembers?: number;

lib/util/Routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export const GUILD_VOICE_STATE = (guildID: string, userID: string) =>
4848
export const GUILD_STICKER = (guildID: string, stickerID: string) => `/guilds/${guildID}/stickers/${stickerID}` as const;
4949
export const GUILD_STICKERS = (guildID: string) => `/guilds/${guildID}/stickers` as const;
5050
export const GUILD_ONBOARDING = (guildID: string) => `/guilds/${guildID}/onboarding` as const;
51+
export const GUILD_INCIDENT_ACTIONS = (guildID: string) => `/guilds/${guildID}/incident-actions` as const;
5152

5253
// Channels
5354
export const CHANNEL = (channelID: string) => `/channels/${channelID}` as const;

0 commit comments

Comments
 (0)