diff --git a/src/structure/components/observers/GuildLogging.js b/src/structure/components/observers/GuildLogging.js index 5631f0f..0e55902 100644 --- a/src/structure/components/observers/GuildLogging.js +++ b/src/structure/components/observers/GuildLogging.js @@ -192,13 +192,22 @@ class GuildLogger extends Observer { if (reference && reference.channelId === channel.id) { const referenced = await channel.messages.fetch(reference.messageId).catch(() => null); - if(referenced) embed.fields.push({ - name: wrapper.format('MSGLOG_REPLY', { tag: referenced.author.tag, id: referenced.author.id }), - value: wrapper.format('MSGLOG_REPLY_VALUE', { - content: referenced.content.length > 900 ? referenced.content.substring(0, 900) + '...' : referenced.content, - link: referenced.url - }) - }); + if (referenced) { + // eslint-disable-next-line no-nested-ternary + const content = referenced.content ? + referenced.content.length > 900 ? + referenced.content.substring(0, 900) + '...' : + referenced.content : + wrapper.format('MSGLOG_REPLY_NOCONTENT'); + + embed.fields.push({ + name: wrapper.format('MSGLOG_REPLY', { tag: referenced.author.tag, id: referenced.author.id }), + value: wrapper.format('MSGLOG_REPLY_VALUE', { + content, + link: referenced.url + }) + }); + } } if (message.filtered) { @@ -586,21 +595,24 @@ class GuildLogger extends Observer { }); if (reference && reference.channelId === channel.id) { - const referenced = await channel.messages.fetch(reference.messageId); - // eslint-disable-next-line no-nested-ternary - const content = referenced.content ? - referenced.content.length > 900 ? - referenced.content.substring(0, 900) + '...' : - referenced.content : - wrapper.format('MSGLOG_REPLY_NOCONTENT'); + const referenced = await channel.messages.fetch(reference.messageId).catch(() => null); - embed.fields.push({ - name: wrapper.format('MSGLOG_REPLY', { tag: referenced.author.tag, id: referenced.author.id }), - value: wrapper.format('MSGLOG_REPLY_VALUE', { - content, - link: referenced.url - }) - }); + if (referenced) { + // eslint-disable-next-line no-nested-ternary + const content = referenced.content ? + referenced.content.length > 900 ? + referenced.content.substring(0, 900) + '...' : + referenced.content : + wrapper.format('MSGLOG_REPLY_NOCONTENT'); + + embed.fields.push({ + name: wrapper.format('MSGLOG_REPLY', { tag: referenced.author.tag, id: referenced.author.id }), + value: wrapper.format('MSGLOG_REPLY_VALUE', { + content, + link: referenced.url + }) + }); + } } //if(oldMessage.content.length > 1024) embed.description += '\n' + oldMessage.format('MSGLOG_EDIT_OLD_CUTOFF');