feat: Super Reaction
test: ❌
This commit is contained in:
parent
f4dbc57f42
commit
11167aed25
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
7
typings/index.d.ts
vendored
7
typings/index.d.ts
vendored
@ -2116,7 +2116,7 @@ export class Message<Cached extends boolean = boolean> extends Base {
|
||||
public crosspost(): Promise<Message>;
|
||||
public fetch(force?: boolean): Promise<Message>;
|
||||
public pin(reason?: string): Promise<Message>;
|
||||
public react(emoji: EmojiIdentifierResolvable): Promise<MessageReaction>;
|
||||
public react(emoji: EmojiIdentifierResolvable, burst?: boolean): Promise<MessageReaction>;
|
||||
public removeAttachments(): Promise<Message>;
|
||||
public reply(options: string | MessagePayload | ReplyMessageOptions): Promise<Message>;
|
||||
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<Snowflake, Message, MessageRes
|
||||
cacheOptions?: BaseFetchOptions,
|
||||
): Promise<Collection<Snowflake, Message>>;
|
||||
public fetchPinned(cache?: boolean): Promise<Collection<Snowflake, Message>>;
|
||||
public react(message: MessageResolvable, emoji: EmojiIdentifierResolvable): Promise<void>;
|
||||
public react(message: MessageResolvable, emoji: EmojiIdentifierResolvable, burst?: boolean): Promise<void>;
|
||||
public pin(message: MessageResolvable, reason?: string): Promise<void>;
|
||||
public unpin(message: MessageResolvable, reason?: string): Promise<void>;
|
||||
public search(options: MessageSearchOptions): Promise<MessageSearchResult>;
|
||||
|
Loading…
Reference in New Issue
Block a user