required changes
This commit is contained in:
		
							parent
							
								
									711f78002e
								
							
						
					
					
						commit
						2286c9af3f
					
				
					 3 changed files with 40 additions and 21 deletions
				
			
		|  | @ -6,8 +6,7 @@ import { TextChannel } from '../structures/textChannel.ts' | ||||||
| import { | import { | ||||||
|   ChannelPayload, |   ChannelPayload, | ||||||
|   GuildChannelPayload, |   GuildChannelPayload, | ||||||
|   MessageOptions, |   MessageOptions | ||||||
|   MessageReference |  | ||||||
| } from '../types/channel.ts' | } from '../types/channel.ts' | ||||||
| import { CHANNEL } from '../types/endpoint.ts' | import { CHANNEL } from '../types/endpoint.ts' | ||||||
| import getChannelByType from '../utils/getChannelByType.ts' | import getChannelByType from '../utils/getChannelByType.ts' | ||||||
|  | @ -80,8 +79,7 @@ export class ChannelsManager extends BaseManager<ChannelPayload, Channel> { | ||||||
|   async sendMessage( |   async sendMessage( | ||||||
|     channel: string | TextChannel, |     channel: string | TextChannel, | ||||||
|     content?: string | AllMessageOptions, |     content?: string | AllMessageOptions, | ||||||
|     option?: AllMessageOptions, |     option?: AllMessageOptions | ||||||
|     reply?: Message |  | ||||||
|   ): Promise<Message> { |   ): Promise<Message> { | ||||||
|     const channelID = typeof channel === 'string' ? channel : channel.id |     const channelID = typeof channel === 'string' ? channel : channel.id | ||||||
| 
 | 
 | ||||||
|  | @ -104,16 +102,23 @@ export class ChannelsManager extends BaseManager<ChannelPayload, Channel> { | ||||||
|       file: option?.file, |       file: option?.file, | ||||||
|       files: option?.files, |       files: option?.files, | ||||||
|       tts: option?.tts, |       tts: option?.tts, | ||||||
|       allowed_mentions: option?.allowedMentions |       allowed_mentions: option?.allowedMentions, | ||||||
|     } |       message_reference: | ||||||
| 
 |         option?.reply === undefined | ||||||
|     if (reply !== undefined) { |           ? undefined | ||||||
|       const reference: MessageReference = { |           : typeof option.reply === 'string' | ||||||
|         message_id: reply.id, |           ? { | ||||||
|         channel_id: reply.channel.id, |               message_id: option.reply | ||||||
|         guild_id: reply.guild?.id |             } | ||||||
|       } |           : typeof option.reply === 'object' | ||||||
|       payload.message_reference = reference |           ? option.reply instanceof Message | ||||||
|  |             ? { | ||||||
|  |                 message_id: option.reply.id, | ||||||
|  |                 channel_id: option.reply.channel.id, | ||||||
|  |                 guild_id: option.reply.guild?.id | ||||||
|  |               } | ||||||
|  |             : option.reply | ||||||
|  |           : undefined | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const resp = await this.client.rest.api.channels[channelID].messages.post( |     const resp = await this.client.rest.api.channels[channelID].messages.post( | ||||||
|  |  | ||||||
|  | @ -59,7 +59,11 @@ export class TextChannel extends Channel { | ||||||
|     option?: AllMessageOptions, |     option?: AllMessageOptions, | ||||||
|     reply?: Message |     reply?: Message | ||||||
|   ): Promise<Message> { |   ): Promise<Message> { | ||||||
|     return this.client.channels.sendMessage(this, content, option, reply) |     return this.client.channels.sendMessage( | ||||||
|  |       this, | ||||||
|  |       content, | ||||||
|  |       Object.assign(option ?? {}, { reply }) | ||||||
|  |     ) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /** |   /** | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| import { Embed } from '../structures/embed.ts' | import { Embed } from '../structures/embed.ts' | ||||||
| import { MessageAttachment } from '../structures/message.ts' | import type { Message, MessageAttachment } from '../structures/message.ts' | ||||||
| import { EmojiPayload } from './emoji.ts' | import { EmojiPayload } from './emoji.ts' | ||||||
| import { MemberPayload } from './guild.ts' | import { MemberPayload } from './guild.ts' | ||||||
| import { UserPayload } from './user.ts' | import { UserPayload } from './user.ts' | ||||||
|  | @ -156,16 +156,26 @@ export interface MessagePayload { | ||||||
|   stickers?: MessageStickerPayload[] |   stickers?: MessageStickerPayload[] | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | export enum AllowedMentionType { | ||||||
|  |   Roles = 'roles', | ||||||
|  |   Users = 'users', | ||||||
|  |   Everyone = 'everyone' | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface AllowedMentionsPayload { | ||||||
|  |   parse?: AllowedMentionType[] | ||||||
|  |   users?: string[] | ||||||
|  |   roles?: string[] | ||||||
|  |   replied_user?: boolean | ||||||
|  | } | ||||||
|  | 
 | ||||||
| export interface MessageOptions { | export interface MessageOptions { | ||||||
|   tts?: boolean |   tts?: boolean | ||||||
|   embed?: Embed |   embed?: Embed | ||||||
|   file?: MessageAttachment |   file?: MessageAttachment | ||||||
|   files?: MessageAttachment[] |   files?: MessageAttachment[] | ||||||
|   allowedMentions?: { |   allowedMentions?: AllowedMentionsPayload | ||||||
|     parse?: 'everyone' | 'users' | 'roles' |   reply?: Message | MessageReference | string | ||||||
|     roles?: string[] |  | ||||||
|     users?: string[] |  | ||||||
|   } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface ChannelMention { | export interface ChannelMention { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue