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 {
|
||||
ChannelPayload,
|
||||
GuildChannelPayload,
|
||||
MessageOptions,
|
||||
MessageReference
|
||||
MessageOptions
|
||||
} from '../types/channel.ts'
|
||||
import { CHANNEL } from '../types/endpoint.ts'
|
||||
import getChannelByType from '../utils/getChannelByType.ts'
|
||||
|
@ -80,8 +79,7 @@ export class ChannelsManager extends BaseManager<ChannelPayload, Channel> {
|
|||
async sendMessage(
|
||||
channel: string | TextChannel,
|
||||
content?: string | AllMessageOptions,
|
||||
option?: AllMessageOptions,
|
||||
reply?: Message
|
||||
option?: AllMessageOptions
|
||||
): Promise<Message> {
|
||||
const channelID = typeof channel === 'string' ? channel : channel.id
|
||||
|
||||
|
@ -104,16 +102,23 @@ export class ChannelsManager extends BaseManager<ChannelPayload, Channel> {
|
|||
file: option?.file,
|
||||
files: option?.files,
|
||||
tts: option?.tts,
|
||||
allowed_mentions: option?.allowedMentions
|
||||
}
|
||||
|
||||
if (reply !== undefined) {
|
||||
const reference: MessageReference = {
|
||||
message_id: reply.id,
|
||||
channel_id: reply.channel.id,
|
||||
guild_id: reply.guild?.id
|
||||
}
|
||||
payload.message_reference = reference
|
||||
allowed_mentions: option?.allowedMentions,
|
||||
message_reference:
|
||||
option?.reply === undefined
|
||||
? undefined
|
||||
: typeof option.reply === 'string'
|
||||
? {
|
||||
message_id: option.reply
|
||||
}
|
||||
: typeof option.reply === 'object'
|
||||
? 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(
|
||||
|
|
|
@ -59,7 +59,11 @@ export class TextChannel extends Channel {
|
|||
option?: AllMessageOptions,
|
||||
reply?: 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 { MessageAttachment } from '../structures/message.ts'
|
||||
import type { Message, MessageAttachment } from '../structures/message.ts'
|
||||
import { EmojiPayload } from './emoji.ts'
|
||||
import { MemberPayload } from './guild.ts'
|
||||
import { UserPayload } from './user.ts'
|
||||
|
@ -156,16 +156,26 @@ export interface MessagePayload {
|
|||
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 {
|
||||
tts?: boolean
|
||||
embed?: Embed
|
||||
file?: MessageAttachment
|
||||
files?: MessageAttachment[]
|
||||
allowedMentions?: {
|
||||
parse?: 'everyone' | 'users' | 'roles'
|
||||
roles?: string[]
|
||||
users?: string[]
|
||||
}
|
||||
allowedMentions?: AllowedMentionsPayload
|
||||
reply?: Message | MessageReference | string
|
||||
}
|
||||
|
||||
export interface ChannelMention {
|
||||
|
|
Loading…
Reference in a new issue