From 901b7013aac7af310f591c3d4bd4a7132c54ece0 Mon Sep 17 00:00:00 2001 From: Neko-Life Date: Wed, 11 Aug 2021 23:51:23 +0700 Subject: [PATCH] getAudit moved to functions.js --- resources/eventsLogger/channelUpdate.js | 18 ++---------------- resources/functions.js | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/resources/eventsLogger/channelUpdate.js b/resources/eventsLogger/channelUpdate.js index 5908c92..5c510d4 100644 --- a/resources/eventsLogger/channelUpdate.js +++ b/resources/eventsLogger/channelUpdate.js @@ -3,7 +3,7 @@ const { GuildChannel, Guild, GuildAuditLogsEntry, Role } = require("discord.js"); const { Interval } = require("luxon"); const { intervalToDuration } = require("../../cmds/moderation/src/duration"); -const { defaultEventLogEmbed, changed, trySend, wait } = require("../functions"); +const { defaultEventLogEmbed, changed, trySend, wait, getAudit } = require("../functions"); const getColor = require("../getColor"); let blockChannelUpdate = false; @@ -301,20 +301,6 @@ async function run(oldChannel, newChannel) { return trySend(newChannel.client, logChannel, emb); }; -/** - * @param {Guild} guild Get audit from - * @param {Date} dateNow - * @param {string} id Target ID - * @param {import("discord.js").GuildAuditLogsFetchOptions} option - * @returns {Promise} - */ -async function getAudit(guild, dateNow, id, option, filter = (value, key, collection) => - value.target.id === id && (dateNow.valueOf() - value.createdTimestamp) < 60000) { - const col = await guild.fetchAuditLogs(option); - const fil = col.entries.filter(filter); - return fil.first(); -}; - function blockChannelUpdateEvents() { blockChannelUpdate = true; console.log("CHANNEL UPDATE EVENTS BLOCKED. STATE:", blockChannelUpdate); @@ -325,4 +311,4 @@ function unblockChannelUpdateEvents() { console.log("CHANNEL UPDATE EVENTS UNBLOCKED. STATE:", blockChannelUpdate); }; -module.exports = { run, blockChannelUpdateEvents, unblockChannelUpdateEvents, getAudit } \ No newline at end of file +module.exports = { run, blockChannelUpdateEvents, unblockChannelUpdateEvents } \ No newline at end of file diff --git a/resources/functions.js b/resources/functions.js index bc92ef2..28d2dfc 100644 --- a/resources/functions.js +++ b/resources/functions.js @@ -565,11 +565,25 @@ function changed(oldObj, newObj) { return { oldObj: diffOld, newObj: diffNew }; } +/** + * @param {Guild} guild Get audit from + * @param {Date} dateNow + * @param {string} id Target ID + * @param {import("discord.js").GuildAuditLogsFetchOptions} option + * @returns {Promise} + */ +async function getAudit(guild, dateNow, id, option, filter = (value, key, collection) => + value.target.id === id && (dateNow.valueOf() - value.createdTimestamp) < 60000) { + const col = await guild.fetchAuditLogs(option); + const fil = col.entries.filter(filter); + return fil.first(); +}; + module.exports = { cleanMentionID, defaultEventLogEmbed, multipleMembersFound, multipleRolesFound, multipleChannelsFound, findMemberRegEx, findChannelRegEx, findRoleRegEx, - getChannelMessage, errLog, changed, + getChannelMessage, errLog, changed, getAudit, execCB, ranLog, noPerm, getUTCComparison, trySend, tryDelete, tryReact, defaultDateFormat, adCheck, defaultImageEmbed, getChannel,