Fix crash when a user sends an attachment
Also added an eslint rule to catch similar errors caused by shadowed variables in the future.cshd
parent
a69e9dd0a2
commit
883d8adf93
|
@ -20,6 +20,7 @@
|
|||
"!!": true
|
||||
}
|
||||
}],
|
||||
"quotes": ["error", "double"]
|
||||
"quotes": ["error", "double"],
|
||||
"no-shadow": "error"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -258,8 +258,8 @@ class Thread {
|
|||
let messageContent = msg.content || "";
|
||||
|
||||
// Prepare attachments
|
||||
const attachments = [];
|
||||
const smallAttachments = [];
|
||||
const attachmentLinks = [];
|
||||
const smallAttachmentLinks = [];
|
||||
const attachmentFiles = [];
|
||||
|
||||
for (const attachment of msg.attachments) {
|
||||
|
@ -269,10 +269,10 @@ class Thread {
|
|||
if (config.relaySmallAttachmentsAsAttachments && attachment.size <= config.smallAttachmentLimit) {
|
||||
const file = await attachments.attachmentToDiscordFileObject(attachment);
|
||||
attachmentFiles.push(file);
|
||||
smallAttachments.push(savedAttachment.url);
|
||||
smallAttachmentLinks.push(savedAttachment.url);
|
||||
}
|
||||
|
||||
attachments.push(savedAttachment.url);
|
||||
attachmentLinks.push(savedAttachment.url);
|
||||
}
|
||||
|
||||
// Handle special embeds (listening party invites etc.)
|
||||
|
@ -311,8 +311,8 @@ class Thread {
|
|||
is_anonymous: 0,
|
||||
dm_message_id: msg.id,
|
||||
dm_channel_id: msg.channel.id,
|
||||
attachments,
|
||||
small_attachments: smallAttachments,
|
||||
attachments: attachmentLinks,
|
||||
small_attachments: smallAttachmentLinks,
|
||||
});
|
||||
|
||||
threadMessage = await this._addThreadMessageToDB(threadMessage.getSQLProps());
|
||||
|
|
Loading…
Reference in New Issue