server: fix image content logging

This commit is contained in:
liushuyu 2021-07-07 00:12:52 -06:00
parent 3d02b9a871
commit e3ae371c57
No known key found for this signature in database
GPG Key ID: 23D1CE4534419437
1 changed files with 5 additions and 5 deletions

View File

@ -81,13 +81,13 @@ client.on('guildMemberAdd', (member) => {
client.on('messageDelete', message => { client.on('messageDelete', message => {
let parent = (message.channel as discord.TextChannel).parent; let parent = (message.channel as discord.TextChannel).parent;
if (parent && IsIgnoredCategory(parent.name) === false) { if (parent && IsIgnoredCategory(parent.name) === false) {
if (message.content && message.content.startsWith('.') === false && message.author?.bot === false) { if (((message.content && message.content.startsWith('.') === false) || (message.attachments.array().length > 0)) && message.author?.bot === false) {
let messageAttachment = message.attachments.size > 0 ? message.attachments.array()[0].url : null let messageAttachment = message.attachments.array()[0]?.proxyURL
const deletionEmbed = new discord.MessageEmbed() const deletionEmbed = new discord.MessageEmbed()
.setAuthor(message.author?.tag, message.author?.displayAvatarURL()) .setAuthor(message.author?.tag, message.author?.displayAvatarURL())
.setDescription(`Message deleted in ${message.channel.toString()}`) .setDescription(`Message deleted in ${message.channel.toString()}`)
.addField('Content', message.cleanContent, false) .addField('Content', message.cleanContent || '<no content>', false)
.setTimestamp() .setTimestamp()
.setColor('RED'); .setColor('RED');
@ -111,10 +111,10 @@ client.on('messageUpdate', (oldMessage, newMessage) => {
if (!findArray(authorRoles, AllowedRoles)) { if (!findArray(authorRoles, AllowedRoles)) {
let parent = (oldMessage.channel as discord.TextChannel).parent; let parent = (oldMessage.channel as discord.TextChannel).parent;
if (parent && IsIgnoredCategory(parent.name) === false) { if (parent && IsIgnoredCategory(parent.name) === false) {
const oldM = oldMessage.cleanContent; const oldM = oldMessage.cleanContent || '<no content>';
const newM = newMessage.cleanContent; const newM = newMessage.cleanContent;
if (oldMessage.content !== newMessage.content && oldM && newM) { if (oldMessage.content !== newMessage.content && oldM && newM) {
let messageAttachment = oldMessage.attachments.size > 0 ? oldMessage.attachments.array()[0].url : null let messageAttachment = oldMessage.attachments.array()[0]?.proxyURL
const editedEmbed = new discord.MessageEmbed() const editedEmbed = new discord.MessageEmbed()
.setAuthor(oldMessage.author?.tag, oldMessage.author?.displayAvatarURL()) .setAuthor(oldMessage.author?.tag, oldMessage.author?.displayAvatarURL())