messageDelete.js
const Discord = require('discord.js')
module.exports = {
name: 'messageDelete',
async execute(client, message, messageDelete) {
if (message.channel.type === 'DM') return;
if (message.author == client) return;
if (!message.author) return;
if(message.embeds[0]) return;
if(message.attachments.size) return;
let Channel = client.channels.cache.get("CHANNEL-ID")
if (!Channel){
return;
} else if (Channel.type !== 'GUILD_TEXT') {
return;
} else if (!data.Mod.Logs.isEnabled){
return;
} else if(!Channel.guild.me.permissions.has("EMBED_LINKS", "VIEW_CHANNEL", "READ_MESSAGE_HISTORY", "VIEW_AUDIT_LOG", "SEND_MESSAGES")) {
return;
} else {
// Do nothing..
};
const timestamp = Math.floor(Date.now() / 1000)
const Msg = message.toString().substr(0, 500);
const DeletedLog = new Discord.MessageEmbed()
.setAuthor({ name: message.author.username, iconURL: message.author.displayAvatarURL({dynamic: true, size: 2048}) })
.setTitle(`<a:Down:853495989796470815> Deleted Message`)
.setDescription(`<a:iNFO:853495450111967253> **Member**: \`${message.author.tag}\` (${message.author.id})\n<:pp198:853494893439352842> **In**: ${message.channel}\n• **At**: <t:${timestamp}>\n\n<a:Right:877975111846731847> **Content**: \`\`\`\n${Msg || '❌ | Unkown message!'}\n\`\`\``)
.setColor('RED')
.setFooter({ text: message.guild.name, iconURL: message.guild.iconURL({dynamic: true}) })
.setTimestamp()
.setThumbnail(message.author.displayAvatarURL({dynamic: true}))
const botname = client.user.username;
const webhooks = await Channel.fetchWebhooks()
setTimeout(async function(){
let webhook = webhooks.filter((w)=>w.type === "Incoming" && w.token).first();
if(!webhook){
webhook = await Channel.createWebhook(botname, {avatar: client.user.displayAvatarURL({ format: 'png', dynamic: true, size: 128 })})
} else if(webhooks.size <= 10) {
}
webhook.send({embeds: [DeletedLog]})
.catch(() => {});
}, 5000);
// add more functions on ready event callback function...
return;
}
}
That's how my messageDelete event sends the embed How can i force the bot to wait for a certain time and if the messageDelete event excuted like 5 times at this time the bot sends all the 5 embed at the same message?