Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fs = require('fs');
- const path = require('path');
- //AUDIT LOG
- const Audit_Log = require("./Schemas.js/auditlog");
- client.on('guildBanAdd', async (guild, user) => {
- const auditLogs = await guild.fetchAuditLogs({ type: 'MEMBER_BAN_ADD', limit: 1 });
- const banLog = auditLogs.entries.first();
- const executor = banLog.executor;
- const reason = banLog.reason || 'No reason given';
- const timestamp = banLog.createdAt;
- const data = await Audit_Log.findOne({
- Guild: guild.id
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const auditChannel = client.channels.cache.get(logID);
- auditEmbed
- .setTitle('Ban added')
- .addFields(
- {name: "Banned Member:", value: `Name: ${user.tag}\nID: ${user.id}`, inline: false},
- {name: "Executor:", value: `${executor.tag}\nID: ${executor.id}`, inline: false},
- {name: "Time:", value: timestamp, inline: false},
- {name: "Reason:", value: reason, inline: false}
- )
- await auditChannel.send({ embeds: [auditEmbed] });
- });
- client.on('guildBanRemove', async (guild, user) => {
- const auditLogs = await guild.fetchAuditLogs({ type: 'MEMBER_BAN_REMOVE', limit: 1 });
- const unbanLog = auditLogs.entries.first();
- const executor = unbanLog.executor;
- const timestamp = unbanLog.createdAt;
- const data = await Audit_Log.findOne({
- Guild: guild.id
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const auditChannel = client.channels.cache.get(logID);
- auditEmbed
- .setTitle('Ban removed')
- .setDescription(`Name: ${user.tag}\nID: ${user.id}`)
- .addFields(
- {name: "Banned Member:", value: `${user.tag}\nID: ${user.id}`, inline: false},
- {name: "Executor:", value: `${executor.tag}\nID: ${executor.id}`, inline: false},
- {name: "Time:", value: `${timestamp}`}
- )
- await auditChannel.send({ embeds: [auditEmbed] });
- });
- client.on(Events.ChannelCreate, async (channel) => {
- const data = await Audit_Log.findOne({
- Guild: channel.guild.id
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const auditChannel = client.channels.cache.get(logID);
- auditEmbed.setTitle("Channel Created").addFields(
- {name: "Channel Name:", value: channel.name, inline: false},
- {name: "Channel ID:", value: channel.id, inline: false}
- )
- await auditChannel.send({ embeds: [auditEmbed]});
- })
- client.on(Events.ChannelDelete, async (channel) => {
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const data = await Audit_Log.findOne({
- Guild: channel.guild.id,
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- const auditChannel = client.channels.cache.get(logID);
- auditEmbed.setTitle("Channel Deleted").addFields(
- {name: "Channel Name:", value: channel.name, inline: false},
- {name: "Channel ID:", value: channel.id, inline: false}
- )
- await auditChannel.send({ embeds: [auditEmbed]});
- })
- client.on(Events.ChannelUpdate, async (oldChannel, newChannel) => {
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const data = await Audit_Log.findOne({
- Guild: oldChannel.guild.id,
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- const auditChannel = client.channels.cache.get(logID);
- const changes = [];
- if (oldChannel.name !== newChannel.name) {
- changes.push(`Name: \`${oldChannel.name}\` → \`${newChannel.name}\``);
- }
- if (oldChannel.topic !== newChannel.topic) {
- changes.push(`Topic: \`${oldChannel.topic || 'None'}\` → \`${newChannel.topic || 'None'}\``);
- }
- if (changes.length === 0) return;
- const changesText = changes.join('\n');
- auditEmbed.setTitle("Channel Updated").addFields({ name: "Changes:", value: changesText})
- await auditChannel.send({ embeds: [auditEmbed]});
- })
- client.on(Events.GuildRoleCreate, async (role) => {
- const data = await Audit_Log.findOne({
- Guild: role.guild.id
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const auditChannel = client.channels.cache.get(logID);
- auditEmbed.setTitle("Role Created").addFields(
- {name: "Role Name:", value: role.name, inline: false},
- {name: "Role ID:", value: role.id, inline: false}
- )
- await auditChannel.send({ embeds: [auditEmbed]});
- })
- client.on(Events.GuildRoleDelete, async (role) => {
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const data = await Audit_Log.findOne({
- Guild: role.guild.id,
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- const auditChannel = client.channels.cache.get(logID);
- auditEmbed.setTitle("Role Removed").addFields(
- {name: "Role Name:", value: role.name, inline: false},
- {name: "Role ID:", value: role.id, inline: false}
- )
- await auditChannel.send({ embeds: [auditEmbed]});
- })
- client.on(Events.MessageDelete, async (message) => {
- const data = await Audit_Log.findOne({
- Guild: message.guild.id,
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- try {
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const auditChannel = client.channels.cache.get(logID);
- auditEmbed.setTitle("Message Deleted").addFields(
- {name: "Author:", value: `${message.author}`, inline: false},
- {name: "Message:", value: `${message.content}`, inline: false},
- {name: "Message ID:", value: `${message.id}`}
- )
- await auditChannel.send({ embeds: [auditEmbed]});
- } catch (err) {
- return;
- }
- })
- client.on(Events.AutoModerationRuleCreate, async (autoModerationRule) => {
- const data = await Audit_Log.findOne({
- Guild: autoModerationRule.guild.id,
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const auditChannel = client.channels.cache.get(logID);
- auditEmbed.setTitle("Automod Rule Created").addFields(
- {name: "Rulecreator:", value: `<@${autoModerationRule.creatorId}>`, inline: false},
- {name: "Rulename:", value: autoModerationRule.name},
- {name: "Actions:", value: `${autoModerationRule.actions}`, inline: false},
- )
- await auditChannel.send({ embeds: [auditEmbed]});
- })
- client.on(Events.AutoModerationRuleDelete, async (autoModerationRule) => {
- const data = await Audit_Log.findOne({
- Guild: autoModerationRule.guild.id,
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const auditChannel = client.channels.cache.get(logID);
- auditEmbed.setTitle("Automod Rule Created").addFields(
- {name: "Rulecreator:", value: `<@${autoModerationRule.creatorId}>`, inline: false},
- {name: "Rulename:", value: autoModerationRule.name},
- {name: "Actions:", value: `${autoModerationRule.actions}`, inline: false},
- )
- await auditChannel.send({ embeds: [auditEmbed]});
- })
- client.on(Events.AutoModerationRuleUpdate, async (newAutoModerationRule, oldAutoModerationRule) => {
- const data = await Audit_Log.findOne({
- Guild: newAutoModerationRule.guild.id,
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const auditChannel = client.channels.cache.get(logID);
- auditEmbed.setTitle("Automod Rule Updated").addFields(
- {name: "Old Rulename:", value: `${oldAutoModerationRule.name}`, inline: false},
- {name: "Old Actions:", value: `${oldAutoModerationRule.actions}`, inline: false},
- {name: "New Rulename:", value: newAutoModerationRule.name, inline: false},
- {name: "New Actions:", value: newAutoModerationRule.actions}
- )
- await auditChannel.send({ embeds: [auditEmbed]});
- })
- client.on(Events.ThreadCreate, async (thread) => {
- const data = await Audit_Log.findOne({
- Guild: thread.guild.id,
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const auditChannel = client.channels.cache.get(logID);
- auditEmbed.setTitle("Thread Created").addFields(
- {name: "Name:", value: thread.name, inline: false},
- {name: "Tag:", value: `<#${thread.id}>`, inline: false},
- {name: "ID:", value: thread.id, inline: false},
- )
- await auditChannel.send({ embeds: [auditEmbed]});
- })
- client.on(Events.ThreadDelete, async (thread) => {
- const data = await Audit_Log.findOne({
- Guild: thread.guild.id,
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const auditChannel = client.channels.cache.get(logID);
- auditEmbed.setTitle("Thread Deleted").addFields(
- {name: "Name:", value: thread.name, inline: false},
- {name: "Tag:", value: `<#${thread.id}>`, inline: false},
- {name: "ID:", value: thread.id, inline: false},
- )
- await auditChannel.send({ embeds: [auditEmbed]});
- })
- client.on(Events.InviteCreate, async (invite) => {
- const data = await Audit_Log.findOne({
- Guild: invite.guild.id,
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const auditChannel = client.channels.cache.get(logID);
- auditEmbed.setTitle("Invite Created").addFields(
- {name: "User:", value: `<@${invite.inviterId}>`, inline: false},
- {name: "Invite Code:", value: `${invite.code}`, inline: false},
- {name: "Expires at:", value: `${invite.expiresAt}`, inline: false},
- {name: "Created at:", value: `${invite.createdAt}`, inline: false},
- {name: "Channel:", value: `<#${invite.channelId}>`, inline: false},
- {name: "Max Uses:", value: `${invite.maxUses}`, inline: false},
- {name: "URL", value: `${invite.url}`}
- )
- await auditChannel.send({ embeds: [auditEmbed]});
- })
- client.on(Events.InviteDelete, async (invite) => {
- const data = await Audit_Log.findOne({
- Guild: invite.guild.id
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const auditChannel = client.channels.cache.get(logID);
- auditEmbed.setTitle("Invite Deleted").addFields(
- {name: "User:", value: `<@${invite.inviter.id}>`, inline: false},
- {name: "Invite Code:", value: `${invite.code}`, inline: false},
- {name: "Expires at:", value: `${invite.expiresAt}`, inline: false},
- {name: "Created at:", value: `${invite.createdAt}`, inline: false},
- {name: "Channel:", value: `<#${invite.channelId}>`, inline: false},
- {name: "Max Uses:", value: `${invite.maxUses}`, inline: false},
- {name: "URL", value: `${invite.url}`}
- )
- await auditChannel.send({ embeds: [auditEmbed]});
- })
- client.on(Events.MessageBulkDelete, async (messages) => {
- const firstMessage = messages.first();
- const channel = firstMessage.channel;
- const guildId = channel.guild.id;
- const data = await Audit_Log.findOne({
- Guild: guildId
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const auditChannel = client.channels.cache.get(logID);
- const htmlContent = generateHtmlTranscript(messages, channel, guildId);
- const transcriptFilePath = path.join(__dirname, 'transcripts', `transcript_${Date.now()}.html`);
- fs.writeFileSync(transcriptFilePath, htmlContent);
- function generateHtmlTranscript(messages, channel, guildId) {
- let html = `
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Bulk Delete</title>
- </head>
- <body>
- <h1>Transscript - Deleted Messages</h1>
- <p>Kanal: ${channel.name} (ID: ${channel.id})</p>
- <p>Server ID: ${guildId}</p>
- <p>Anzahl der gelöschten Nachrichten: ${messages.size}</p>
- <ul>
- `;
- messages.forEach(message => {
- const content = message.content || '[Picture/File]';
- html += `<li><strong>${message.author.tag}</strong>: ${content}</li>`;
- });
- html += `
- </ul>
- </body>
- </html>
- `;
- return html;
- }
- auditEmbed.setTitle("Messae Bulk Delete").addFields(
- {name: "Messages Deleted:", value: `${messages.size}`, inline: false},
- {name: "Channel:", value: `${messages.channel}`, inline: false},
- )
- await auditChannel.send({
- embeds: [auditEmbed],
- files: [transcriptFilePath],});
- })
- /*const { id, channel_id, guild_id, author, timestamp, type } = data;*/
- client.on(Events.MessageUpdate, async (oldMessage, newMessage) => {
- const data = await Audit_Log.findOne({
- Guild: oldMessage.guild.id
- })
- let logID;
- if (data) {
- logID = data.Channel
- } else {
- return;
- }
- const auditEmbed = new EmbedBuilder().setColor("White").setTimestamp().setFooter({ text: "Nexus Audit Log System"})
- const auditChannel = client.channels.cache.get(logID);
- auditEmbed.setTitle("Message Edited")
- .addFields({ name: 'Author:', value: `${newMessage.author.tag}`, inline: false})
- .addFields({ name: 'Channel:', value: `${newMessage.channel}`, inline: false})
- .addFields({ name: 'Old Message:', value: `${oldMessage.content}`, inline: false})
- .addFields({ name: 'New Message:', value: `${newMessage.content}`, inline: false})
- await auditChannel.send({ embeds: [auditEmbed]});
- })
- client.on(Events.GuildMemberAdd, async (member) => {
- })
- client.on(Events.GuildMemberRemove, async (member) => {
- })
Advertisement
Add Comment
Please, Sign In to add comment