mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-19 04:38:17 +00:00
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:
@@ -244,6 +244,7 @@ export async function sendMessage(
|
||||
? {
|
||||
message_reference: {
|
||||
message_id: content.replyMessageID,
|
||||
fail_if_not_exists: content.failReplyIfNotExists === true,
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
|
||||
@@ -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) */
|
||||
|
||||
@@ -118,6 +118,8 @@ export interface MessageContent {
|
||||
"payload_json"?: string;
|
||||
/** If you want to send a reply message, provide the original message id here */
|
||||
replyMessageID?: string;
|
||||
/** When sending a reply to a message that was deleted, should Discord fail and throw an error. By default we make this false to prevent your bot from crashing. */
|
||||
failReplyIfNotExists?: boolean;
|
||||
}
|
||||
|
||||
export interface FileContent {
|
||||
|
||||
+17
-4
@@ -200,11 +200,23 @@ export interface Application {
|
||||
|
||||
export interface Reference {
|
||||
/** The id of the originating message */
|
||||
"message_id"?: string;
|
||||
// deno-lint-ignore camelcase
|
||||
message_id?: string;
|
||||
/** The id of the originating message's channel */
|
||||
"channel_id": string;
|
||||
// deno-lint-ignore camelcase
|
||||
channel_id?: string;
|
||||
/** The id of the originating message's guild */
|
||||
"guild_id"?: string;
|
||||
// deno-lint-ignore camelcase
|
||||
guild_id?: string;
|
||||
/** When sending, whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message, default false */
|
||||
// deno-lint-ignore camelcase
|
||||
fail_if_not_exists?: boolean;
|
||||
}
|
||||
|
||||
export interface DiscordReferencePayload extends Reference {
|
||||
/** The id of the originating message's channel */
|
||||
// deno-lint-ignore camelcase
|
||||
channel_id: string;
|
||||
}
|
||||
|
||||
export enum MessageFlags {
|
||||
@@ -287,7 +299,8 @@ export interface MessageCreateOptions {
|
||||
/** Applications that sent with Rich Presence related chat embeds. */
|
||||
applications?: Application;
|
||||
/** The reference data sent with crossposted messages */
|
||||
"message_reference"?: Reference;
|
||||
// deno-lint-ignore camelcase
|
||||
message_reference?: 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) */
|
||||
|
||||
Reference in New Issue
Block a user