我一直在花费数小时来尝试获取此代码来记录已删除的图像,但是我尝试的所有操作都不过是失败,它记录了已删除的消息,但是它只是完全忽略了图像。
请有人指出正确的方向,以解决此问题。非常感谢您的帮助
const Discord = require('discord.js')
module.exports = async (client, message) => {
if (!message.guild) return;
if (!message.content) return;
const logs = message.guild.channels.find(c => c.name === '420-logs');
if (!logs) {
return console.log(`[WARN]: The Delete Logs channel does not exist in the server named '${message.guild.name}'`)
}
if (message.attachments.size > 0) { // If I change this to: message.attachments.size>0 && message it works with deleted image & text but as it is without this said line it doesn't function
var Attachment = (message.attachments).array();
Attachment.forEach(function(attachment) {
const logembed = new Discord.RichEmbed()
.setAuthor(message.author.tag, message.author.displayAvatarURL)
.setDescription(`**Image sent by ${message.author.tag} deleted in <#${message.channel.id}>**`)
.setImage(attachment.proxyURL)
.setColor(message.guild.member(client.user).displayHexColor)
.setFooter(`Deleted Image`)
.setTimestamp()
logs.send(logembed);
console.log(attachment.proxyURL);
})
} else {
const logembed = new Discord.RichEmbed()
//.setTitle('Message Deleted')
.setAuthor(message.author.tag, message.author.displayAvatarURL)
.setDescription(`**Message sent by ${message.author.tag} deleted in <#${message.channel.id}>**`)
.addField("Message Content", `${message.content}`)
.setColor(message.guild.member(client.user).displayHexColor)
.setFooter(`Deleted Message`)
.setTimestamp()
logs.send(logembed);
}
}