From daedb2b416d0d3f880668ebed719477d9be59b2d Mon Sep 17 00:00:00 2001 From: Donovan Daniels Date: Thu, 2 Sep 2021 16:40:24 -0500 Subject: [PATCH] Sticker Sending (#1252) Co-Authored-By: Catboy Co-authored-by: bsian03 --- index.d.ts | 33 ++++++++++++++++---------------- lib/Client.js | 14 ++------------ lib/structures/PrivateChannel.js | 1 + lib/structures/TextChannel.js | 1 + 4 files changed, 21 insertions(+), 28 deletions(-) diff --git a/index.d.ts b/index.d.ts index aec24bb95..4bb8cc93f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -53,19 +53,6 @@ declare namespace Eris { type VerificationLevel = 0 | 1 | 2 | 3 | 4; // Message - type AdvancedMessageContent = { - allowedMentions?: AllowedMentions; - components?: ActionRow[]; - content?: string; - /** @deprecated */ - embed?: EmbedOptions; - embeds?: EmbedOptions[]; - flags?: number; - messageReference?: MessageReferenceReply; - /** @deprecated */ - messageReferenceID?: string; - tts?: boolean; - }; type ActionRowComponents = Button | SelectMenu; type Button = InteractionButton | URLButton; type Component = ActionRow | ActionRowComponents; @@ -154,7 +141,7 @@ declare namespace Eris { } interface PartialChannel { bitrate?: number; - id?: number; + id: string; name?: string; nsfw?: boolean; parent_id?: number; @@ -852,6 +839,20 @@ declare namespace Eris { command: Command; timeout: NodeJS.Timer; } + interface AdvancedMessageContent { + allowedMentions?: AllowedMentions; + components?: ActionRow[]; + content?: string; + /** @deprecated */ + embed?: EmbedOptions; + embeds?: EmbedOptions[]; + flags?: number; + messageReference?: MessageReferenceReply; + /** @deprecated */ + messageReferenceID?: string; + stickerIDs?: string[]; + tts?: boolean; + } interface AllowedMentions { everyone?: boolean; repliedUser?: boolean; @@ -1009,7 +1010,7 @@ declare namespace Eris { interface PartialRole { color?: number; hoist?: boolean; - id?: number; + id: string; mentionable?: boolean; name?: string; permissions?: number; @@ -2364,9 +2365,9 @@ declare namespace Eris { reactions: { [s: string]: { count: number; me: boolean } }; referencedMessage?: Message | null; roleMentions: string[]; + stickerItems?: StickerItems[]; /** @deprecated */ stickers?: Sticker[]; - stickerItems?: StickerItems[]; timestamp: number; tts: boolean; type: number; diff --git a/lib/Client.js b/lib/Client.js index 3ea505a2c..3b8593b25 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -607,6 +607,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} [content.stickerIDs] An array of IDs corresponding to stickers to send * @arg {Boolean} [content.tts] Set the message TTS flag * @arg {Object | Array} [file] A file object (or an Array of them) * @arg {Buffer} file.file A buffer containing file data @@ -621,13 +622,12 @@ 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.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) { @@ -650,8 +650,6 @@ class Client extends EventEmitter { this.emit("warn", "[DEPRECATED] content.messageReferenceID is deprecated. Use content.messageReference instead"); content.message_reference = {message_id: content.messageReferenceID}; } - } else if(!file) { - 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)); } @@ -1281,8 +1279,6 @@ 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 && !content.components && content.flags === undefined) { - return Promise.reject(new Error("No content, embeds, components or flags")); } else if(content.embed && !content.embeds) { this.emit("warn", "[DEPRECATED] content.embed is deprecated. Use content.embeds instead"); content.embeds = [content.embed]; @@ -1549,9 +1545,6 @@ class Client extends EventEmitter { * @returns {Promise} */ editWebhookMessage(webhookID, token, messageID, options) { - if(!options.content && !options.embeds && !options.components && !options.file) { - return Promise.reject(new Error("No content, embed, components, or file")); - } if(options.allowedMentions) { options.allowed_mentions = this._formatAllowedMentions(options.allowedMentions); } @@ -1631,9 +1624,6 @@ class Client extends EventEmitter { * @returns {Promise} */ executeWebhook(webhookID, token, options) { - if(!options.content && !options.file && !options.embeds) { - return Promise.reject(new Error("No content, file, or embeds")); - } return this.requestHandler.request("POST", Endpoints.WEBHOOK_TOKEN(webhookID, token) + (options.wait ? "?wait=true" : ""), !!options.auth, { content: options.content, embeds: options.embeds, diff --git a/lib/structures/PrivateChannel.js b/lib/structures/PrivateChannel.js index a48bf8ab5..54ff072f8 100644 --- a/lib/structures/PrivateChannel.js +++ b/lib/structures/PrivateChannel.js @@ -72,6 +72,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} [content.stickerIDs] An array of IDs corresponding to the stickers to send * @arg {Boolean} [content.tts] Set the message TTS flag * @arg {Object} [file] A file object * @arg {Buffer} file.file A buffer containing file data diff --git a/lib/structures/TextChannel.js b/lib/structures/TextChannel.js index 9c8fe7b86..88c5faf5e 100644 --- a/lib/structures/TextChannel.js +++ b/lib/structures/TextChannel.js @@ -93,6 +93,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} [content.stickerIDs] An array of IDs corresponding to the stickers to send * @arg {Boolean} [content.tts] Set the message TTS flag * @arg {Object} [file] A file object * @arg {Buffer} file.file A buffer containing file data