feat: Super Reaction
test: ❌
This commit is contained in:
@@ -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);
|
||||
|
@@ -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<void>}
|
||||
*/
|
||||
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,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -573,6 +573,14 @@ class ClientUser extends User {
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Super Reactions
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
fetchBurstCredit() {
|
||||
return this.client.api.users['@me']['burst-credits'].get().then(d => d.amount);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ClientUser;
|
||||
|
@@ -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<MessageReaction>}
|
||||
* @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;
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user