diff --git a/src/client/actions/MessageReactionAdd.js b/src/client/actions/MessageReactionAdd.js index 736b1e4..5595233 100644 --- a/src/client/actions/MessageReactionAdd.js +++ b/src/client/actions/MessageReactionAdd.js @@ -36,6 +36,7 @@ class MessageReactionAdd extends Action { emoji: data.emoji, count: message.partial ? null : 0, me: user.id === this.client.user.id, + me_burst: user.id === this.client.user.id && data.me_burst, }); if (!reaction) return false; reaction._add(user); diff --git a/src/managers/MessageManager.js b/src/managers/MessageManager.js index ff73c10..36d0205 100644 --- a/src/managers/MessageManager.js +++ b/src/managers/MessageManager.js @@ -205,9 +205,10 @@ class MessageManager extends CachedManager { * Adds a reaction to a message, even if it's not cached. * @param {MessageResolvable} message The message to react to * @param {EmojiIdentifierResolvable} emoji The emoji to react with + * @param {boolean} [burst=false] Super Reactions (Discord Nitro only) * @returns {Promise} */ - async react(message, emoji) { + async react(message, emoji, burst = false) { message = this.resolveId(message); if (!message) throw new TypeError('INVALID_TYPE', 'message', 'MessageResolvable'); @@ -219,7 +220,15 @@ class MessageManager extends CachedManager { : encodeURIComponent(emoji.name); // eslint-disable-next-line newline-per-chained-call - await this.client.api.channels(this.channel.id).messages(message).reactions(emojiId, '@me').put(); + await this.client.api + .channels(this.channel.id) + .messages(message) + .reactions(emojiId, '@me') + .put({ + query: { + type: burst ? 1 : 0, + }, + }); } /** diff --git a/src/structures/ClientUser.js b/src/structures/ClientUser.js index a351610..1ab2fa2 100644 --- a/src/structures/ClientUser.js +++ b/src/structures/ClientUser.js @@ -573,6 +573,14 @@ class ClientUser extends User { data: {}, }); } + + /** + * Super Reactions + * @returns {Promise} + */ + fetchBurstCredit() { + return this.client.api.users['@me']['burst-credits'].get().then(d => d.amount); + } } module.exports = ClientUser; diff --git a/src/structures/Message.js b/src/structures/Message.js index 683d22d..5acd060 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -792,6 +792,7 @@ class Message extends Base { /** * Adds a reaction to the message. * @param {EmojiIdentifierResolvable} emoji The emoji to react with + * @param {boolean} [burst=false] Super Reactions (Discord Nitro only) * @returns {Promise} * @example * // React to a message with a unicode emoji @@ -804,9 +805,9 @@ class Message extends Base { * .then(console.log) * .catch(console.error); */ - async react(emoji) { + async react(emoji, burst = false) { if (!this.channel) throw new Error('CHANNEL_NOT_CACHED'); - await this.channel.messages.react(this.id, emoji); + await this.channel.messages.react(this.id, emoji, burst); return this.client.actions.MessageReactionAdd.handle( { @@ -814,6 +815,7 @@ class Message extends Base { channel: this.channel, message: this, emoji: Util.resolvePartialEmoji(emoji), + me_burst: burst, }, true, ).reaction; diff --git a/src/structures/MessageReaction.js b/src/structures/MessageReaction.js index 60e0189..803a5d5 100644 --- a/src/structures/MessageReaction.js +++ b/src/structures/MessageReaction.js @@ -30,6 +30,12 @@ class MessageReaction { */ this.me = data.me; + /** + * Whether the client has given this super reaction + * @type {boolean} + */ + this.meBurst = Boolean(data.me_burst); + /** * A manager of the users that have given this reaction * @type {ReactionUserManager} @@ -49,6 +55,22 @@ class MessageReaction { */ this.count ??= data.count; } + + if ('burst_count' in data) { + /** + * The number of people that have given the same super reaction + * @type {?number} + */ + this.burstCount ??= data.burst_count; + } + + if ('burst_colors' in data) { + /** + * Burst colors of the reaction + * @type {?string[]} + */ + this.burstColors ??= data.burst_colors; + } } /** diff --git a/typings/index.d.ts b/typings/index.d.ts index f373b03..5e965a2 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2116,7 +2116,7 @@ export class Message extends Base { public crosspost(): Promise; public fetch(force?: boolean): Promise; public pin(reason?: string): Promise; - public react(emoji: EmojiIdentifierResolvable): Promise; + public react(emoji: EmojiIdentifierResolvable, burst?: boolean): Promise; public removeAttachments(): Promise; public reply(options: string | MessagePayload | ReplyMessageOptions): Promise; public resolveComponent(customId: string): MessageActionRowComponent | null; @@ -2407,8 +2407,11 @@ export class MessageReaction { public readonly client: Client; public count: number; + public burstCount: number; + public burstColors: string[]; public readonly emoji: GuildEmoji | ReactionEmoji; public me: boolean; + public meBurst: boolean; public message: Message | PartialMessage; public readonly partial: false; public users: ReactionUserManager; @@ -4235,7 +4238,7 @@ export class MessageManager extends CachedManager>; public fetchPinned(cache?: boolean): Promise>; - public react(message: MessageResolvable, emoji: EmojiIdentifierResolvable): Promise; + public react(message: MessageResolvable, emoji: EmojiIdentifierResolvable, burst?: boolean): Promise; public pin(message: MessageResolvable, reason?: string): Promise; public unpin(message: MessageResolvable, reason?: string): Promise; public search(options: MessageSearchOptions): Promise;