Skip to content

Commit

Permalink
Move to content.messageReference (abalabahaha#1187)
Browse files Browse the repository at this point in the history
Co-authored-by: abalabahaha <hi@abal.moe>
  • Loading branch information
bsian03 and abalabahaha authored Apr 25, 2021
1 parent e2814a2 commit c3d491d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
6 changes: 6 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ declare namespace Eris {
content?: string;
embed?: EmbedOptions;
flags?: number;
messageReference?: MessageReferenceReply;
/** @deprecated */
messageReferenceID?: string;
tts?: boolean;
};
Expand Down Expand Up @@ -804,6 +806,10 @@ declare namespace Eris {
guildID?: string;
messageID?: string;
}
interface MessageReferenceReply extends MessageReferenceBase {
messageID: string;
failIfNotExists?: boolean;
}
interface Sticker {
asset: string;
description: string;
Expand Down
28 changes: 26 additions & 2 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,12 @@ class Client extends EventEmitter {
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to.
* @arg {String} content.content A content string
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
* @arg {String} [content.messageReferenceID] The ID of the message should be replied to. The reference message cannot be a system message.
* @arg {Object} [content.messageReference] The message reference, used when replying to messages
* @arg {String} [content.messageReference.channelID] The channel ID of the referenced message
* @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message
* @arg {String} [content.messageReference.guildID] The guild ID of the referenced message
* @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message
* @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead
* @arg {Boolean} [content.tts] Set the message TTS flag
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
* @arg {Buffer} file.file A buffer containing file data
Expand All @@ -600,7 +605,26 @@ class Client extends EventEmitter {
return Promise.reject(new Error("No content, file, or embed"));
}
content.allowed_mentions = this._formatAllowedMentions(content.allowedMentions);
if(content.messageReferenceID) {
if(content.messageReference) {
content.message_reference = content.messageReference;
if(content.messageReference.messageID !== undefined) {
content.message_reference.message_id = content.messageReference.messageID;
content.messageReference.messageID = undefined;
}
if(content.messageReference.channelID !== undefined) {
content.message_reference.channel_id = content.messageReference.channelID;
content.messageReference.channelID = undefined;
}
if(content.messageReference.guildID !== undefined) {
content.message_reference.guild_id = content.messageReference.guildID;
content.messageReference.guildID = undefined;
}
if(content.messageReference.failIfNotExists !== undefined) {
content.message_reference.fail_if_not_exists = content.messageReference.failIfNotExists;
content.messageReference.failIfNotExists = undefined;
}
} else if(content.messageReferenceID) {
this.emit("warn", "[DEPRECATED] content.messageReferenceID is deprecated. Use content.messageReference instead");
content.message_reference = {message_id: content.messageReferenceID};
}
} else if(!file) {
Expand Down
7 changes: 6 additions & 1 deletion lib/structures/PrivateChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ class PrivateChannel extends Channel {
* @arg {Boolean} [options.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to
* @arg {String} content.content A content string
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
* @arg {String} [content.messageReferenceID] The ID of the message should be replied to. The reference message cannot be a system message.
* @arg {Object} [content.messageReference] The message reference, used when replying to messages
* @arg {String} [content.messageReference.channelID] The channel ID of the referenced message
* @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message
* @arg {String} [content.messageReference.guildID] The guild ID of the referenced message
* @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message
* @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead
* @arg {Boolean} [content.tts] Set the message TTS flag
* @arg {Object} [file] A file object
* @arg {Buffer} file.file A buffer containing file data
Expand Down
7 changes: 6 additions & 1 deletion lib/structures/TextChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ class TextChannel extends GuildChannel {
* @arg {Boolean} [options.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to
* @arg {String} content.content A content string
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
* @arg {String} [content.messageReferenceID] The ID of the message should be replied to. The reference message cannot be a system message.
* @arg {Object} [content.messageReference] The message reference, used when replying to messages
* @arg {String} [content.messageReference.channelID] The channel ID of the referenced message
* @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message
* @arg {String} [content.messageReference.guildID] The guild ID of the referenced message
* @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message
* @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead
* @arg {Boolean} [content.tts] Set the message TTS flag
* @arg {Object} [file] A file object
* @arg {Buffer} file.file A buffer containing file data
Expand Down

0 comments on commit c3d491d

Please sign in to comment.