Add reactions
This commit is contained in:
parent
3695b81de6
commit
9e6d2c1047
2 changed files with 48 additions and 1 deletions
|
@ -17,6 +17,7 @@ import { TextChannel } from './textChannel.ts'
|
|||
import { Guild } from './guild.ts'
|
||||
import { MessageReactionsManager } from '../managers/messageReactions.ts'
|
||||
import { MessageSticker } from './messageSticker.ts'
|
||||
import { Emoji } from './emoji.ts'
|
||||
|
||||
type AllMessageOptions = MessageOption | Embed
|
||||
|
||||
|
@ -129,4 +130,12 @@ export class Message extends Base {
|
|||
async delete(): Promise<void> {
|
||||
return this.client.rest.delete(CHANNEL_MESSAGE(this.channelID, this.id))
|
||||
}
|
||||
|
||||
async addReaction(emoji: string | Emoji): Promise<void> {
|
||||
return this.channel.addReaction(this, emoji)
|
||||
}
|
||||
|
||||
async removeReaction(emoji: string | Emoji): Promise<void> {
|
||||
return this.channel.removeReaction(this, emoji)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,12 @@ import {
|
|||
import {
|
||||
CHANNEL,
|
||||
CHANNEL_MESSAGE,
|
||||
CHANNEL_MESSAGES
|
||||
CHANNEL_MESSAGES,
|
||||
MESSAGE_REACTION_ME
|
||||
} from '../types/endpoint.ts'
|
||||
import { Channel } from './channel.ts'
|
||||
import { Embed } from './embed.ts'
|
||||
import { Emoji } from './emoji.ts'
|
||||
import { Guild } from './guild.ts'
|
||||
import { Message } from './message.ts'
|
||||
|
||||
|
@ -124,6 +126,42 @@ export class TextChannel extends Channel {
|
|||
await res.mentions.fromPayload(newMsg)
|
||||
return res
|
||||
}
|
||||
|
||||
async addReaction(
|
||||
message: Message | string,
|
||||
emoji: Emoji | string
|
||||
): Promise<void> {
|
||||
if (emoji instanceof Emoji) {
|
||||
emoji = emoji.getEmojiString
|
||||
}
|
||||
if (message instanceof Message) {
|
||||
message = message.id
|
||||
}
|
||||
|
||||
const encodedEmoji = encodeURI(emoji)
|
||||
|
||||
await this.client.rest.put(
|
||||
MESSAGE_REACTION_ME(this.id, message, encodedEmoji)
|
||||
)
|
||||
}
|
||||
|
||||
async removeReaction(
|
||||
message: Message | string,
|
||||
emoji: Emoji | string
|
||||
): Promise<void> {
|
||||
if (emoji instanceof Emoji) {
|
||||
emoji = emoji.getEmojiString
|
||||
}
|
||||
if (message instanceof Message) {
|
||||
message = message.id
|
||||
}
|
||||
|
||||
const encodedEmoji = encodeURI(emoji)
|
||||
|
||||
await this.client.rest.delete(
|
||||
MESSAGE_REACTION_ME(this.id, message, encodedEmoji)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export class GuildTextChannel extends TextChannel {
|
||||
|
|
Loading…
Reference in a new issue