mirror of
https://github.com/danbulant/Shasha
synced 2026-06-24 17:12:01 +00:00
avoid create mute role log spam
This commit is contained in:
parent
e4d9810899
commit
a601eaa344
3 changed files with 23 additions and 5 deletions
2
Main.js
2
Main.js
|
|
@ -117,7 +117,7 @@ client.on("guildUpdate", async (oldGuild, newGuild) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on("channelUpdate", async (oldChannel, newChannel) => {
|
client.on("channelUpdate", async (oldChannel, newChannel) => {
|
||||||
lgr.channelUpdate(oldChannel, newChannel);
|
lgr.channelUpdate.run(oldChannel, newChannel);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on("messageDelete", async (msg) => {
|
client.on("messageDelete", async (msg) => {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Message } = require("discord.js");
|
const { Message } = require("discord.js");
|
||||||
|
const { blockChannelUpdateEvents, unblockChannelUpdateEvents } = require("../../../resources/eventsLogger/channelUpdate");
|
||||||
const { trySend, parseDash, defaultImageEmbed, defaultSplitMessage } = require("../../../resources/functions");
|
const { trySend, parseDash, defaultImageEmbed, defaultSplitMessage } = require("../../../resources/functions");
|
||||||
const getColor = require("../../../resources/getColor");
|
const getColor = require("../../../resources/getColor");
|
||||||
|
|
||||||
|
|
@ -34,9 +35,11 @@ async function detonate(msg, data) {
|
||||||
msg.guild.DB.settings.mute.role = ROLE.id;
|
msg.guild.DB.settings.mute.role = ROLE.id;
|
||||||
let cant = [];
|
let cant = [];
|
||||||
if (ROLE) {
|
if (ROLE) {
|
||||||
|
blockChannelUpdateEvents();
|
||||||
for (const U of map) {
|
for (const U of map) {
|
||||||
await U.updateOverwrite(ROLE, { SEND_MESSAGES: false, CONNECT: false }, "Create Mute Role").catch(() => cant.push(U.id));
|
await U.updateOverwrite(ROLE, { SEND_MESSAGES: false, CONNECT: false }, "Create Mute Role").catch(() => cant.push(U.id));
|
||||||
}
|
};
|
||||||
|
setTimeout(unblockChannelUpdateEvents, 5000);
|
||||||
} else return pleaseWait.edit("Create Mute Role: Can't create role. Operation cancelled");
|
} else return pleaseWait.edit("Create Mute Role: Can't create role. Operation cancelled");
|
||||||
if (cant.length > 0) {
|
if (cant.length > 0) {
|
||||||
const split = defaultSplitMessage,
|
const split = defaultSplitMessage,
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,14 @@
|
||||||
const { GuildChannel, Guild, GuildAuditLogsEntry } = require("discord.js");
|
const { GuildChannel, Guild, GuildAuditLogsEntry } = require("discord.js");
|
||||||
const { defaultEventLogEmbed, changed, trySend, wait } = require("../functions");
|
const { defaultEventLogEmbed, changed, trySend, wait } = require("../functions");
|
||||||
const getColor = require("../getColor");
|
const getColor = require("../getColor");
|
||||||
|
let blockChannelUpdate = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {GuildChannel} oldChannel
|
* @param {GuildChannel} oldChannel
|
||||||
* @param {GuildChannel} newChannel
|
* @param {GuildChannel} newChannel
|
||||||
*/
|
*/
|
||||||
module.exports = async (oldChannel, newChannel) => {
|
async function run(oldChannel, newChannel) {
|
||||||
await wait(2000);
|
await wait(4000);
|
||||||
const dateNow = new Date();
|
const dateNow = new Date();
|
||||||
if (!newChannel.guild.DB) await newChannel.guild.dbLoad();
|
if (!newChannel.guild.DB) await newChannel.guild.dbLoad();
|
||||||
if (!newChannel.guild.DB.eventChannels?.guild) return;
|
if (!newChannel.guild.DB.eventChannels?.guild) return;
|
||||||
|
|
@ -76,6 +77,7 @@ module.exports = async (oldChannel, newChannel) => {
|
||||||
const added = newChannel.permissionOverwrites.get(key);
|
const added = newChannel.permissionOverwrites.get(key);
|
||||||
if (!newChannel.guild.roles.cache.get((removed || added).id)) continue;
|
if (!newChannel.guild.roles.cache.get((removed || added).id)) continue;
|
||||||
if (removed) {
|
if (removed) {
|
||||||
|
if (blockChannelUpdate && removed.id === newChannel.guild.DB.settings.mute.role) return;
|
||||||
if (!fetchAR) fetchAR = "R";
|
if (!fetchAR) fetchAR = "R";
|
||||||
const allow = removed.allow.serialize(), deny = removed.deny.serialize();
|
const allow = removed.allow.serialize(), deny = removed.deny.serialize();
|
||||||
let all = [], den = [];
|
let all = [], den = [];
|
||||||
|
|
@ -93,6 +95,7 @@ module.exports = async (oldChannel, newChannel) => {
|
||||||
"**Denied:**```js\n" + (den.join(", ") || "NONE") + "```");
|
"**Denied:**```js\n" + (den.join(", ") || "NONE") + "```");
|
||||||
console.log; // BREAKPOINT
|
console.log; // BREAKPOINT
|
||||||
} else if (added) {
|
} else if (added) {
|
||||||
|
if (blockChannelUpdate && added.id === newChannel.guild.DB.settings.mute.role) return;
|
||||||
if (!fetchAR) fetchAR = "A";
|
if (!fetchAR) fetchAR = "A";
|
||||||
const allow = added.allow.serialize(), deny = added.deny.serialize();
|
const allow = added.allow.serialize(), deny = added.deny.serialize();
|
||||||
let all = [], den = [];
|
let all = [], den = [];
|
||||||
|
|
@ -158,4 +161,16 @@ async function getAudit(guild, dateNow, id, option, filter = (value, key, collec
|
||||||
const col = await guild.fetchAuditLogs(option);
|
const col = await guild.fetchAuditLogs(option);
|
||||||
const fil = col.entries.filter(filter);
|
const fil = col.entries.filter(filter);
|
||||||
return fil.first();
|
return fil.first();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function blockChannelUpdateEvents() {
|
||||||
|
blockChannelUpdate = true;
|
||||||
|
console.log("CHANNEL UPDATE EVENTS BLOCKED. STATE:", blockChannelUpdate);
|
||||||
|
};
|
||||||
|
|
||||||
|
function unblockChannelUpdateEvents() {
|
||||||
|
blockChannelUpdate = false;
|
||||||
|
console.log("CHANNEL UPDATE EVENTS UNBLOCKED. STATE:", blockChannelUpdate);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = { run, blockChannelUpdateEvents, unblockChannelUpdateEvents }
|
||||||
Loading…
Reference in a new issue