Support removing other user's reactions
This commit is contained in:
parent
eac5d52d83
commit
540f3b1877
2 changed files with 25 additions and 7 deletions
|
@ -135,7 +135,10 @@ export class Message extends Base {
|
||||||
return this.channel.addReaction(this, emoji)
|
return this.channel.addReaction(this, emoji)
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeReaction(emoji: string | Emoji): Promise<void> {
|
async removeReaction(
|
||||||
return this.channel.removeReaction(this, emoji)
|
emoji: string | Emoji,
|
||||||
|
user?: User | Member | string
|
||||||
|
): Promise<void> {
|
||||||
|
return this.channel.removeReaction(this, emoji, user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,16 @@ import {
|
||||||
CHANNEL,
|
CHANNEL,
|
||||||
CHANNEL_MESSAGE,
|
CHANNEL_MESSAGE,
|
||||||
CHANNEL_MESSAGES,
|
CHANNEL_MESSAGES,
|
||||||
MESSAGE_REACTION_ME
|
MESSAGE_REACTION_ME,
|
||||||
|
MESSAGE_REACTION_USER
|
||||||
} from '../types/endpoint.ts'
|
} from '../types/endpoint.ts'
|
||||||
import { Channel } from './channel.ts'
|
import { Channel } from './channel.ts'
|
||||||
import { Embed } from './embed.ts'
|
import { Embed } from './embed.ts'
|
||||||
import { Emoji } from './emoji.ts'
|
import { Emoji } from './emoji.ts'
|
||||||
import { Guild } from './guild.ts'
|
import { Guild } from './guild.ts'
|
||||||
|
import { Member } from './member.ts'
|
||||||
import { Message } from './message.ts'
|
import { Message } from './message.ts'
|
||||||
|
import { User } from './user.ts'
|
||||||
|
|
||||||
export type AllMessageOptions = MessageOption | Embed
|
export type AllMessageOptions = MessageOption | Embed
|
||||||
|
|
||||||
|
@ -147,7 +150,8 @@ export class TextChannel extends Channel {
|
||||||
|
|
||||||
async removeReaction(
|
async removeReaction(
|
||||||
message: Message | string,
|
message: Message | string,
|
||||||
emoji: Emoji | string
|
emoji: Emoji | string,
|
||||||
|
user?: User | Member | string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (emoji instanceof Emoji) {
|
if (emoji instanceof Emoji) {
|
||||||
emoji = emoji.getEmojiString
|
emoji = emoji.getEmojiString
|
||||||
|
@ -155,12 +159,23 @@ export class TextChannel extends Channel {
|
||||||
if (message instanceof Message) {
|
if (message instanceof Message) {
|
||||||
message = message.id
|
message = message.id
|
||||||
}
|
}
|
||||||
|
if (user !== undefined) {
|
||||||
|
if (typeof user !== 'string') {
|
||||||
|
user = user.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const encodedEmoji = encodeURI(emoji)
|
const encodedEmoji = encodeURI(emoji)
|
||||||
|
|
||||||
await this.client.rest.delete(
|
if (user === undefined) {
|
||||||
MESSAGE_REACTION_ME(this.id, message, encodedEmoji)
|
await this.client.rest.delete(
|
||||||
)
|
MESSAGE_REACTION_ME(this.id, message, encodedEmoji)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
await this.client.rest.delete(
|
||||||
|
MESSAGE_REACTION_USER(this.id, message, encodedEmoji, user)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue