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 { Guild } from './guild.ts' | ||||||
| import { MessageReactionsManager } from '../managers/messageReactions.ts' | import { MessageReactionsManager } from '../managers/messageReactions.ts' | ||||||
| import { MessageSticker } from './messageSticker.ts' | import { MessageSticker } from './messageSticker.ts' | ||||||
|  | import { Emoji } from './emoji.ts' | ||||||
| 
 | 
 | ||||||
| type AllMessageOptions = MessageOption | Embed | type AllMessageOptions = MessageOption | Embed | ||||||
| 
 | 
 | ||||||
|  | @ -129,4 +130,12 @@ export class Message extends Base { | ||||||
|   async delete(): Promise<void> { |   async delete(): Promise<void> { | ||||||
|     return this.client.rest.delete(CHANNEL_MESSAGE(this.channelID, this.id)) |     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 { | import { | ||||||
|   CHANNEL, |   CHANNEL, | ||||||
|   CHANNEL_MESSAGE, |   CHANNEL_MESSAGE, | ||||||
|   CHANNEL_MESSAGES |   CHANNEL_MESSAGES, | ||||||
|  |   MESSAGE_REACTION_ME | ||||||
| } 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 { Guild } from './guild.ts' | import { Guild } from './guild.ts' | ||||||
| import { Message } from './message.ts' | import { Message } from './message.ts' | ||||||
| 
 | 
 | ||||||
|  | @ -124,6 +126,42 @@ export class TextChannel extends Channel { | ||||||
|     await res.mentions.fromPayload(newMsg) |     await res.mentions.fromPayload(newMsg) | ||||||
|     return res |     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 { | export class GuildTextChannel extends TextChannel { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue