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
34 changes: 18 additions & 16 deletions index.d.ts
Original file line number Diff line number Diff line change
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,21 @@ declare namespace Eris {
command: Command;
timeout: NodeJS.Timer;
}

DonovanDMC marked this conversation as resolved.
Show resolved Hide resolved
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 +1011,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 +2366,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
14 changes: 2 additions & 12 deletions lib/Client.js
Original file line number Diff line number Diff line change
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
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 @@ -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
Original file line number Diff line number Diff line change
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
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 @@ -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
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