mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +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.
|
||||
* @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>}
|
||||
*/
|
||||
async edit(message, options) {
|
||||
message = this.resolveID(message);
|
||||
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 });
|
||||
|
||||
if (this.cache.has(message)) {
|
||||
|
||||
@@ -494,11 +494,8 @@ class Message extends Base {
|
||||
* .catch(console.error);
|
||||
*/
|
||||
edit(content, options) {
|
||||
if (!options && typeof content === 'object' && !Array.isArray(content)) {
|
||||
options = content;
|
||||
content = undefined;
|
||||
}
|
||||
return this.channel.messages.edit(this.id, { content, ...options });
|
||||
options = content instanceof APIMessage ? content : APIMessage.create(this.channel, content, options);
|
||||
return this.channel.messages.edit(this.id, 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 crosspost(message: MessageResolvable): Promise<Message>;
|
||||
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(
|
||||
options?: ChannelLogsQueryOptions,
|
||||
|
||||
Reference in New Issue
Block a user