From e6028c02f8f4c1f6d67e5225d9dba108ff37e851 Mon Sep 17 00:00:00 2001 From: Neko-Life Date: Sun, 8 Aug 2021 13:53:02 +0700 Subject: [PATCH] more logged event guildUpdate.js --- cmds/utility/newquoteotd.js | 17 +++--- resources/eventsLogger/guildMemberUpdate.js | 7 +-- resources/eventsLogger/guildUpdate.js | 65 ++++++++++++++++----- resources/eventsLogger/messageDelete.js | 2 +- 4 files changed, 64 insertions(+), 27 deletions(-) diff --git a/cmds/utility/newquoteotd.js b/cmds/utility/newquoteotd.js index 4019bba..71d894c 100644 --- a/cmds/utility/newquoteotd.js +++ b/cmds/utility/newquoteotd.js @@ -13,7 +13,7 @@ module.exports = class newquoteotd extends commando.Command { group: "utility", description: "The Life exclusive command for Quote of the day.", guildOnly: true, - userPermissions:["ADMINISTRATOR"] + userPermissions: ["ADMINISTRATOR"] }); } async run(msg, arg) { @@ -33,21 +33,20 @@ module.exports = class newquoteotd extends commando.Command { const author = mes.guild.member(mes.author); let description = mes.content; if (!description.endsWith('.')) { - description = description+'.'; + description = description + '.'; } - const thumbnail = mes.author.displayAvatarURL({format: "png", size: 4096, dynamic: true}); + const thumbnail = mes.author.displayAvatarURL({ format: "png", size: 4096, dynamic: true }); let name; if (author.displayName) { name = author.displayName; } else { name = author.username; } - emb - .setTitle(name) - .setDescription(description) - .setThumbnail(thumbnail) - .setFooter(quoteOTD.footerText || "", quoteOTD.footerIcon) - .setColor(color[Math.floor(Math.random()*color.length)]); + emb.setTitle(name) + .setDescription(description) + .setThumbnail(thumbnail) + .setFooter(quoteOTD.footerText || "​", quoteOTD.footerIcon) + .setColor(color[Math.floor(Math.random() * color.length)]); const sent = await trySend(this.client, quoteOTD.channel, emb); if (sent) { ranLog(msg, "New quote: " + sent.content + "\nBy: " + mes.author.tag + ` (${mes.author.id})`); diff --git a/resources/eventsLogger/guildMemberUpdate.js b/resources/eventsLogger/guildMemberUpdate.js index a28f11d..6558d42 100644 --- a/resources/eventsLogger/guildMemberUpdate.js +++ b/resources/eventsLogger/guildMemberUpdate.js @@ -67,8 +67,7 @@ module.exports = async (memberold, membernew) => { if (the.executor.id === memberold.id) nullReason = true; auditPerm = true; } - emb.addField("Current Nickname", "`" + membernew.displayName + "`") - .addField("Original Nickname", "`" + memberold.displayName + "`"); + emb.addField("Nickname", "Changed from `" + memberold.displayName + "` to `" + membernew.displayName + "`"); if (audit.executor) { if (!audit.executor.bot) nullReason = true; emb.setAuthor(emb.author.name, audit.executor.displayAvatarURL({ size: 128, format: "png", dynamic: true })); @@ -86,8 +85,8 @@ module.exports = async (memberold, membernew) => { emb.setTitle("Profile `" + memberold.user.tag + "` updated" + (audit?.executor ? ` by \`${audit.executor.tag}\`` : "")) .setColor(getColor("blue")); - if (emb.fields?.[0]?.name !== "Avatar") - emb.setFooter(emb.footer.text, NEWAV); + if (emb.fields[0]?.name !== "Avatar") + emb.setFooter(emb.footer.text || "​", NEWAV); if (!nullReason) { if (auditPerm) { emb.setDescription((audit?.reason || "No reason provided") + (emb.description ? "\n\n" + emb.description : "")); diff --git a/resources/eventsLogger/guildUpdate.js b/resources/eventsLogger/guildUpdate.js index 23d3948..57f44c9 100644 --- a/resources/eventsLogger/guildUpdate.js +++ b/resources/eventsLogger/guildUpdate.js @@ -84,7 +84,49 @@ module.exports = async (oldGuild, newGuild) => { }; if (newGuild.rulesChannelID !== oldGuild.rulesChannelID) { - emb.addField("Rules or Guidelines Channel", `Changed from <#${oldGuild.rulesChannelID}> to <#${newGuild.rulesChannelID}>`); + emb.addField("Rules or Guidelines Channel", + `Changed from ${oldGuild.rulesChannelID ? + "<#" + oldGuild.rulesChannelID + ">" : + "`[NONE]`" + } to ${newGuild.rulesChannelID ? + "<#" + newGuild.rulesChannelID + ">" : + "`[NONE]`"}`); + }; + + if (oldGuild.publicUpdatesChannelID !== newGuild.publicUpdatesChannelID) { + emb.addField("Community Updates Channel", + `Changed from ${oldGuild.publicUpdatesChannelID ? + "<#" + oldGuild.publicUpdatesChannelID + ">" : + "`[NONE]`" + } to ${newGuild.publicUpdatesChannelID ? + "<#" + newGuild.publicUpdatesChannelID + ">" : + "`[NONE]`"}`); + }; + + if (oldGuild.description !== newGuild.description) { + emb.addField("Current Description", newGuild.description || "`[NONE]`") + .addField("Original Description", oldGuild.description || "`[NONE]`"); + }; + + if (oldGuild.mfaLevel !== newGuild.mfaLevel) { + const level = ["None", "Low", "Medium", "High", "Highest"]; + emb.addField("Verification Level", `Changed from \`${level[oldGuild.mfaLevel] + }\` to \`${level[newGuild.mfaLevel]}\``); + } + + if (oldGuild.explicitContentFilter !== newGuild.explicitContentFilter) { + emb.addField("Explicit Media Content Filter", + `Changed from \`${oldGuild.explicitContentFilter}\` to \`${newGuild.explicitContentFilter}\``); + }; + + if (oldGuild.vanityURLCode !== newGuild.vanityURLCode) { + emb.addField("Vanity URL Code", `Changed from \`${oldGuild.vanityURLCode + }\` to \`${newGuild.vanityURLCode}\``); + }; + + if (oldGuild.ownerID !== newGuild.ownerID) { + emb.addField("Ownership", `<@${oldGuild.ownerID}> (\`${oldGuild.owner.user.tag}\` ${oldGuild.ownerID + }) have transferred Server Ownership to <@${newGuild.ownerID}> (\`${newGuild.owner.user.tag})\` ${newGuild.ownerID})`); }; if (oldGuild.banner !== newGuild.banner) { @@ -110,23 +152,19 @@ module.exports = async (oldGuild, newGuild) => { }; if (cached.iconURL && cached.iconURL !== newIcon) { - const newEmb = new MessageEmbed(emb); - await elseImageEmbed(logChannel, newEmb, "Icon", "This embed's thumbnail is the server's old icon.\nThe image below is the server's new icon.", cached.iconURL, newIcon); + await imageLogEmbed(logChannel, newEmb, "Icon", "This embed's thumbnail is the server's old icon.\nThe image below is the server's new icon.", cached.iconURL, newIcon); }; if (oldBanner || newBanner) { - const newEmb = new MessageEmbed(emb); - await elseImageEmbed(logChannel, newEmb, "Banner", "This embed's thumbnail is the server's old banner.\nThe image below is the server's new banner.", oldBanner, newBanner); + await imageLogEmbed(logChannel, newEmb, "Banner", "This embed's thumbnail is the server's old banner.\nThe image below is the server's new banner.", oldBanner, newBanner); }; if (oldSplash || newSplash) { - const newEmb = new MessageEmbed(emb); - await elseImageEmbed(logChannel, newEmb, "Splash Invite", "This embed's thumbnail is the server's old splash invite.\nThe image below is the server's new splash invite.", oldSplash, newSplash); + await imageLogEmbed(logChannel, newEmb, "Splash Invite", "This embed's thumbnail is the server's old splash invite.\nThe image below is the server's new splash invite.", oldSplash, newSplash); }; if (oldSDisc || newSDisc) { - const newEmb = new MessageEmbed(emb); - await elseImageEmbed(logChannel, newEmb, "Splash Discovery", "This embed's thumbnail is the server's old splash discovery.\nThe image below is the server's new splash discovery.", oldSDisc, newSDisc); + await imageLogEmbed(logChannel, newEmb, "Splash Discovery", "This embed's thumbnail is the server's old splash discovery.\nThe image below is the server's new splash discovery.", oldSDisc, newSDisc); }; if (!emb.fields.length) return; @@ -140,10 +178,11 @@ module.exports = async (oldGuild, newGuild) => { newGuild.updateCached("iconURL", newIcon); } -async function elseImageEmbed(channel, embed, fieldName, fieldValue, thumbnail, image) { - embed.fields = []; - embed.addField(fieldName, fieldValue) +async function imageLogEmbed(channel, embed, fieldName, fieldValue, thumbnail, image) { + const newEmb = new MessageEmbed(embed); + newEmb.fields = []; + newEmb.addField(fieldName, fieldValue) .setThumbnail(thumbnail) .setImage(image); - return trySend(channel.client, channel, embed); + return trySend(channel.client, channel, newEmb); } \ No newline at end of file diff --git a/resources/eventsLogger/messageDelete.js b/resources/eventsLogger/messageDelete.js index ce88d0a..ab017c7 100644 --- a/resources/eventsLogger/messageDelete.js +++ b/resources/eventsLogger/messageDelete.js @@ -37,7 +37,7 @@ module.exports = async (msg) => { .setTitle((!msg.webhookID ? "Message " + msg.id : "Webhook " + msg.webhookID) + " deleted" + (audit?.executor ? ` by \`${audit.executor.tag}\`` : "")) .setDescription(msg.content.length > 0 ? msg.content : "`[EMPTY]`") .setURL(msg.url) - .setFooter(emb.footer.text, msg.author.displayAvatarURL({ size: 128, format: "png", dynamic: true })); + .setFooter(emb.footer.text || "​", msg.author.displayAvatarURL({ size: 128, format: "png", dynamic: true })); if (audit.executor) emb.setAuthor(emb.author.name, audit.executor.displayAvatarURL({ size: 128, format: "png", dynamic: true })); if (msg.attachments?.size > 0) {