Update message and textchannel
This commit is contained in:
parent
3695b81de6
commit
65eace4046
2 changed files with 30 additions and 13 deletions
|
@ -108,21 +108,37 @@ export class Message extends Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Edits this message. */
|
/** Edits this message. */
|
||||||
async edit(text?: string, option?: MessageOption): Promise<Message> {
|
async edit(
|
||||||
|
content?: string | AllMessageOptions,
|
||||||
|
option?: AllMessageOptions
|
||||||
|
): Promise<Message> {
|
||||||
|
if (typeof content === 'object') {
|
||||||
|
option = content
|
||||||
|
content = undefined
|
||||||
|
}
|
||||||
|
if (content === undefined && option === undefined) {
|
||||||
|
throw new Error('Either text or option is necessary.')
|
||||||
|
}
|
||||||
|
if (option instanceof Embed) {
|
||||||
|
option = {
|
||||||
|
embed: option
|
||||||
|
}
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
this.client.user !== undefined &&
|
this.client.user !== undefined &&
|
||||||
this.author.id !== this.client.user?.id
|
this.author.id !== this.client.user?.id
|
||||||
)
|
) {
|
||||||
throw new Error("Cannot edit other users' messages")
|
throw new Error("Cannot edit other users' messages")
|
||||||
return this.channel.editMessage(this.id, text, option)
|
}
|
||||||
|
return this.channel.editMessage(this.id, content, option)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates a Reply to this Message. */
|
/** Creates a Reply to this Message. */
|
||||||
async reply(
|
async reply(
|
||||||
text?: string | AllMessageOptions,
|
content?: string | AllMessageOptions,
|
||||||
option?: AllMessageOptions
|
option?: AllMessageOptions
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
return this.channel.send(text, option, this)
|
return this.channel.send(content, option, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Deletes the Message. */
|
/** Deletes the Message. */
|
||||||
|
|
|
@ -41,29 +41,30 @@ export class TextChannel extends Channel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param text Text content of the Message to send.
|
* @param content Text content of the Message to send.
|
||||||
* @param option Various other Message options.
|
* @param option Various other Message options.
|
||||||
* @param reply Reference to a Message object to reply-to.
|
* @param reply Reference to a Message object to reply-to.
|
||||||
*/
|
*/
|
||||||
async send(
|
async send(
|
||||||
text?: string | AllMessageOptions,
|
content?: string | AllMessageOptions,
|
||||||
option?: AllMessageOptions,
|
option?: AllMessageOptions,
|
||||||
reply?: Message
|
reply?: Message
|
||||||
): Promise<Message> {
|
): Promise<Message> {
|
||||||
if (typeof text === 'object') {
|
if (typeof content === 'object') {
|
||||||
option = text
|
option = content
|
||||||
text = undefined
|
content = undefined
|
||||||
}
|
}
|
||||||
if (text === undefined && option === undefined) {
|
if (content === undefined && option === undefined) {
|
||||||
throw new Error('Either text or option is necessary.')
|
throw new Error('Either text or option is necessary.')
|
||||||
}
|
}
|
||||||
if (option instanceof Embed)
|
if (option instanceof Embed) {
|
||||||
option = {
|
option = {
|
||||||
embed: option
|
embed: option
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const payload: any = {
|
const payload: any = {
|
||||||
content: text,
|
content: content,
|
||||||
embed: option?.embed,
|
embed: option?.embed,
|
||||||
file: option?.file,
|
file: option?.file,
|
||||||
tts: option?.tts,
|
tts: option?.tts,
|
||||||
|
|
Loading…
Reference in a new issue