diff --git a/src/structures/message.ts b/src/structures/message.ts index 39dff7150..e48f2ae01 100644 --- a/src/structures/message.ts +++ b/src/structures/message.ts @@ -131,8 +131,8 @@ export async function createDiscordenoMessage(data: DiscordMessage) { guildId = "", channelId, mentionChannels = [], - mentions, - mentionRoles, + mentions = [], + mentionRoles = [], editedTimestamp, ...rest } = snakeKeysToCamelCase(data); @@ -162,7 +162,7 @@ export async function createDiscordenoMessage(data: DiscordMessage) { // Keep any ids that discord sends ...mentionChannels.map((m) => m.id), // Add any other ids that can be validated in a channel mention format - ...(rest.content.match(CHANNEL_MENTION_REGEX) || []).map((text) => + ...(rest.content?.match(CHANNEL_MENTION_REGEX) || []).map((text) => // converts the <#123> into 123 text.substring(2, text.length - 1) ), diff --git a/src/types/messages/message.ts b/src/types/messages/message.ts index 04317a2d9..d38f6111d 100644 --- a/src/types/messages/message.ts +++ b/src/types/messages/message.ts @@ -30,7 +30,7 @@ export interface Message { */ member?: Partial; /** Contents of the message */ - content: string; + content?: string; /** When this message was sent */ timestamp: string; /** When this message was edited (or null if never) */ @@ -43,9 +43,9 @@ export interface Message { * Users specifically mentioned in the message * Note: The user objects in the mentions array will only have the partial member field present in `MESSAGE_CREATE` and `MESSAGE_UPDATE` events from text-based guild channels. */ - mentions: (User & { member?: Partial })[]; + mentions?: (User & { member?: Partial })[]; /** Roles specifically mentioned in this message */ - mentionRoles: string[]; + mentionRoles?: string[]; /** * Channels specifically mentioned in this message * Note: Not all channel mentions in a message will appear in `mention_channels`. Only textual channels that are visible to everyone in a lurkable guild will ever be included. Only crossposted messages (via Channel Following) currently include `mention_channels` at all. If no mentions in the message meet these requirements, this field will not be sent.