required changes

This commit is contained in:
DjDeveloperr 2021-03-19 16:48:11 +05:30
parent 711f78002e
commit 2286c9af3f
3 changed files with 40 additions and 21 deletions

View file

@ -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
? undefined
: typeof option.reply === 'string'
? {
message_id: option.reply
} }
: typeof option.reply === 'object'
if (reply !== undefined) { ? option.reply instanceof Message
const reference: MessageReference = { ? {
message_id: reply.id, message_id: option.reply.id,
channel_id: reply.channel.id, channel_id: option.reply.channel.id,
guild_id: reply.guild?.id guild_id: option.reply.guild?.id
} }
payload.message_reference = reference : 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(

View file

@ -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 })
)
} }
/** /**

View file

@ -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 {