Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sticker Sending #1252

Merged
merged 13 commits into from
Sep 2, 2021
3 changes: 2 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ declare namespace Eris {
messageReference?: MessageReferenceReply;
/** @deprecated */
messageReferenceID?: string;
stickerIDs?: string[];
tts?: boolean;
};
type ImageFormat = "jpg" | "jpeg" | "png" | "gif" | "webp";
Expand Down Expand Up @@ -2300,9 +2301,9 @@ declare namespace Eris {
reactions: { [s: string]: { count: number; me: boolean } };
referencedMessage?: Message | null;
roleMentions: string[];
stickerItems?: StickerItems[];
bsian03 marked this conversation as resolved.
Show resolved Hide resolved
/** @deprecated */
stickers?: Sticker[];
stickerItems?: StickerItems[];
timestamp: number;
tts: boolean;
type: number;
Expand Down
8 changes: 5 additions & 3 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ class Client extends EventEmitter {
* @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 {Array<String>} [content.stickerIDs] An array of ids corresponding to stickers to send
DonovanDMC marked this conversation as resolved.
Show resolved Hide resolved
* @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 @@ -602,13 +603,14 @@ 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.embeds && !file) {
return Promise.reject(new Error("No content, file, or embeds"));
} else if(content.content === undefined && !content.embed && !content.embeds && !file && (content.stickerIDs === undefined || content.stickerIDs.length === 0)) {
return Promise.reject(new Error("No content, file, stickers, 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);
content.sticker_ids = content.stickerIDs;
if(content.messageReference) {
content.message_reference = content.messageReference;
if(content.messageReference.messageID !== undefined) {
Expand Down Expand Up @@ -2735,7 +2737,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
1 change: 1 addition & 0 deletions lib/structures/PrivateChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class PrivateChannel extends Channel {
* @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 {Array<String>} [content.stickerIDs] An array of ids corresponding to the stickers to send
DonovanDMC marked this conversation as resolved.
Show resolved Hide resolved
* @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
1 change: 1 addition & 0 deletions lib/structures/TextChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class TextChannel extends GuildChannel {
* @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 {Array<String>} [content.stickerIDs] An array of ids corresponding to the stickers to send
DonovanDMC marked this conversation as resolved.
Show resolved Hide resolved
* @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