Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
DonovanDMC committed Jul 12, 2021
2 parents f3b991e + f2bcd50 commit 59b7559
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,9 @@ declare namespace Eris {
allowedMentions?: AllowedMentions;
content?: string;
components?: ActionRow[];
/** @deprecated */
embed?: EmbedOptions;
embeds?: EmbedOptions[];
flags?: number;
messageReference?: MessageReferenceReply;
/** @deprecated */
Expand Down
26 changes: 17 additions & 9 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,8 @@ class Client extends EventEmitter {
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
* @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 {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure. Use `embeds` instead
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
* @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
Expand All @@ -620,8 +621,11 @@ class Client extends EventEmitter {
};
} else if(content.content !== undefined && typeof content.content !== "string") {
content.content = "" + content.content;
} else if(content.content === undefined && !content.embed && !file) {
return Promise.reject(new Error("No content, file, or embed"));
} else if(content.content === undefined && !content.embed && !content.embeds && !file) {
return Promise.reject(new Error("No content, file, or embeds"));
} else if(content.embed && !content.embeds) {
this.emit("warn", "[DEPRECATED] content.embed is deprecated. Use content.embeds instead");
content.embeds = [content.embed];
}
content.allowed_mentions = this._formatAllowedMentions(content.allowedMentions);
if(content.messageReference) {
Expand All @@ -647,7 +651,7 @@ class Client extends EventEmitter {
content.message_reference = {message_id: content.messageReferenceID};
}
} else if(!file) {
return Promise.reject(new Error("No content, file, or embed"));
return Promise.reject(new Error("No content, file, or embeds"));
}
return this.requestHandler.request("POST", Endpoints.CHANNEL_MESSAGES(channelID), true, content, file).then((message) => new Message(message, this));
}
Expand Down Expand Up @@ -1325,7 +1329,8 @@ class Client extends EventEmitter {
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
* @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 {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure. Use `embeds` instead
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
* @arg {Object | Array<Object>} [content.file] A file object (or an Array of them)
* @arg {Buffer} content.file[].file A buffer containing file data
* @arg {String} content.file[].name What to name the file
Expand All @@ -1340,10 +1345,13 @@ class Client extends EventEmitter {
};
} else if(content.content !== undefined && typeof content.content !== "string") {
content.content = "" + content.content;
} else if(content.content === undefined && !content.embed && content.flags === undefined) {
return Promise.reject(new Error("No content, embed or flags"));
} else if(content.content === undefined && !content.embed && !content.embeds && content.flags === undefined) {
return Promise.reject(new Error("No content, embeds or flags"));
} else if(content.embed && !content.embeds) {
this.emit("warn", "[DEPRECATED] content.embed is deprecated. Use content.embeds instead");
content.embeds = [content.embed];
}
if(content.content !== undefined || content.embed || content.allowedMentions) {
if(content.content !== undefined || content.embeds || content.allowedMentions) {
content.allowed_mentions = this._formatAllowedMentions(content.allowedMentions);
}
}
Expand Down Expand Up @@ -2982,7 +2990,7 @@ class Client extends EventEmitter {

_formatImage(url, format, size) {
if(!format || !Constants.ImageFormats.includes(format.toLowerCase())) {
format = url.includes("/a_") ? "gif": this.options.defaultImageFormat;
format = url.includes("/a_") ? "gif" : this.options.defaultImageFormat;
}
if(!size || size < Constants.ImageSizeBoundaries.MINIMUM || size > Constants.ImageSizeBoundaries.MAXIMUM || (size & (size - 1))) {
size = this.options.defaultImageSize;
Expand Down
6 changes: 4 additions & 2 deletions lib/structures/PrivateChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class PrivateChannel extends Channel {
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
* @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 {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure. Use `embeds` instead
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
* @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
Expand Down Expand Up @@ -117,7 +118,8 @@ class PrivateChannel extends Channel {
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
* @arg {String} content.content A content string
* @arg {Boolean} [content.disableEveryone] Whether to filter @everyone/@here or not (overrides default)
* @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 {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure. Use `embeds` instead
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
* @arg {Object | Array<Object>} [content.file] A file object (or an Array of them)
* @arg {Buffer} content.file[].file A buffer containing file data
* @arg {String} content.file[].name What to name the file
Expand Down
6 changes: 4 additions & 2 deletions lib/structures/TextChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ class TextChannel extends GuildChannel {
* @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a select menu
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
* @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 {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure. Use `embeds` instead
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
* @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
Expand Down Expand Up @@ -188,7 +189,8 @@ class TextChannel extends GuildChannel {
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
* @arg {String} content.content A content string
* @arg {Boolean} [content.disableEveryone] Whether to filter @everyone/@here or not (overrides default)
* @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 {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure. Use `embeds` instead
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
* @arg {Object | Array<Object>} [content.file] A file object (or an Array of them)
* @arg {Buffer} content.file[].file A buffer containing file data
* @arg {String} content.file[].name What to name the file
Expand Down

0 comments on commit 59b7559

Please sign in to comment.