Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { EmbedBuilder } = require("discord.js");
- function handleLogs(client) {
- const logSchema = require(`${process.cwd()}/src/database/LogChannel.js`);
- // Function to send log to the specified log channel
- function send_log(guildId, embed) {
- logSchema.findOne({ Guild: guildId }, async (err, data) => {
- if (!data || !data.Channel) return;
- const LogChannel = client.channels.cache.get(data.Channel);
- if (!LogChannel) return;
- embed.setTimestamp();
- try {
- LogChannel.send({ embeds: [embed] });
- } catch (err) {
- console.log("Error sending log!");
- }
- });
- }
- // Log Message Deleted
- client.on("messageDelete", function (message) {
- if (!message.guild || message.author.bot) return;
- const embed = new EmbedBuilder()
- .setTitle("> 🚮 **Message Deleted**")
- .setColor("#4169e1")
- .setDescription(`🗑️ A message was deleted in <#${message.channel.id}>.`)
- .addFields(
- { name: `• 🧑💻 Author`, value: `<@${message.author.id}> - *${message.author.tag}*`, inline: true },
- { name: `• 📢 Channel`, value: `#${message.channel.name}`, inline: true },
- { name: `• ❌ Deleted Message`, value: `${message.content || "*No content*"}`, inline: false }
- )
- .setThumbnail("https://i.imgur.com/mq2Gse6.png")
- .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
- .setFooter({ text: "🚮 Message Deleted | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
- send_log(message.guild.id, embed);
- });
- // Log Message Edited
- client.on("messageUpdate", function (oldMessage, newMessage) {
- if (!oldMessage.guild || oldMessage.author.bot) return;
- const embed = new EmbedBuilder()
- .setTitle("> ✍️ **Message Edited**")
- .setColor("#4169e1")
- .setDescription(`✏️ A message was edited in <#${oldMessage.channel.id}>.`)
- .addFields(
- { name: `• 🧑💻 Author`, value: `<@${oldMessage.author.id}> - *${oldMessage.author.tag}*`, inline: true },
- { name: `• 📢 Channel`, value: `#${oldMessage.channel.name}`, inline: true },
- { name: `• 📝 Old Message`, value: `${oldMessage.content || "*No content*"}`, inline: false },
- { name: `• ✨ New Message`, value: `${newMessage.content || "*No content*"}`, inline: false }
- )
- .setThumbnail("https://i.imgur.com/mq2Gse6.png")
- .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
- .setFooter({ text: "✍️ Message Edited | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
- send_log(oldMessage.guild.id, embed);
- });
- // Log Profile Picture Change
- client.on("guildMemberUpdate", (oldMember, newMember) => {
- if (oldMember.displayAvatarURL() !== newMember.displayAvatarURL()) {
- const embed = new EmbedBuilder()
- .setTitle("> 🖼️ **Profile Picture Updated**")
- .setColor("#4169e1")
- .setDescription(`🖼️ ${newMember.user.tag} has updated their profile picture.`)
- .setThumbnail(newMember.displayAvatarURL({ dynamic: true, size: 1024 }))
- .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
- .setFooter({ text: "🖼️ Profile Picture Updated | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
- send_log(newMember.guild.id, embed);
- }
- });
- // Log Voice Channel Join
- client.on("voiceStateUpdate", (oldState, newState) => {
- if (oldState.channelId === null && newState.channelId !== null) {
- const embed = new EmbedBuilder()
- .setTitle("> 🎤 **User Joined Voice Channel**")
- .setColor("#4169e1")
- .setDescription(`🎙️ ${newState.member.user.tag} joined the voice channel **${newState.channel.name}**.`)
- .setThumbnail(newState.member.user.displayAvatarURL({ dynamic: true }))
- .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
- .setFooter({ text: "🎤 Voice Channel Joined | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
- send_log(newState.guild.id, embed);
- }
- });
- // Log Voice Channel Leave
- client.on("voiceStateUpdate", (oldState, newState) => {
- if (oldState.channelId !== null && newState.channelId === null) {
- const embed = new EmbedBuilder()
- .setTitle("> 🔇 **User Left Voice Channel**")
- .setColor("#4169e1")
- .setDescription(`🔇 ${oldState.member.user.tag} left the voice channel **${oldState.channel.name}**.`)
- .setThumbnail(oldState.member.user.displayAvatarURL({ dynamic: true }))
- .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
- .setFooter({ text: "🔇 Voice Channel Left | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
- send_log(oldState.guild.id, embed);
- }
- });
- // Log User Banned
- client.on("guildBanAdd", async (ban) => {
- const embed = new EmbedBuilder()
- .setTitle("> 🚨 **User Banned**")
- .setColor("#4169e1")
- .setDescription(`❌ ${ban.user.tag} has been banned from the server.`)
- .setThumbnail(ban.user.displayAvatarURL({ dynamic: true }))
- .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
- .setFooter({ text: "🚨 User Banned | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
- send_log(ban.guild.id, embed);
- });
- // Log User Unbanned
- client.on("guildBanRemove", async (ban) => {
- const embed = new EmbedBuilder()
- .setTitle("> 🛡️ **User Unbanned**")
- .setColor("#4169e1")
- .setDescription(`✅ ${ban.user.tag} has been unbanned from the server.`)
- .setThumbnail(ban.user.displayAvatarURL({ dynamic: true }))
- .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
- .setFooter({ text: "🛡️ User Unbanned | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
- send_log(ban.guild.id, embed);
- });
- // Log Role Create
- client.on("roleCreate", (role) => {
- const embed = new EmbedBuilder()
- .setTitle("> 🛠️ **New Role Created**")
- .setColor("#4169e1")
- .setDescription(`🆕 A new role **${role.name}** was created.`)
- .addFields({ name: `• Role Color`, value: `${role.hexColor}`, inline: true })
- .setThumbnail("https://i.imgur.com/mq2Gse6.png")
- .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
- .setFooter({ text: "🛠️ Role Created | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
- send_log(role.guild.id, embed);
- });
- // Log Role Delete
- client.on("roleDelete", (role) => {
- const embed = new EmbedBuilder()
- .setTitle("> ❌ **Role Deleted**")
- .setColor("#4169e1")
- .setDescription(`🗑️ The role **${role.name}** was deleted.`)
- .setThumbnail("https://i.imgur.com/mq2Gse6.png")
- .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
- .setFooter({ text: "❌ Role Deleted | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
- send_log(role.guild.id, embed);
- });
- // Log Channel Create
- client.on("channelCreate", (channel) => {
- const embed = new EmbedBuilder()
- .setTitle("> 🛠️ **New Channel Created**")
- .setColor("#4169e1")
- .setDescription(`🆕 A new channel **#${channel.name}** was created.`)
- .addFields({ name: `• Channel Type`, value: `${channel.type}`, inline: true })
- .setThumbnail("https://i.imgur.com/mq2Gse6.png")
- .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
- .setFooter({ text: "🛠️ Channel Created | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
- send_log(channel.guild.id, embed);
- });
- // Log Channel Delete
- client.on("channelDelete", (channel) => {
- const embed = new EmbedBuilder()
- .setTitle("> ❌ **Channel Deleted**")
- .setColor("#4169e1")
- .setDescription(`🗑️ The channel **#${channel.name}** was deleted.`)
- .setThumbnail("https://i.imgur.com/mq2Gse6.png")
- .setAuthor({ name: "🔧 Rivvix Logging", iconURL: client.user.displayAvatarURL({ dynamic: true }) })
- .setFooter({ text: "❌ Channel Deleted | Rivvix Logs", iconURL: "https://i.imgur.com/T4v9RgP.png" });
- send_log(channel.guild.id, embed);
- });
- }
- module.exports = handleLogs;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement