Repository: discordjs/discord.js
File: packages/discord.js/typings/index.d.ts (TypeScript)

Code before:
      | 'attachments'
      | 'client'
      | 'components'
      | 'content'
      | 'createdTimestamp'
      | 'editedTimestamp'
      | 'embeds'
      | 'flags'
      | 'mentions'
      | 'stickers'
      | 'type'
    >
  > {}

export interface BaseMessageOptions {
  allowedMentions?: MessageMentionOptions;
  components?: readonly (
    | ActionRowData<MessageActionRowComponentBuilder | MessageActionRowComponentData>
    | APIMessageTopLevelComponent
    | JSONEncodable<APIActionRowComponent<APIComponentInActionRow>>
    | JSONEncodable<APIMessageTopLevelComponent>
    | TopLevelComponentData
  )[];
  content?: string;
  embeds?: readonly (APIEmbed | JSONEncodable<APIEmbed>)[];
  files?: readonly (Attachment | AttachmentPayload | BufferResolvable | JSONEncodable<APIAttachment> | Stream)[];
}

export interface MessageOptionsPoll {
  poll?: JSONEncodable<RESTAPIPoll> | PollData;
}

export interface MessageOptionsFlags {
  flags?:
    | BitFieldResolvable<
        Extract<MessageFlagsString, 'IsComponentsV2' | 'IsVoiceMessage' | 'SuppressEmbeds' | 'SuppressNotifications'>,
        | MessageFlags.IsComponentsV2
        | MessageFlags.IsVoiceMessage
        | MessageFlags.SuppressEmbeds
        | MessageFlags.SuppressNotifications
      >
    | undefined;
}

export interface MessageOptionsTTS {
  tts?: boolean;
}

export interface MessageOptionsStickers {
  stickers?: readonly StickerResolvable[];
}

Review comment (bug):
`JSONEncodable<APIAttachment>` doesn't work:

https://github.com/discordjs/discord.js/blob/77241ad7c59d622428f825ba6e4d862f46d2adbb/packages/discord.js/src/structures/MessagePayload.js#L271-L279

`attachment = fileLike.attachment` resolves to `undefined` since there's no `attachment` property. This then follows:

https://github.com/discordjs/discord.js/blob/77241ad7c59d622428f825ba6e4d862f46d2adbb/packages/discord.js/src/util/Util.js#L413-L415

Which crashes:

```
TypeError: Cannot read properties of undefined (reading 'path')
    at findName (/Users/jiralite/Documents/GitHub/discord.js/discord.js/packages/discord.js/src/util/Util.js:413:13)
    at MessagePayload.resolveFile (/Users/jiralite/Documents/GitHub/discord.js/discord.js/packages/discord.js/src/structures/MessagePayload.js:278:31)
    at /Users/jiralite/Documents/GitHub/discord.js/discord.js/packages/discord.js/src/structures/MessagePayload.js:257:85
    at Array.map (<anonymous>)
    at MessagePayload.resolveFiles (/Users/jiralite/Documents/GitHub/discord.js/discord.js/packages/discord.js/src/structures/MessagePayload.js:257:56)
    at ChannelManager.createMessage (/Users/jiralite/Documents/GitHub/discord.js/discord.js/packages/discord.js/src/managers/ChannelManager.js:186:74)
    at TextChannel.send (/Users/jiralite/Documents/GitHub/discord.js/discord.js/packages/discord.js/src/structures/interfaces/TextBasedChannel.js:186:33)
    at Client.<anonymous> (/Users/jiralite/Documents/GitHub/Soulobby/Soulobby/source/test.ts:34:83)
    at Client.emit (/Users/jiralite/Documents/GitHub/discord.js/discord.js/node_modules/.pnpm/@vladfrangu+async_event_emitter@2.4.7/node_modules/@vladfrangu/async_event_emitter/src/index.ts:524:28)
    at Client._triggerClientReady (/Users/jiralite/Documents/GitHub/discord.js/discord.js/packages/discord.js/src/client/Client.js:464:10)
```

Code after:
export type MessageMentionTypes = 'everyone' | 'roles' | 'users';

export interface MessageSnapshot extends Partialize<
  Message,
  null,
  Exclude<
    keyof Message,
    | 'attachments'
    | 'client'
    | 'components'
    | 'content'
    | 'createdTimestamp'
    | 'editedTimestamp'
    | 'embeds'
    | 'flags'
    | 'mentions'
    | 'stickers'
    | 'type'
  >
> {}

export interface BaseMessageOptions {
  allowedMentions?: MessageMentionOptions;
  components?: readonly (
    | ActionRowData<MessageActionRowComponentBuilder | MessageActionRowComponentData>
    | APIMessageTopLevelComponent
    | JSONEncodable<APIActionRowComponent<APIComponentInActionRow>>
    | JSONEncodable<APIMessageTopLevelComponent>
    | TopLevelComponentData
  )[];
  content?: string;
  embeds?: readonly (APIEmbed | JSONEncodable<APIEmbed>)[];
  files?: readonly (Attachment | AttachmentPayload | BufferResolvable | FileBodyEncodable<APIAttachment> | Stream)[];
}

export interface MessageOptionsPoll {
  poll?: JSONEncodable<RESTAPIPoll> | PollData;
}

export interface MessageOptionsFlags {
  flags?:
    | BitFieldResolvable<
        Extract<MessageFlagsString, 'IsComponentsV2' | 'IsVoiceMessage' | 'SuppressEmbeds' | 'SuppressNotifications'>,
        | MessageFlags.IsComponentsV2
        | MessageFlags.IsVoiceMessage
        | MessageFlags.SuppressEmbeds
        | MessageFlags.SuppressNotifications
      >
    | undefined;
}