Advertisement
spiralvibes

Made By ZayDocs | Maverick Team

Oct 14th, 2024
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { EmbedBuilder } = require("discord.js");
  2.  
  3. function handleLogs(client) {
  4.   const logSchema = require(`${process.cwd()}/src/database/LogChannel.js`);
  5.  
  6.   // Function to send log to the specified log channel
  7.   function send_log(guildId, embed) {
  8.     logSchema.findOne({ Guild: guildId }, async (err, data) => {
  9.       if (!data || !data.Channel) return;
  10.       const LogChannel = client.channels.cache.get(data.Channel);
  11.  
  12.       if (!LogChannel) return;
  13.       embed.setTimestamp();
  14.  
  15.       try {
  16.         LogChannel.send({ embeds: [embed] });
  17.       } catch (err) {
  18.         console.log("Error sending log!");
  19.       }
  20.     });
  21.   }
  22.  
  23.   // Log Message Deleted
  24.   client.on("messageDelete", function (message) {
  25.     if (!message.guild || message.author.bot) return;
  26.  
  27.     const embed = new EmbedBuilder()
  28.       .setTitle("> 🚮 **Message Deleted**")
  29.       .setColor("#4169e1")
  30.       .setDescription(`🗑️ A message was deleted in <#${message.channel.id}>.`)
  31.       .addFields(
  32.         { name: `• 🧑‍💻 Author`, value: `<@${message.author.id}> - *${message.author.tag}*`, inline: true },
  33.         { name: `• 📢 Channel`, value: `#${message.channel.name}`, inline: true },
  34.         { name: `• ❌ Deleted Message`, value: `${message.content || "*No content*"}`, inline: false }
  35.       )
  36.       .setThumbnail("https://i.imgur.com/mq2Gse6.png")
  37.       .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
  38.       .setFooter({ text: "🚮 Message Deleted | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
  39.  
  40.     send_log(message.guild.id, embed);
  41.   });
  42.  
  43.   // Log Message Edited
  44.   client.on("messageUpdate", function (oldMessage, newMessage) {
  45.     if (!oldMessage.guild || oldMessage.author.bot) return;
  46.  
  47.     const embed = new EmbedBuilder()
  48.       .setTitle("> ✍️ **Message Edited**")
  49.       .setColor("#4169e1")
  50.       .setDescription(`✏️ A message was edited in <#${oldMessage.channel.id}>.`)
  51.       .addFields(
  52.         { name: `• 🧑‍💻 Author`, value: `<@${oldMessage.author.id}> - *${oldMessage.author.tag}*`, inline: true },
  53.         { name: `• 📢 Channel`, value: `#${oldMessage.channel.name}`, inline: true },
  54.         { name: `• 📝 Old Message`, value: `${oldMessage.content || "*No content*"}`, inline: false },
  55.         { name: `• ✨ New Message`, value: `${newMessage.content || "*No content*"}`, inline: false }
  56.       )
  57.       .setThumbnail("https://i.imgur.com/mq2Gse6.png")
  58.       .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
  59.       .setFooter({ text: "✍️ Message Edited | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
  60.  
  61.     send_log(oldMessage.guild.id, embed);
  62.   });
  63.  
  64.   // Log Profile Picture Change
  65.   client.on("guildMemberUpdate", (oldMember, newMember) => {
  66.     if (oldMember.displayAvatarURL() !== newMember.displayAvatarURL()) {
  67.       const embed = new EmbedBuilder()
  68.         .setTitle("> 🖼️ **Profile Picture Updated**")
  69.         .setColor("#4169e1")
  70.         .setDescription(`🖼️ ${newMember.user.tag} has updated their profile picture.`)
  71.         .setThumbnail(newMember.displayAvatarURL({ dynamic: true, size: 1024 }))
  72.         .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
  73.         .setFooter({ text: "🖼️ Profile Picture Updated | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
  74.  
  75.       send_log(newMember.guild.id, embed);
  76.     }
  77.   });
  78.  
  79.   // Log Voice Channel Join
  80.   client.on("voiceStateUpdate", (oldState, newState) => {
  81.     if (oldState.channelId === null && newState.channelId !== null) {
  82.       const embed = new EmbedBuilder()
  83.         .setTitle("> 🎤 **User Joined Voice Channel**")
  84.         .setColor("#4169e1")
  85.         .setDescription(`🎙️ ${newState.member.user.tag} joined the voice channel **${newState.channel.name}**.`)
  86.         .setThumbnail(newState.member.user.displayAvatarURL({ dynamic: true }))
  87.         .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
  88.         .setFooter({ text: "🎤 Voice Channel Joined | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
  89.  
  90.       send_log(newState.guild.id, embed);
  91.     }
  92.   });
  93.  
  94.   // Log Voice Channel Leave
  95.   client.on("voiceStateUpdate", (oldState, newState) => {
  96.     if (oldState.channelId !== null && newState.channelId === null) {
  97.       const embed = new EmbedBuilder()
  98.         .setTitle("> 🔇 **User Left Voice Channel**")
  99.         .setColor("#4169e1")
  100.         .setDescription(`🔇 ${oldState.member.user.tag} left the voice channel **${oldState.channel.name}**.`)
  101.         .setThumbnail(oldState.member.user.displayAvatarURL({ dynamic: true }))
  102.         .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
  103.         .setFooter({ text: "🔇 Voice Channel Left | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
  104.  
  105.       send_log(oldState.guild.id, embed);
  106.     }
  107.   });
  108.  
  109.   // Log User Banned
  110.   client.on("guildBanAdd", async (ban) => {
  111.     const embed = new EmbedBuilder()
  112.       .setTitle("> 🚨 **User Banned**")
  113.       .setColor("#4169e1")
  114.       .setDescription(`❌ ${ban.user.tag} has been banned from the server.`)
  115.       .setThumbnail(ban.user.displayAvatarURL({ dynamic: true }))
  116.       .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
  117.       .setFooter({ text: "🚨 User Banned | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
  118.  
  119.     send_log(ban.guild.id, embed);
  120.   });
  121.  
  122.   // Log User Unbanned
  123.   client.on("guildBanRemove", async (ban) => {
  124.     const embed = new EmbedBuilder()
  125.       .setTitle("> 🛡️ **User Unbanned**")
  126.       .setColor("#4169e1")
  127.       .setDescription(`✅ ${ban.user.tag} has been unbanned from the server.`)
  128.       .setThumbnail(ban.user.displayAvatarURL({ dynamic: true }))
  129.       .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
  130.       .setFooter({ text: "🛡️ User Unbanned | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
  131.  
  132.     send_log(ban.guild.id, embed);
  133.   });
  134.  
  135.   // Log Role Create
  136.   client.on("roleCreate", (role) => {
  137.     const embed = new EmbedBuilder()
  138.       .setTitle("> 🛠️ **New Role Created**")
  139.       .setColor("#4169e1")
  140.       .setDescription(`🆕 A new role **${role.name}** was created.`)
  141.       .addFields({ name: `• Role Color`, value: `${role.hexColor}`, inline: true })
  142.       .setThumbnail("https://i.imgur.com/mq2Gse6.png")
  143.       .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
  144.       .setFooter({ text: "🛠️ Role Created | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
  145.  
  146.     send_log(role.guild.id, embed);
  147.   });
  148.  
  149.   // Log Role Delete
  150.   client.on("roleDelete", (role) => {
  151.     const embed = new EmbedBuilder()
  152.       .setTitle("> ❌ **Role Deleted**")
  153.       .setColor("#4169e1")
  154.       .setDescription(`🗑️ The role **${role.name}** was deleted.`)
  155.       .setThumbnail("https://i.imgur.com/mq2Gse6.png")
  156.       .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
  157.       .setFooter({ text: "❌ Role Deleted | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
  158.  
  159.     send_log(role.guild.id, embed);
  160.   });
  161.  
  162.   // Log Channel Create
  163.   client.on("channelCreate", (channel) => {
  164.     const embed = new EmbedBuilder()
  165.       .setTitle("> 🛠️ **New Channel Created**")
  166.       .setColor("#4169e1")
  167.       .setDescription(`🆕 A new channel **#${channel.name}** was created.`)
  168.       .addFields({ name: `• Channel Type`, value: `${channel.type}`, inline: true })
  169.       .setThumbnail("https://i.imgur.com/mq2Gse6.png")
  170.       .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
  171.       .setFooter({ text: "🛠️ Channel Created | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
  172.  
  173.     send_log(channel.guild.id, embed);
  174.   });
  175.  
  176.   // Log Channel Delete
  177.   client.on("channelDelete", (channel) => {
  178.     const embed = new EmbedBuilder()
  179.       .setTitle("> ❌ **Channel Deleted**")
  180.       .setColor("#4169e1")
  181.       .setDescription(`🗑️ The channel **#${channel.name}** was deleted.`)
  182.       .setThumbnail("https://i.imgur.com/mq2Gse6.png")
  183.       .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
  184.       .setFooter({ text: "❌ Channel Deleted | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
  185.  
  186.     send_log(channel.guild.id, embed);
  187.   });
  188. }
  189.  
  190. module.exports = handleLogs;
  191.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement