feat(types/message): add fail_if_not_exists to Reference interface (#642)

* support fail replies

* fmt

* fix linter issue

* fix condition
This commit is contained in:
Skillz4Killz
2021-03-08 08:41:31 -05:00
committed by GitHub
parent 53bd6c2386
commit 5be674e3e8
4 changed files with 29 additions and 6 deletions
+9 -2
View File
@@ -2,6 +2,7 @@ import {
Activity,
Application,
Attachment,
DiscordReferencePayload,
Embed,
GuildMember,
MessageContent,
@@ -85,11 +86,17 @@ const baseMessage: Partial<Message> = {
},
reply(content) {
const contentWithMention = typeof content === "string"
? { content, mentions: { repliedUser: true }, replyMessageID: this.id }
? {
content,
mentions: { repliedUser: true },
replyMessageID: this.id,
failReplyIfNotExists: false,
}
: {
...content,
mentions: { ...(content.mentions || {}), repliedUser: true },
replyMessageID: this.id,
failReplyIfNotExists: content.failReplyIfNotExists === true,
};
if (this.guildID) return sendMessage(this.channelID!, contentWithMention);
@@ -216,7 +223,7 @@ export interface Message {
/** Applications that sent with Rich Presence related chat embeds. */
applications?: Application;
/** The reference data sent with crossposted messages */
messageReference?: Reference;
messageReference?: DiscordReferencePayload;
/** The message flags combined like permission bits describe extra features of the message */
flags?: 1 | 2 | 4 | 8 | 16;
/** the stickers sent with the message (bots currently can only receive messages with stickers, not send) */