This commit is contained in:
Yuzu 2022-07-01 14:47:51 -05:00
parent 5b98c593af
commit dba2de7305
3 changed files with 38 additions and 15 deletions

View File

@ -184,7 +184,7 @@ export class Message implements Model {
/**
* alias for Message.addReaction
* */
*/
get react() {
return this.addReaction;
}
@ -213,13 +213,13 @@ export class Message implements Model {
r,
options.userId,
)
: Routes.CHANNEL_MESSAGE_REACTION_ME(this.channelId, this.id, r)
: Routes.CHANNEL_MESSAGE_REACTION_ME(this.channelId, this.id, r),
);
}
/**
* Get users who reacted with this emoji
* */
*/
async fetchReactions(reaction: ReactionResolvable, options?: GetReactions): Promise<User[]> {
const r = typeof reaction === "string" ? reaction : `${reaction.name}:${reaction.id}`;
@ -238,7 +238,7 @@ export class Message implements Model {
await this.session.rest.runMethod<undefined>(
this.session.rest,
"DELETE",
Routes.CHANNEL_MESSAGE_REACTION(this.channelId, this.id, r)
Routes.CHANNEL_MESSAGE_REACTION(this.channelId, this.id, r),
);
}
@ -246,7 +246,7 @@ export class Message implements Model {
await this.session.rest.runMethod<undefined>(
this.session.rest,
"DELETE",
Routes.CHANNEL_MESSAGE_REACTIONS(this.channelId, this.id)
Routes.CHANNEL_MESSAGE_REACTIONS(this.channelId, this.id),
);
}

View File

@ -117,15 +117,25 @@ export class TextChannel extends GuildChannel {
}
async addReaction(messageId: Snowflake, reaction: ReactionResolvable) {
await Message.prototype.addReaction.call({ channelId: this.id, id: messageId, session: this.session }, reaction);
await Message.prototype.addReaction.call(
{ channelId: this.id, id: messageId, session: this.session },
reaction,
);
}
async removeReaction(messageId: Snowflake, reaction: ReactionResolvable, options?: { userId: Snowflake }) {
await Message.prototype.removeReaction.call({ channelId: this.id, id: messageId, session: this.session }, reaction, options);
await Message.prototype.removeReaction.call(
{ channelId: this.id, id: messageId, session: this.session },
reaction,
options,
);
}
async removeReactionEmoji(messageId: Snowflake, reaction: ReactionResolvable) {
await Message.prototype.removeReactionEmoji.call({ channelId: this.id, id: messageId, session: this.session }, reaction);
await Message.prototype.removeReactionEmoji.call(
{ channelId: this.id, id: messageId, session: this.session },
reaction,
);
}
async nukeReactions(messageId: Snowflake) {
@ -133,7 +143,11 @@ export class TextChannel extends GuildChannel {
}
async fetchReactions(messageId: Snowflake, reaction: ReactionResolvable, options?: GetReactions) {
const users = await Message.prototype.fetchReactions.call({ channelId: this.id, id: messageId, session: this.session }, reaction, options);
const users = await Message.prototype.fetchReactions.call(
{ channelId: this.id, id: messageId, session: this.session },
reaction,
options,
);
return users;
}

View File

@ -178,12 +178,16 @@ export function CHANNEL_PINS(channelId: Snowflake) {
return `/channels/${channelId}/pins`;
}
export function CHANNEL_MESSAGE_REACTION_ME(channelId: Snowflake, messageId: Snowflake, emoji: string) {
return `/channels/${channelId}/messages/${messageId}/reactions/${encodeURIComponent(emoji)}/@me`;
}
export function CHANNEL_MESSAGE_REACTION_USER(channelId: Snowflake, messageId: Snowflake, emoji: string, userId: Snowflake) {
export function CHANNEL_MESSAGE_REACTION_USER(
channelId: Snowflake,
messageId: Snowflake,
emoji: string,
userId: Snowflake,
) {
return `/channels/${channelId}/messages/${messageId}/reactions/${encodeURIComponent(emoji)}/${userId}`;
}
@ -193,13 +197,18 @@ export function CHANNEL_MESSAGE_REACTIONS(channelId: Snowflake, messageId: Snowf
/**
* @link https://discord.com/developers/docs/resources/channel#get-reactions-query-string-params
* */
*/
export interface GetReactions {
after?: string;
limit?: number;
after?: string;
limit?: number;
}
export function CHANNEL_MESSAGE_REACTION(channelId: Snowflake, messageId: Snowflake, emoji: string, options?: GetReactions) {
export function CHANNEL_MESSAGE_REACTION(
channelId: Snowflake,
messageId: Snowflake,
emoji: string,
options?: GetReactions,
) {
let url = `/channels/${channelId}/messages/${messageId}/reactions/${encodeURIComponent(emoji)}?`;
if (options?.after) url += `after=${options.after}`;