Skip to content

Commit

Permalink
Sticker Sending (#1252)
Browse files Browse the repository at this point in the history
Co-Authored-By: Catboy <elijahchristopherjohnson@gmail.com>
Co-authored-by: bsian03 <chharry321@gmail.com>
  • Loading branch information
3 people committed Sep 2, 2021
1 parent e357991 commit daedb2b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 28 deletions.
33 changes: 17 additions & 16 deletions index.d.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -154,7 +141,7 @@ declare namespace Eris {
}
interface PartialChannel {
bitrate?: number;
id?: number;
id: string;
name?: string;
nsfw?: boolean;
parent_id?: number;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1009,7 +1010,7 @@ declare namespace Eris {
interface PartialRole {
color?: number;
hoist?: boolean;
id?: number;
id: string;
mentionable?: boolean;
name?: string;
permissions?: number;
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 2 additions & 12 deletions lib/Client.js
Expand Up @@ -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<String>} [content.stickerIDs] An array of IDs corresponding to stickers to send
* @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 @@ -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) {
Expand All @@ -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));
}
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -1549,9 +1545,6 @@ class Client extends EventEmitter {
* @returns {Promise<Message>}
*/
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);
}
Expand Down Expand Up @@ -1631,9 +1624,6 @@ class Client extends EventEmitter {
* @returns {Promise<Message?>}
*/
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,
Expand Down
1 change: 1 addition & 0 deletions lib/structures/PrivateChannel.js
Expand Up @@ -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<String>} [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
Expand Down
1 change: 1 addition & 0 deletions lib/structures/TextChannel.js
Expand Up @@ -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<String>} [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
Expand Down

0 comments on commit daedb2b

Please sign in to comment.