refactor(MessagePayload): rename APIMessage (#5921)

This commit is contained in:
monbrey
2021-06-27 21:47:15 +10:00
committed by GitHub
parent 630432b4e2
commit b15d825bb3
10 changed files with 101 additions and 101 deletions

View File

@@ -57,7 +57,6 @@ module.exports = {
ApplicationCommand: require('./structures/ApplicationCommand'), ApplicationCommand: require('./structures/ApplicationCommand'),
Base: require('./structures/Base'), Base: require('./structures/Base'),
Activity: require('./structures/Presence').Activity, Activity: require('./structures/Presence').Activity,
APIMessage: require('./structures/APIMessage'),
BaseGuild: require('./structures/BaseGuild'), BaseGuild: require('./structures/BaseGuild'),
BaseGuildEmoji: require('./structures/BaseGuildEmoji'), BaseGuildEmoji: require('./structures/BaseGuildEmoji'),
BaseGuildVoiceChannel: require('./structures/BaseGuildVoiceChannel'), BaseGuildVoiceChannel: require('./structures/BaseGuildVoiceChannel'),
@@ -96,6 +95,7 @@ module.exports = {
MessageComponentInteractionCollector: require('./structures/MessageComponentInteractionCollector'), MessageComponentInteractionCollector: require('./structures/MessageComponentInteractionCollector'),
MessageEmbed: require('./structures/MessageEmbed'), MessageEmbed: require('./structures/MessageEmbed'),
MessageMentions: require('./structures/MessageMentions'), MessageMentions: require('./structures/MessageMentions'),
MessagePayload: require('./structures/MessagePayload'),
MessageReaction: require('./structures/MessageReaction'), MessageReaction: require('./structures/MessageReaction'),
MessageSelectMenu: require('./structures/MessageSelectMenu'), MessageSelectMenu: require('./structures/MessageSelectMenu'),
NewsChannel: require('./structures/NewsChannel'), NewsChannel: require('./structures/NewsChannel'),

View File

@@ -2,8 +2,8 @@
const BaseManager = require('./BaseManager'); const BaseManager = require('./BaseManager');
const { TypeError } = require('../errors'); const { TypeError } = require('../errors');
const APIMessage = require('../structures/APIMessage');
const Message = require('../structures/Message'); const Message = require('../structures/Message');
const MessagePayload = require('../structures/MessagePayload');
const Collection = require('../util/Collection'); const Collection = require('../util/Collection');
const LimitedCollection = require('../util/LimitedCollection'); const LimitedCollection = require('../util/LimitedCollection');
@@ -116,16 +116,16 @@ class MessageManager extends BaseManager {
/** /**
* Edits a message, even if it's not cached. * Edits a message, even if it's not cached.
* @param {MessageResolvable} message The message to edit * @param {MessageResolvable} message The message to edit
* @param {MessageEditOptions|APIMessage} [options] The options to provide * @param {MessageEditOptions|MessagePayload} [options] The options to provide
* @returns {Promise<Message>} * @returns {Promise<Message>}
*/ */
async edit(message, options) { async edit(message, options) {
const messageID = this.resolveID(message); const messageID = this.resolveID(message);
if (!messageID) throw new TypeError('INVALID_TYPE', 'message', 'MessageResolvable'); if (!messageID) throw new TypeError('INVALID_TYPE', 'message', 'MessageResolvable');
const { data, files } = await (options instanceof APIMessage const { data, files } = await (options instanceof MessagePayload
? options ? options
: APIMessage.create(message instanceof Message ? message : this, options) : MessagePayload.create(message instanceof Message ? message : this, options)
) )
.resolveData() .resolveData()
.resolveFiles(); .resolveFiles();

View File

@@ -28,8 +28,8 @@ class InteractionWebhook {
/* eslint-disable no-empty-function, valid-jsdoc */ /* eslint-disable no-empty-function, valid-jsdoc */
/** /**
* Sends a message with this webhook. * Sends a message with this webhook.
* @param {string|APIMessage|InteractionReplyOptions} options The content for the reply * @param {string|MessagePayload|InteractionReplyOptions} options The content for the reply
* @returns {Promise<Message|APIMessageRaw>} * @returns {Promise<Message|APIMessage>}
*/ */
send() {} send() {}
fetchMessage() {} fetchMessage() {}

View File

@@ -1,6 +1,5 @@
'use strict'; 'use strict';
const APIMessage = require('./APIMessage');
const Base = require('./Base'); const Base = require('./Base');
const BaseMessageComponent = require('./BaseMessageComponent'); const BaseMessageComponent = require('./BaseMessageComponent');
const ClientApplication = require('./ClientApplication'); const ClientApplication = require('./ClientApplication');
@@ -8,6 +7,7 @@ const MessageAttachment = require('./MessageAttachment');
const MessageComponentInteractionCollector = require('./MessageComponentInteractionCollector'); const MessageComponentInteractionCollector = require('./MessageComponentInteractionCollector');
const Embed = require('./MessageEmbed'); const Embed = require('./MessageEmbed');
const Mentions = require('./MessageMentions'); const Mentions = require('./MessageMentions');
const MessagePayload = require('./MessagePayload');
const ReactionCollector = require('./ReactionCollector'); const ReactionCollector = require('./ReactionCollector');
const Sticker = require('./Sticker'); const Sticker = require('./Sticker');
const { Error } = require('../errors'); const { Error } = require('../errors');
@@ -26,7 +26,7 @@ const Util = require('../util/Util');
class Message extends Base { class Message extends Base {
/** /**
* @param {Client} client The instantiating client * @param {Client} client The instantiating client
* @param {APIMessageRaw} data The data for the message * @param {APIMessage} data The data for the message
* @param {TextChannel|DMChannel|NewsChannel} channel The channel the message was sent in * @param {TextChannel|DMChannel|NewsChannel} channel The channel the message was sent in
*/ */
constructor(client, data, channel) { constructor(client, data, channel) {
@@ -300,7 +300,7 @@ class Message extends Base {
/** /**
* Updates the message and returns the old message. * Updates the message and returns the old message.
* @param {APIMessageRaw} data Raw Discord message update data * @param {APIMessage} data Raw Discord message update data
* @returns {Message} * @returns {Message}
* @private * @private
*/ */
@@ -565,7 +565,7 @@ class Message extends Base {
/** /**
* Edits the content of the message. * Edits the content of the message.
* @param {string|APIMessage|MessageEditOptions} options The options to provide * @param {string|MessagePayload|MessageEditOptions} options The options to provide
* @returns {Promise<Message>} * @returns {Promise<Message>}
* @example * @example
* // Update the content of a message * // Update the content of a message
@@ -667,7 +667,7 @@ class Message extends Base {
/** /**
* Send an inline reply to this message. * Send an inline reply to this message.
* @param {string|APIMessage|ReplyMessageOptions} options The options to provide * @param {string|MessagePayload|ReplyMessageOptions} options The options to provide
* @returns {Promise<Message|Message[]>} * @returns {Promise<Message|Message[]>}
* @example * @example
* // Reply to a message * // Reply to a message
@@ -678,10 +678,10 @@ class Message extends Base {
reply(options) { reply(options) {
let data; let data;
if (options instanceof APIMessage) { if (options instanceof MessagePayload) {
data = options; data = options;
} else { } else {
data = APIMessage.create(this, options, { data = MessagePayload.create(this, options, {
reply: { reply: {
messageReference: this, messageReference: this,
failIfNotExists: options?.failIfNotExists ?? true, failIfNotExists: options?.failIfNotExists ?? true,
@@ -754,7 +754,7 @@ class Message extends Base {
* without checking all the properties, use `message.id === message2.id`, which is much more efficient. This * without checking all the properties, use `message.id === message2.id`, which is much more efficient. This
* method allows you to see if there are differences in content, embeds, attachments, nonce and tts properties. * method allows you to see if there are differences in content, embeds, attachments, nonce and tts properties.
* @param {Message} message The message to compare it to * @param {Message} message The message to compare it to
* @param {APIMessageRaw} rawData Raw data passed through the WebSocket about this message * @param {APIMessage} rawData Raw data passed through the WebSocket about this message
* @returns {boolean} * @returns {boolean}
*/ */
equals(message, rawData) { equals(message, rawData) {

View File

@@ -16,7 +16,7 @@ class MessageComponentInteraction extends Interaction {
/** /**
* The message to which the component was attached * The message to which the component was attached
* @type {?(Message|APIMessageRaw)} * @type {?(Message|APIMessage)}
*/ */
this.message = data.message ? this.channel?.messages.add(data.message) ?? data.message : null; this.message = data.message ? this.channel?.messages.add(data.message) ?? data.message : null;

View File

@@ -11,7 +11,7 @@ const Util = require('../util/Util');
/** /**
* Represents a message to be sent to the API. * Represents a message to be sent to the API.
*/ */
class APIMessage { class MessagePayload {
/** /**
* @param {MessageTarget} target - The target for this message to be sent to * @param {MessageTarget} target - The target for this message to be sent to
* @param {MessageOptions|WebhookMessageOptions} options - Options passed in from send * @param {MessageOptions|WebhookMessageOptions} options - Options passed in from send
@@ -31,7 +31,7 @@ class APIMessage {
/** /**
* Data sendable to the API * Data sendable to the API
* @type {?APIMessageRaw} * @type {?APIMessage}
*/ */
this.data = null; this.data = null;
@@ -119,7 +119,7 @@ class APIMessage {
/** /**
* Resolves data. * Resolves data.
* @returns {APIMessage} * @returns {MessagePayload}
*/ */
resolveData() { resolveData() {
if (this.data) return this; if (this.data) return this;
@@ -202,7 +202,7 @@ class APIMessage {
/** /**
* Resolves files. * Resolves files.
* @returns {Promise<APIMessage>} * @returns {Promise<MessagePayload>}
*/ */
async resolveFiles() { async resolveFiles() {
if (this.files) return this; if (this.files) return this;
@@ -247,7 +247,7 @@ class APIMessage {
} }
/** /**
* Creates an `APIMessage` from user-level arguments. * Creates a `MessagePayload` from user-level arguments.
* @param {MessageTarget} target Target to send to * @param {MessageTarget} target Target to send to
* @param {string|MessageOptions|WebhookMessageOptions} options Options or content to use * @param {string|MessageOptions|WebhookMessageOptions} options Options or content to use
* @param {MessageOptions|WebhookMessageOptions} [extra={}] - Extra options to add onto specified options * @param {MessageOptions|WebhookMessageOptions} [extra={}] - Extra options to add onto specified options
@@ -261,7 +261,7 @@ class APIMessage {
} }
} }
module.exports = APIMessage; module.exports = MessagePayload;
/** /**
* A target for a message. * A target for a message.
@@ -270,6 +270,6 @@ module.exports = APIMessage;
*/ */
/** /**
* @external APIMessageRaw * @external APIMessage
* @see {@link https://discord.com/developers/docs/resources/channel#message-object} * @see {@link https://discord.com/developers/docs/resources/channel#message-object}
*/ */

View File

@@ -1,7 +1,7 @@
'use strict'; 'use strict';
const APIMessage = require('./APIMessage');
const Channel = require('./Channel'); const Channel = require('./Channel');
const MessagePayload = require('./MessagePayload');
const { Error } = require('../errors'); const { Error } = require('../errors');
const { WebhookTypes } = require('../util/Constants'); const { WebhookTypes } = require('../util/Constants');
const DataResolver = require('../util/DataResolver'); const DataResolver = require('../util/DataResolver');
@@ -109,8 +109,8 @@ class Webhook {
/** /**
* Sends a message with this webhook. * Sends a message with this webhook.
* @param {string|APIMessage|WebhookMessageOptions} options The options to provide * @param {string|MessagePayload|WebhookMessageOptions} options The options to provide
* @returns {Promise<Message|APIMessageRaw>} * @returns {Promise<Message|APIMessage>}
* @example * @example
* // Send a basic message * // Send a basic message
* webhook.send('hello!') * webhook.send('hello!')
@@ -158,21 +158,21 @@ class Webhook {
async send(options) { async send(options) {
if (!this.token) throw new Error('WEBHOOK_TOKEN_UNAVAILABLE'); if (!this.token) throw new Error('WEBHOOK_TOKEN_UNAVAILABLE');
let apiMessage; let messagePayload;
if (options instanceof APIMessage) { if (options instanceof MessagePayload) {
apiMessage = options.resolveData(); messagePayload = options.resolveData();
} else { } else {
apiMessage = APIMessage.create(this, options).resolveData(); messagePayload = MessagePayload.create(this, options).resolveData();
} }
const { data, files } = await apiMessage.resolveFiles(); const { data, files } = await messagePayload.resolveFiles();
return this.client.api return this.client.api
.webhooks(this.id, this.token) .webhooks(this.id, this.token)
.post({ .post({
data, data,
files, files,
query: { thread_id: apiMessage.options.threadID, wait: true }, query: { thread_id: messagePayload.options.threadID, wait: true },
auth: false, auth: false,
}) })
.then(d => { .then(d => {
@@ -247,7 +247,7 @@ class Webhook {
* Gets a message that was sent by this webhook. * Gets a message that was sent by this webhook.
* @param {Snowflake|'@original'} message The ID of the message to fetch * @param {Snowflake|'@original'} message The ID of the message to fetch
* @param {boolean} [cache=true] Whether to cache the message * @param {boolean} [cache=true] Whether to cache the message
* @returns {Promise<Message|APIMessageRaw>} Returns the raw message data if the webhook was instantiated as a * @returns {Promise<Message|APIMessage>} Returns the raw message data if the webhook was instantiated as a
* {@link WebhookClient} or if the channel is uncached, otherwise a {@link Message} will be returned * {@link WebhookClient} or if the channel is uncached, otherwise a {@link Message} will be returned
*/ */
async fetchMessage(message, cache = true) { async fetchMessage(message, cache = true) {
@@ -260,19 +260,19 @@ class Webhook {
/** /**
* Edits a message that was sent by this webhook. * Edits a message that was sent by this webhook.
* @param {MessageResolvable|'@original'} message The message to edit * @param {MessageResolvable|'@original'} message The message to edit
* @param {string|APIMessage|WebhookEditMessageOptions} options The options to provide * @param {string|MessagePayload|WebhookEditMessageOptions} options The options to provide
* @returns {Promise<Message|APIMessageRaw>} Returns the raw message data if the webhook was instantiated as a * @returns {Promise<Message|APIMessage>} Returns the raw message data if the webhook was instantiated as a
* {@link WebhookClient} or if the channel is uncached, otherwise a {@link Message} will be returned * {@link WebhookClient} or if the channel is uncached, otherwise a {@link Message} will be returned
*/ */
async editMessage(message, options) { async editMessage(message, options) {
if (!this.token) throw new Error('WEBHOOK_TOKEN_UNAVAILABLE'); if (!this.token) throw new Error('WEBHOOK_TOKEN_UNAVAILABLE');
let apiMessage; let messagePayload;
if (options instanceof APIMessage) apiMessage = options; if (options instanceof MessagePayload) messagePayload = options;
else apiMessage = APIMessage.create(this, options); else messagePayload = MessagePayload.create(this, options);
const { data, files } = await apiMessage.resolveData().resolveFiles(); const { data, files } = await messagePayload.resolveData().resolveFiles();
const d = await this.client.api const d = await this.client.api
.webhooks(this.id, this.token) .webhooks(this.id, this.token)

View File

@@ -3,7 +3,7 @@
const { Error } = require('../../errors'); const { Error } = require('../../errors');
const { InteractionResponseTypes } = require('../../util/Constants'); const { InteractionResponseTypes } = require('../../util/Constants');
const MessageFlags = require('../../util/MessageFlags'); const MessageFlags = require('../../util/MessageFlags');
const APIMessage = require('../APIMessage'); const MessagePayload = require('../MessagePayload');
/** /**
* Interface for classes that support shared interaction response types. * Interface for classes that support shared interaction response types.
@@ -53,7 +53,7 @@ class InteractionResponses {
/** /**
* Creates a reply to this interaction. * Creates a reply to this interaction.
* @param {string|APIMessage|InteractionReplyOptions} options The options for the reply * @param {string|MessagePayload|InteractionReplyOptions} options The options for the reply
* @returns {Promise<void>} * @returns {Promise<void>}
* @example * @example
* // Reply to the interaction with an embed * // Reply to the interaction with an embed
@@ -72,11 +72,11 @@ class InteractionResponses {
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED'); if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
this.ephemeral = options.ephemeral ?? false; this.ephemeral = options.ephemeral ?? false;
let apiMessage; let messagePayload;
if (options instanceof APIMessage) apiMessage = options; if (options instanceof MessagePayload) messagePayload = options;
else apiMessage = APIMessage.create(this, options); else messagePayload = MessagePayload.create(this, options);
const { data, files } = await apiMessage.resolveData().resolveFiles(); const { data, files } = await messagePayload.resolveData().resolveFiles();
await this.client.api.interactions(this.id, this.token).callback.post({ await this.client.api.interactions(this.id, this.token).callback.post({
data: { data: {
@@ -91,7 +91,7 @@ class InteractionResponses {
/** /**
* Fetches the initial reply to this interaction. * Fetches the initial reply to this interaction.
* @see Webhook#fetchMessage * @see Webhook#fetchMessage
* @returns {Promise<Message|APIMessageRaw>} * @returns {Promise<Message|APIMessage>}
* @example * @example
* // Fetch the reply to this interaction * // Fetch the reply to this interaction
* interaction.fetchReply() * interaction.fetchReply()
@@ -106,8 +106,8 @@ class InteractionResponses {
/** /**
* Edits the initial reply to this interaction. * Edits the initial reply to this interaction.
* @see Webhook#editMessage * @see Webhook#editMessage
* @param {string|APIMessage|WebhookEditMessageOptions} options The new options for the message * @param {string|MessagePayload|WebhookEditMessageOptions} options The new options for the message
* @returns {Promise<Message|APIMessageRaw>} * @returns {Promise<Message|APIMessage>}
* @example * @example
* // Edit the reply to this interaction * // Edit the reply to this interaction
* interaction.editReply('New content') * interaction.editReply('New content')
@@ -138,8 +138,8 @@ class InteractionResponses {
/** /**
* Send a follow-up message to this interaction. * Send a follow-up message to this interaction.
* @param {string|APIMessage|InteractionReplyOptions} options The options for the reply * @param {string|MessagePayload|InteractionReplyOptions} options The options for the reply
* @returns {Promise<Message|APIMessageRaw>} * @returns {Promise<Message|APIMessage>}
*/ */
followUp(options) { followUp(options) {
return this.webhook.send(options); return this.webhook.send(options);
@@ -166,7 +166,7 @@ class InteractionResponses {
/** /**
* Updates the original message whose button was pressed * Updates the original message whose button was pressed
* @param {string|APIMessage|WebhookEditMessageOptions} options The options for the reply * @param {string|MessagePayload|WebhookEditMessageOptions} options The options for the reply
* @returns {Promise<void>} * @returns {Promise<void>}
* @example * @example
* // Remove the components from the message * // Remove the components from the message
@@ -180,11 +180,11 @@ class InteractionResponses {
async update(options) { async update(options) {
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED'); if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
let apiMessage; let messagePayload;
if (options instanceof APIMessage) apiMessage = options; if (options instanceof MessagePayload) messagePayload = options;
else apiMessage = APIMessage.create(this, options); else messagePayload = MessagePayload.create(this, options);
const { data, files } = await apiMessage.resolveData().resolveFiles(); const { data, files } = await messagePayload.resolveData().resolveFiles();
await this.client.api.interactions(this.id, this.token).callback.post({ await this.client.api.interactions(this.id, this.token).callback.post({
data: { data: {

View File

@@ -2,7 +2,7 @@
/* eslint-disable import/order */ /* eslint-disable import/order */
const MessageCollector = require('../MessageCollector'); const MessageCollector = require('../MessageCollector');
const APIMessage = require('../APIMessage'); const MessagePayload = require('../MessagePayload');
const SnowflakeUtil = require('../../util/SnowflakeUtil'); const SnowflakeUtil = require('../../util/SnowflakeUtil');
const Collection = require('../../util/Collection'); const Collection = require('../../util/Collection');
const { RangeError, TypeError, Error } = require('../../errors'); const { RangeError, TypeError, Error } = require('../../errors');
@@ -105,7 +105,7 @@ class TextBasedChannel {
/** /**
* Sends a message to this channel. * Sends a message to this channel.
* @param {string|APIMessage|MessageOptions} options The options to provide * @param {string|MessagePayload|MessageOptions} options The options to provide
* @returns {Promise<Message|Message[]>} * @returns {Promise<Message|Message[]>}
* @example * @example
* // Send a basic message * // Send a basic message
@@ -156,15 +156,15 @@ class TextBasedChannel {
return this.createDM().then(dm => dm.send(options)); return this.createDM().then(dm => dm.send(options));
} }
let apiMessage; let messagePayload;
if (options instanceof APIMessage) { if (options instanceof MessagePayload) {
apiMessage = options.resolveData(); messagePayload = options.resolveData();
} else { } else {
apiMessage = APIMessage.create(this, options).resolveData(); messagePayload = MessagePayload.create(this, options).resolveData();
} }
const { data, files } = await apiMessage.resolveFiles(); const { data, files } = await messagePayload.resolveFiles();
return this.client.api.channels[this.id].messages return this.client.api.channels[this.id].messages
.post({ data, files }) .post({ data, files })
.then(d => this.client.actions.MessageCreate.handle(d).message); .then(d => this.client.actions.MessageCreate.handle(d).message);

78
typings/index.d.ts vendored
View File

@@ -139,17 +139,17 @@ declare module 'discord.js' {
import BaseCollection from '@discordjs/collection'; import BaseCollection from '@discordjs/collection';
import { ChildProcess } from 'child_process'; import { ChildProcess } from 'child_process';
import { import {
APIActionRowComponent as RawActionRowComponent, APIActionRowComponent,
APIInteractionDataResolvedChannel as RawInteractionDataResolvedChannel, APIInteractionDataResolvedChannel,
APIInteractionDataResolvedGuildMember as RawInteractionDataResolvedGuildMember, APIInteractionDataResolvedGuildMember,
APIInteractionGuildMember as RawInteractionGuildMember, APIInteractionGuildMember,
APIMessage as RawMessage, APIMessage,
APIMessageComponent as RawMessageComponent, APIMessageComponent,
APIOverwrite as RawOverwrite, APIOverwrite,
APIPartialEmoji as RawEmoji, APIPartialEmoji,
APIRole as RawRole, APIRole,
Snowflake as APISnowflake,
APIUser, APIUser,
Snowflake as APISnowflake,
ApplicationCommandOptionType as ApplicationCommandOptionTypes, ApplicationCommandOptionType as ApplicationCommandOptionTypes,
ApplicationCommandPermissionType as ApplicationCommandPermissionTypes, ApplicationCommandPermissionType as ApplicationCommandPermissionTypes,
} from 'discord-api-types/v8'; } from 'discord-api-types/v8';
@@ -209,7 +209,7 @@ declare module 'discord.js' {
public splashURL(options?: StaticImageURLOptions): string | null; public splashURL(options?: StaticImageURLOptions): string | null;
} }
export class APIMessage { export class MessagePayload {
constructor(target: MessageTarget, options: MessageOptions | WebhookMessageOptions); constructor(target: MessageTarget, options: MessageOptions | WebhookMessageOptions);
public data: unknown | null; public data: unknown | null;
public readonly isUser: boolean; public readonly isUser: boolean;
@@ -225,7 +225,7 @@ declare module 'discord.js' {
target: MessageTarget, target: MessageTarget,
options: string | MessageOptions | WebhookMessageOptions, options: string | MessageOptions | WebhookMessageOptions,
extra?: MessageOptions | WebhookMessageOptions, extra?: MessageOptions | WebhookMessageOptions,
): APIMessage; ): MessagePayload;
public static resolveFile(fileLike: BufferResolvable | Stream | FileOptions | MessageAttachment): Promise<unknown>; public static resolveFile(fileLike: BufferResolvable | Stream | FileOptions | MessageAttachment): Promise<unknown>;
public makeContent(): string | undefined; public makeContent(): string | undefined;
@@ -524,10 +524,10 @@ declare module 'discord.js' {
public webhook: InteractionWebhook; public webhook: InteractionWebhook;
public defer(options?: InteractionDeferOptions): Promise<void>; public defer(options?: InteractionDeferOptions): Promise<void>;
public deleteReply(): Promise<void>; public deleteReply(): Promise<void>;
public editReply(options: string | APIMessage | WebhookEditMessageOptions): Promise<Message | RawMessage>; public editReply(options: string | MessagePayload | WebhookEditMessageOptions): Promise<Message | APIMessage>;
public fetchReply(): Promise<Message | RawMessage>; public fetchReply(): Promise<Message | APIMessage>;
public followUp(options: string | APIMessage | InteractionReplyOptions): Promise<Message | RawMessage>; public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message | APIMessage>;
public reply(options: string | APIMessage | InteractionReplyOptions): Promise<void>; public reply(options: string | MessagePayload | InteractionReplyOptions): Promise<void>;
private transformOption(option: unknown, resolved: unknown): CommandInteractionOption; private transformOption(option: unknown, resolved: unknown): CommandInteractionOption;
private _createOptionsCollection(options: unknown, resolved: unknown): Collection<string, CommandInteractionOption>; private _createOptionsCollection(options: unknown, resolved: unknown): Collection<string, CommandInteractionOption>;
} }
@@ -1171,7 +1171,7 @@ declare module 'discord.js' {
public readonly guild: Guild | null; public readonly guild: Guild | null;
public guildID: Snowflake | null; public guildID: Snowflake | null;
public id: Snowflake; public id: Snowflake;
public member: GuildMember | RawInteractionGuildMember | null; public member: GuildMember | APIInteractionGuildMember | null;
public readonly token: string; public readonly token: string;
public type: InteractionType; public type: InteractionType;
public user: User; public user: User;
@@ -1185,7 +1185,7 @@ declare module 'discord.js' {
export class InteractionWebhook extends PartialWebhookMixin() { export class InteractionWebhook extends PartialWebhookMixin() {
constructor(client: Client, id: Snowflake, token: string); constructor(client: Client, id: Snowflake, token: string);
public token: string; public token: string;
public send(options: string | APIMessage | InteractionReplyOptions): Promise<Message | RawMessage>; public send(options: string | MessagePayload | InteractionReplyOptions): Promise<Message | RawMessage>;
} }
export class Invite extends Base { export class Invite extends Base {
@@ -1283,7 +1283,7 @@ declare module 'discord.js' {
options?: MessageComponentInteractionCollectorOptions, options?: MessageComponentInteractionCollectorOptions,
): MessageComponentInteractionCollector; ): MessageComponentInteractionCollector;
public delete(): Promise<Message>; public delete(): Promise<Message>;
public edit(content: string | MessageEditOptions | APIMessage): Promise<Message>; public edit(content: string | MessageEditOptions | MessagePayload): Promise<Message>;
public equals(message: Message, rawData: unknown): boolean; public equals(message: Message, rawData: unknown): boolean;
public fetchReference(): Promise<Message>; public fetchReference(): Promise<Message>;
public fetchWebhook(): Promise<Webhook>; public fetchWebhook(): Promise<Webhook>;
@@ -1292,7 +1292,7 @@ declare module 'discord.js' {
public pin(): Promise<Message>; public pin(): Promise<Message>;
public react(emoji: EmojiIdentifierResolvable): Promise<MessageReaction>; public react(emoji: EmojiIdentifierResolvable): Promise<MessageReaction>;
public removeAttachments(): Promise<Message>; public removeAttachments(): Promise<Message>;
public reply(options: string | APIMessage | ReplyMessageOptions): Promise<Message>; public reply(options: string | MessagePayload | ReplyMessageOptions): Promise<Message>;
public startThread( public startThread(
name: string, name: string,
autoArchiveDuration: ThreadAutoArchiveDuration, autoArchiveDuration: ThreadAutoArchiveDuration,
@@ -1341,7 +1341,7 @@ declare module 'discord.js' {
constructor(data?: MessageButton | MessageButtonOptions); constructor(data?: MessageButton | MessageButtonOptions);
public customID: string | null; public customID: string | null;
public disabled: boolean; public disabled: boolean;
public emoji: RawEmoji | null; public emoji: APIPartialEmoji | null;
public label: string | null; public label: string | null;
public style: MessageButtonStyle | null; public style: MessageButtonStyle | null;
public type: 'BUTTON'; public type: 'BUTTON';
@@ -1377,17 +1377,17 @@ declare module 'discord.js' {
public customID: string; public customID: string;
public deferred: boolean; public deferred: boolean;
public ephemeral: boolean | null; public ephemeral: boolean | null;
public message: Message | RawMessage; public message: Message | APIMessage;
public replied: boolean; public replied: boolean;
public webhook: InteractionWebhook; public webhook: InteractionWebhook;
public defer(options?: InteractionDeferOptions): Promise<void>; public defer(options?: InteractionDeferOptions): Promise<void>;
public deferUpdate(): Promise<void>; public deferUpdate(): Promise<void>;
public deleteReply(): Promise<void>; public deleteReply(): Promise<void>;
public editReply(options: string | APIMessage | WebhookEditMessageOptions): Promise<Message | RawMessage>; public editReply(options: string | MessagePayload | WebhookEditMessageOptions): Promise<Message | APIMessage>;
public fetchReply(): Promise<Message | RawMessage>; public fetchReply(): Promise<Message | APIMessage>;
public followUp(options: string | APIMessage | InteractionReplyOptions): Promise<Message | RawMessage>; public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message | APIMessage>;
public reply(options: string | APIMessage | InteractionReplyOptions): Promise<void>; public reply(options: string | MessagePayload | InteractionReplyOptions): Promise<void>;
public update(content: string | APIMessage | WebhookEditMessageOptions): Promise<void>; public update(content: string | MessagePayload | WebhookEditMessageOptions): Promise<void>;
public static resolveType(type: MessageComponentTypeResolvable): MessageComponentType; public static resolveType(type: MessageComponentTypeResolvable): MessageComponentType;
} }
@@ -1587,7 +1587,7 @@ declare module 'discord.js' {
options: PermissionOverwriteOptions, options: PermissionOverwriteOptions,
initialPermissions: { allow?: PermissionResolvable; deny?: PermissionResolvable }, initialPermissions: { allow?: PermissionResolvable; deny?: PermissionResolvable },
): ResolvedOverwriteOptions; ): ResolvedOverwriteOptions;
public static resolve(overwrite: OverwriteResolvable, guild: Guild): RawOverwrite; public static resolve(overwrite: OverwriteResolvable, guild: Guild): APIOverwrite;
} }
export class Permissions extends BitField<PermissionString, bigint> { export class Permissions extends BitField<PermissionString, bigint> {
@@ -2026,7 +2026,7 @@ declare module 'discord.js' {
public static moveElementInArray(array: any[], element: any, newIndex: number, offset?: boolean): number; public static moveElementInArray(array: any[], element: any, newIndex: number, offset?: boolean): number;
public static parseEmoji(text: string): { animated: boolean; name: string; id: Snowflake | null } | null; public static parseEmoji(text: string): { animated: boolean; name: string; id: Snowflake | null } | null;
public static resolveColor(color: ColorResolvable): number; public static resolveColor(color: ColorResolvable): number;
public static resolvePartialEmoji(emoji: EmojiIdentifierResolvable): Partial<RawEmoji> | null; public static resolvePartialEmoji(emoji: EmojiIdentifierResolvable): Partial<APIPartialEmoji> | null;
public static verifyString(data: string, error?: typeof Error, errorMessage?: string, allowEmpty?: boolean): string; public static verifyString(data: string, error?: typeof Error, errorMessage?: string, allowEmpty?: boolean): string;
public static setPosition<T extends Channel | Role>( public static setPosition<T extends Channel | Role>(
item: T, item: T,
@@ -2122,10 +2122,10 @@ declare module 'discord.js' {
public token: string; public token: string;
public editMessage( public editMessage(
message: MessageResolvable, message: MessageResolvable,
options: string | APIMessage | WebhookEditMessageOptions, options: string | MessagePayload | WebhookEditMessageOptions,
): Promise<RawMessage>; ): Promise<RawMessage>;
public fetchMessage(message: Snowflake, cache?: boolean): Promise<RawMessage>; public fetchMessage(message: Snowflake, cache?: boolean): Promise<RawMessage>;
public send(options: string | APIMessage | WebhookMessageOptions): Promise<RawMessage>; public send(options: string | MessagePayload | WebhookMessageOptions): Promise<RawMessage>;
} }
export class WebSocketManager extends EventEmitter { export class WebSocketManager extends EventEmitter {
@@ -2480,7 +2480,7 @@ declare module 'discord.js' {
public cache: Collection<Snowflake, Message>; public cache: Collection<Snowflake, Message>;
public crosspost(message: MessageResolvable): Promise<Message>; public crosspost(message: MessageResolvable): Promise<Message>;
public delete(message: MessageResolvable): Promise<void>; public delete(message: MessageResolvable): Promise<void>;
public edit(message: MessageResolvable, options: APIMessage | MessageEditOptions): Promise<Message>; public edit(message: MessageResolvable, options: MessagePayload | MessageEditOptions): Promise<Message>;
public fetch(message: Snowflake, options?: BaseFetchOptions): Promise<Message>; public fetch(message: Snowflake, options?: BaseFetchOptions): Promise<Message>;
public fetch( public fetch(
options?: ChannelLogsQueryOptions, options?: ChannelLogsQueryOptions,
@@ -2587,7 +2587,7 @@ declare module 'discord.js' {
interface PartialTextBasedChannelFields { interface PartialTextBasedChannelFields {
lastMessageID: Snowflake | null; lastMessageID: Snowflake | null;
readonly lastMessage: Message | null; readonly lastMessage: Message | null;
send(options: string | APIMessage | MessageOptions): Promise<Message>; send(options: string | MessagePayload | MessageOptions): Promise<Message>;
} }
interface TextBasedChannelFields extends PartialTextBasedChannelFields { interface TextBasedChannelFields extends PartialTextBasedChannelFields {
@@ -2623,10 +2623,10 @@ declare module 'discord.js' {
deleteMessage(message: MessageResolvable | '@original'): Promise<void>; deleteMessage(message: MessageResolvable | '@original'): Promise<void>;
editMessage( editMessage(
message: MessageResolvable | '@original', message: MessageResolvable | '@original',
options: string | APIMessage | WebhookEditMessageOptions, options: string | MessagePayload | WebhookEditMessageOptions,
): Promise<Message | RawMessage>; ): Promise<Message | RawMessage>;
fetchMessage(message: Snowflake | '@original', cache?: boolean): Promise<Message | RawMessage>; fetchMessage(message: Snowflake | '@original', cache?: boolean): Promise<Message | RawMessage>;
send(options: string | APIMessage | WebhookMessageOptions): Promise<Message | RawMessage>; send(options: string | MessagePayload | WebhookMessageOptions): Promise<Message | RawMessage>;
} }
interface WebhookFields extends PartialWebhookFields { interface WebhookFields extends PartialWebhookFields {
@@ -3095,9 +3095,9 @@ declare module 'discord.js' {
value?: string | number | boolean; value?: string | number | boolean;
options?: Collection<string, CommandInteractionOption>; options?: Collection<string, CommandInteractionOption>;
user?: User; user?: User;
member?: GuildMember | RawInteractionDataResolvedGuildMember; member?: GuildMember | APIInteractionDataResolvedGuildMember;
channel?: GuildChannel | RawInteractionDataResolvedChannel; channel?: GuildChannel | APIInteractionDataResolvedChannel;
role?: Role | RawRole; role?: Role | APIRole;
} }
interface CreateRoleOptions extends RoleData { interface CreateRoleOptions extends RoleData {
@@ -3776,7 +3776,7 @@ declare module 'discord.js' {
interface MessageSelectOption { interface MessageSelectOption {
default: boolean; default: boolean;
description: string | null; description: string | null;
emoji: RawEmoji | null; emoji: APIPartialEmoji | null;
label: string; label: string;
value: string; value: string;
} }