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
|
"!!": true
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
"quotes": ["error", "double"]
|
"quotes": ["error", "double"],
|
||||||
|
"no-shadow": "error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,8 +258,8 @@ class Thread {
|
||||||
let messageContent = msg.content || "";
|
let messageContent = msg.content || "";
|
||||||
|
|
||||||
// Prepare attachments
|
// Prepare attachments
|
||||||
const attachments = [];
|
const attachmentLinks = [];
|
||||||
const smallAttachments = [];
|
const smallAttachmentLinks = [];
|
||||||
const attachmentFiles = [];
|
const attachmentFiles = [];
|
||||||
|
|
||||||
for (const attachment of msg.attachments) {
|
for (const attachment of msg.attachments) {
|
||||||
|
@ -269,10 +269,10 @@ class Thread {
|
||||||
if (config.relaySmallAttachmentsAsAttachments && attachment.size <= config.smallAttachmentLimit) {
|
if (config.relaySmallAttachmentsAsAttachments && attachment.size <= config.smallAttachmentLimit) {
|
||||||
const file = await attachments.attachmentToDiscordFileObject(attachment);
|
const file = await attachments.attachmentToDiscordFileObject(attachment);
|
||||||
attachmentFiles.push(file);
|
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.)
|
// Handle special embeds (listening party invites etc.)
|
||||||
|
@ -311,8 +311,8 @@ class Thread {
|
||||||
is_anonymous: 0,
|
is_anonymous: 0,
|
||||||
dm_message_id: msg.id,
|
dm_message_id: msg.id,
|
||||||
dm_channel_id: msg.channel.id,
|
dm_channel_id: msg.channel.id,
|
||||||
attachments,
|
attachments: attachmentLinks,
|
||||||
small_attachments: smallAttachments,
|
small_attachments: smallAttachmentLinks,
|
||||||
});
|
});
|
||||||
|
|
||||||
threadMessage = await this._addThreadMessageToDB(threadMessage.getSQLProps());
|
threadMessage = await this._addThreadMessageToDB(threadMessage.getSQLProps());
|
||||||
|
|
Loading…
Reference in New Issue