feat: Super Reaction
test: ❌
This commit is contained in:
parent
f4dbc57f42
commit
11167aed25
@ -36,6 +36,7 @@ class MessageReactionAdd extends Action {
|
|||||||
emoji: data.emoji,
|
emoji: data.emoji,
|
||||||
count: message.partial ? null : 0,
|
count: message.partial ? null : 0,
|
||||||
me: user.id === this.client.user.id,
|
me: user.id === this.client.user.id,
|
||||||
|
me_burst: user.id === this.client.user.id && data.me_burst,
|
||||||
});
|
});
|
||||||
if (!reaction) return false;
|
if (!reaction) return false;
|
||||||
reaction._add(user);
|
reaction._add(user);
|
||||||
|
@ -205,9 +205,10 @@ class MessageManager extends CachedManager {
|
|||||||
* Adds a reaction to a message, even if it's not cached.
|
* Adds a reaction to a message, even if it's not cached.
|
||||||
* @param {MessageResolvable} message The message to react to
|
* @param {MessageResolvable} message The message to react to
|
||||||
* @param {EmojiIdentifierResolvable} emoji The emoji to react with
|
* @param {EmojiIdentifierResolvable} emoji The emoji to react with
|
||||||
|
* @param {boolean} [burst=false] Super Reactions (Discord Nitro only)
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async react(message, emoji) {
|
async react(message, emoji, burst = false) {
|
||||||
message = this.resolveId(message);
|
message = this.resolveId(message);
|
||||||
if (!message) throw new TypeError('INVALID_TYPE', 'message', 'MessageResolvable');
|
if (!message) throw new TypeError('INVALID_TYPE', 'message', 'MessageResolvable');
|
||||||
|
|
||||||
@ -219,7 +220,15 @@ class MessageManager extends CachedManager {
|
|||||||
: encodeURIComponent(emoji.name);
|
: encodeURIComponent(emoji.name);
|
||||||
|
|
||||||
// eslint-disable-next-line newline-per-chained-call
|
// 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: {},
|
data: {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Super Reactions
|
||||||
|
* @returns {Promise<number>}
|
||||||
|
*/
|
||||||
|
fetchBurstCredit() {
|
||||||
|
return this.client.api.users['@me']['burst-credits'].get().then(d => d.amount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ClientUser;
|
module.exports = ClientUser;
|
||||||
|
@ -792,6 +792,7 @@ class Message extends Base {
|
|||||||
/**
|
/**
|
||||||
* Adds a reaction to the message.
|
* Adds a reaction to the message.
|
||||||
* @param {EmojiIdentifierResolvable} emoji The emoji to react with
|
* @param {EmojiIdentifierResolvable} emoji The emoji to react with
|
||||||
|
* @param {boolean} [burst=false] Super Reactions (Discord Nitro only)
|
||||||
* @returns {Promise<MessageReaction>}
|
* @returns {Promise<MessageReaction>}
|
||||||
* @example
|
* @example
|
||||||
* // React to a message with a unicode emoji
|
* // React to a message with a unicode emoji
|
||||||
@ -804,9 +805,9 @@ class Message extends Base {
|
|||||||
* .then(console.log)
|
* .then(console.log)
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
async react(emoji) {
|
async react(emoji, burst = false) {
|
||||||
if (!this.channel) throw new Error('CHANNEL_NOT_CACHED');
|
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(
|
return this.client.actions.MessageReactionAdd.handle(
|
||||||
{
|
{
|
||||||
@ -814,6 +815,7 @@ class Message extends Base {
|
|||||||
channel: this.channel,
|
channel: this.channel,
|
||||||
message: this,
|
message: this,
|
||||||
emoji: Util.resolvePartialEmoji(emoji),
|
emoji: Util.resolvePartialEmoji(emoji),
|
||||||
|
me_burst: burst,
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
).reaction;
|
).reaction;
|
||||||
|
@ -30,6 +30,12 @@ class MessageReaction {
|
|||||||
*/
|
*/
|
||||||
this.me = data.me;
|
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
|
* A manager of the users that have given this reaction
|
||||||
* @type {ReactionUserManager}
|
* @type {ReactionUserManager}
|
||||||
@ -49,6 +55,22 @@ class MessageReaction {
|
|||||||
*/
|
*/
|
||||||
this.count ??= data.count;
|
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 crosspost(): Promise<Message>;
|
||||||
public fetch(force?: boolean): Promise<Message>;
|
public fetch(force?: boolean): Promise<Message>;
|
||||||
public pin(reason?: string): 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 removeAttachments(): Promise<Message>;
|
||||||
public reply(options: string | MessagePayload | ReplyMessageOptions): Promise<Message>;
|
public reply(options: string | MessagePayload | ReplyMessageOptions): Promise<Message>;
|
||||||
public resolveComponent(customId: string): MessageActionRowComponent | null;
|
public resolveComponent(customId: string): MessageActionRowComponent | null;
|
||||||
@ -2407,8 +2407,11 @@ export class MessageReaction {
|
|||||||
|
|
||||||
public readonly client: Client;
|
public readonly client: Client;
|
||||||
public count: number;
|
public count: number;
|
||||||
|
public burstCount: number;
|
||||||
|
public burstColors: string[];
|
||||||
public readonly emoji: GuildEmoji | ReactionEmoji;
|
public readonly emoji: GuildEmoji | ReactionEmoji;
|
||||||
public me: boolean;
|
public me: boolean;
|
||||||
|
public meBurst: boolean;
|
||||||
public message: Message | PartialMessage;
|
public message: Message | PartialMessage;
|
||||||
public readonly partial: false;
|
public readonly partial: false;
|
||||||
public users: ReactionUserManager;
|
public users: ReactionUserManager;
|
||||||
@ -4235,7 +4238,7 @@ export class MessageManager extends CachedManager<Snowflake, Message, MessageRes
|
|||||||
cacheOptions?: BaseFetchOptions,
|
cacheOptions?: BaseFetchOptions,
|
||||||
): Promise<Collection<Snowflake, Message>>;
|
): Promise<Collection<Snowflake, Message>>;
|
||||||
public fetchPinned(cache?: boolean): 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 pin(message: MessageResolvable, reason?: string): Promise<void>;
|
||||||
public unpin(message: MessageResolvable, reason?: string): Promise<void>;
|
public unpin(message: MessageResolvable, reason?: string): Promise<void>;
|
||||||
public search(options: MessageSearchOptions): Promise<MessageSearchResult>;
|
public search(options: MessageSearchOptions): Promise<MessageSearchResult>;
|
||||||
|
Loading…
Reference in New Issue
Block a user