Fix: fix detection for attachments again

This commit is contained in:
fumiichan 2025-01-31 23:18:41 +09:00
parent d001022ec7
commit 6bf49e25aa
No known key found for this signature in database
GPG key ID: 75B15A4C2C5A48A6

View file

@ -22,6 +22,7 @@ import { ImageInvisible, ImageVisible } from "@components/Icons";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { ChannelStore } from "@webpack/common"; import { ChannelStore } from "@webpack/common";
import { MessageSnapshot } from "@webpack/types";
import { ILoadMessagesSuccessPayload, IMessage, IMessageCreatePayload, IMessageUpdatePayload } from "./types"; import { ILoadMessagesSuccessPayload, IMessage, IMessageCreatePayload, IMessageUpdatePayload } from "./types";
import { isStringEmpty } from "./utils"; import { isStringEmpty } from "./utils";
@ -182,8 +183,11 @@ export default definePlugin({
settings, settings,
renderMessagePopoverButton(msg: IMessage) { renderMessagePopoverButton(msg) {
const hasAttachmentsInSnapshots = !Array.isArray(msg.message_snapshots); // @ts-ignore - discord-types lags behind discord.
const hasAttachmentsInSnapshots = msg.messageSnapshots.some(
(snapshot: MessageSnapshot) => snapshot?.message.attachments.length || snapshot?.message.embeds.length > 0
);
if (!msg.attachments.length && !msg.embeds.length && !msg.stickerItems.length && !hasAttachmentsInSnapshots) { if (!msg.attachments.length && !msg.embeds.length && !msg.stickerItems.length && !hasAttachmentsInSnapshots) {
return null; return null;
} }