mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
fix(Message): editing with MessageEmbed or APIMessage (#5612)
This commit is contained in:
@@ -117,14 +117,14 @@ 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} [options] The options to provide
|
* @param {MessageEditOptions|APIMessage} [options] The options to provide
|
||||||
* @returns {Promise<Message>}
|
* @returns {Promise<Message>}
|
||||||
*/
|
*/
|
||||||
async edit(message, options) {
|
async edit(message, options) {
|
||||||
message = this.resolveID(message);
|
message = this.resolveID(message);
|
||||||
if (!message) throw new TypeError('INVALID_TYPE', 'message', 'MessageResolvable');
|
if (!message) throw new TypeError('INVALID_TYPE', 'message', 'MessageResolvable');
|
||||||
|
|
||||||
const { data } = APIMessage.create(this, options).resolveData();
|
const { data } = (options instanceof APIMessage ? options : APIMessage.create(this, options)).resolveData();
|
||||||
const d = await this.client.api.channels[this.channel.id].messages[message].patch({ data });
|
const d = await this.client.api.channels[this.channel.id].messages[message].patch({ data });
|
||||||
|
|
||||||
if (this.cache.has(message)) {
|
if (this.cache.has(message)) {
|
||||||
|
|||||||
@@ -494,11 +494,8 @@ class Message extends Base {
|
|||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
edit(content, options) {
|
edit(content, options) {
|
||||||
if (!options && typeof content === 'object' && !Array.isArray(content)) {
|
options = content instanceof APIMessage ? content : APIMessage.create(this.channel, content, options);
|
||||||
options = content;
|
return this.channel.messages.edit(this.id, options);
|
||||||
content = undefined;
|
|
||||||
}
|
|
||||||
return this.channel.messages.edit(this.id, { content, ...options });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
@@ -2193,7 +2193,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: MessageEditOptions): Promise<Message>;
|
public edit(message: MessageResolvable, options: APIMessage | MessageEditOptions): Promise<Message>;
|
||||||
public fetch(message: Snowflake, cache?: boolean, force?: boolean): Promise<Message>;
|
public fetch(message: Snowflake, cache?: boolean, force?: boolean): Promise<Message>;
|
||||||
public fetch(
|
public fetch(
|
||||||
options?: ChannelLogsQueryOptions,
|
options?: ChannelLogsQueryOptions,
|
||||||
|
|||||||
Reference in New Issue
Block a user