Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: invert deletable message types list #10093

Merged
merged 3 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -3666,6 +3666,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 @@ -3698,6 +3707,8 @@ export const Constants: {
ThreadChannelTypes: ThreadChannelType[];
VoiceBasedChannelTypes: VoiceBasedChannelTypes[];
SelectMenuTypes: SelectMenuType[];
UndeletableMessageTypes: UndeletableMessageType[];
/** @deprecated This list will no longer be updated. Use {@link Constants.UndeletableMessageTypes} */
almeidx marked this conversation as resolved.
Show resolved Hide resolved
DeletableMessageTypes: DeletableMessageType[];
StickerFormatExtensionMap: Record<StickerFormatType, ImageFormat>;
};
Expand Down