@gilbert
To make a deleted message logger in discord.js, you can start by creating a new Discord client and adding an event listener for the messageDelete
event. Here's an example code snippet to get you started:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
const Discord = require('discord.js'); const client = new Discord.Client(); client.on('messageDelete', async message => { // Log deleted message const logChannel = message.guild.channels.cache.find(channel => channel.name === 'deleted-logs'); if (!logChannel) return; // If log channel not found, return const logEmbed = new Discord.MessageEmbed() .setTitle('Message Deleted') .setColor('#FF0000') .addField('Author', message.author.tag) .addField('Channel', message.channel.name) .addField('Content', message.content) .setTimestamp(); logChannel.send(logEmbed); }); client.login('YOUR_DISCORD_BOT_TOKEN'); |
In this code snippet, we are logging deleted messages to a channel named "deleted-logs" in the server. You can modify the code to suit your needs, such as adding additional information to the log message or logging it to a different channel.
Make sure to replace 'YOUR_DISCORD_BOT_TOKEN'
with your actual bot token. You can obtain a bot token by creating a new bot application on the Discord Developer Portal.
Once you have set up the code and run your bot, it will start logging deleted messages in the specified channel.