Skip to content

Commit

Permalink
fix: invert deletable message types list (#10093)
Browse files Browse the repository at this point in the history
* fix: invert deletable message types list

* docs: consistency

Co-authored-by: Jiralite <[email protected]>

---------

Co-authored-by: Jiralite <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 3, 2024
1 parent f691658 commit 42bc5d2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/discord.js/src/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const { Sticker } = require('./Sticker');
const { DiscordjsError, ErrorCodes } = require('../errors');
const ReactionManager = require('../managers/ReactionManager');
const { createComponent } = require('../util/Components');
const { NonSystemMessageTypes, MaxBulkDeletableMessageAge, DeletableMessageTypes } = require('../util/Constants');
const { NonSystemMessageTypes, MaxBulkDeletableMessageAge, UndeletableMessageTypes } = require('../util/Constants');
const MessageFlagsBitField = require('../util/MessageFlagsBitField');
const PermissionsBitField = require('../util/PermissionsBitField');
const { cleanContent, resolvePartialEmoji, transformResolved } = require('../util/Util');
Expand Down Expand Up @@ -635,7 +635,7 @@ class Message extends Base {
* @readonly
*/
get deletable() {
if (!DeletableMessageTypes.includes(this.type)) return false;
if (UndeletableMessageTypes.includes(this.type)) return false;

if (!this.guild) {
return this.author.id === this.client.user.id;
Expand Down
20 changes: 20 additions & 0 deletions packages/discord.js/src/util/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,25 @@ exports.SelectMenuTypes = [
ComponentType.ChannelSelect,
];

/**
* The types of messages that cannot be deleted. The available types are:
* * {@link MessageType.RecipientAdd}
* * {@link MessageType.RecipientRemove}
* * {@link MessageType.Call}
* * {@link MessageType.ChannelNameChange}
* * {@link MessageType.ChannelIconChange}
* * {@link MessageType.ThreadStarterMessage}
* @typedef {MessageType[]} UndeletableMessageTypes
*/
exports.UndeletableMessageTypes = [
MessageType.RecipientAdd,
MessageType.RecipientRemove,
MessageType.Call,
MessageType.ChannelNameChange,
MessageType.ChannelIconChange,
MessageType.ThreadStarterMessage,
];

/**
* The types of messages that can be deleted. The available types are:
* * {@link MessageType.AutoModerationAction}
Expand All @@ -179,6 +198,7 @@ exports.SelectMenuTypes = [
* * {@link MessageType.ThreadCreated}
* * {@link MessageType.UserJoin}
* @typedef {MessageType[]} DeletableMessageTypes
* @deprecated This list will no longer be updated. Use {@link UndeletableMessageTypes} instead.
*/
exports.DeletableMessageTypes = [
MessageType.AutoModerationAction,
Expand Down
11 changes: 11 additions & 0 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3672,6 +3672,15 @@ export type NonSystemMessageType =
| MessageType.ChatInputCommand
| MessageType.ContextMenuCommand;

export type UndeletableMessageType =
| MessageType.RecipientAdd
| MessageType.RecipientRemove
| MessageType.Call
| MessageType.ChannelNameChange
| MessageType.ChannelIconChange
| MessageType.ThreadStarterMessage;

/** @deprecated This type will no longer be updated. Use {@link UndeletableMessageType} instead. */
export type DeletableMessageType =
| MessageType.AutoModerationAction
| MessageType.ChannelFollowAdd
Expand Down Expand Up @@ -3704,6 +3713,8 @@ export const Constants: {
ThreadChannelTypes: ThreadChannelType[];
VoiceBasedChannelTypes: VoiceBasedChannelTypes[];
SelectMenuTypes: SelectMenuType[];
UndeletableMessageTypes: UndeletableMessageType[];
/** @deprecated This list will no longer be updated. Use {@link Constants.UndeletableMessageTypes} instead. */
DeletableMessageTypes: DeletableMessageType[];
StickerFormatExtensionMap: Record<StickerFormatType, ImageFormat>;
};
Expand Down

0 comments on commit 42bc5d2

Please sign in to comment.