message content & mentions & mentionRoles can be undefined

This commit is contained in:
ITOH
2021-04-13 11:44:43 +02:00
parent 6a5307aaab
commit 851b280c87
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -131,8 +131,8 @@ export async function createDiscordenoMessage(data: DiscordMessage) {
guildId = "",
channelId,
mentionChannels = [],
mentions,
mentionRoles,
mentions = [],
mentionRoles = [],
editedTimestamp,
...rest
} = snakeKeysToCamelCase<Message>(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)
),
+3 -3
View File
@@ -30,7 +30,7 @@ export interface Message {
*/
member?: Partial<GuildMember>;
/** 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<GuildMember> })[];
mentions?: (User & { member?: Partial<GuildMember> })[];
/** 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.