From 28a5609a107455ff27e2cf8c4207958b44b00878 Mon Sep 17 00:00:00 2001 From: Neko-Life Date: Mon, 9 Aug 2021 21:05:08 +0700 Subject: [PATCH] allow only one setup running --- cmds/moderation/src/configureMuteRole.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmds/moderation/src/configureMuteRole.js b/cmds/moderation/src/configureMuteRole.js index 609c26a..53f289c 100644 --- a/cmds/moderation/src/configureMuteRole.js +++ b/cmds/moderation/src/configureMuteRole.js @@ -4,6 +4,7 @@ const { Message } = require("discord.js"); const { blockChannelUpdateEvents, unblockChannelUpdateEvents } = require("../../../resources/eventsLogger/channelUpdate"); const { trySend, parseDash, defaultImageEmbed, defaultSplitMessage } = require("../../../resources/functions"); const getColor = require("../../../resources/getColor"); +let block = false; module.exports = async (msg, arg) => { if (!msg.member.isAdmin) return trySend(msg.client, msg, "<@" + msg.author + "> you're not an Administrator <:nekohmLife:846371737644957786>"); @@ -24,10 +25,11 @@ module.exports = async (msg, arg) => { if (data.color) emb.setColor(data.color); await trySend(msg.client, msg, emb); const RR = await msg.channel.awaitMessages((r) => r.author === msg.author, { max: 1, time: 30000 }); - if (RR.first()?.content.toLowerCase() === "yes") return detonate(msg, data); else return trySend(msg.client, msg, "Create Mute Role: **Cancelled**"); + if (RR.first()?.content.toLowerCase() === "yes" && !block) return detonate(msg, data); else return trySend(msg.client, msg, "Create Mute Role: **Cancelled**"); } async function detonate(msg, data) { + block = true; const map = msg.guild.channels.cache.map(r => r); const pleaseWait = await trySend(msg.client, msg, `Setting up for ${map.length} channel${map.length < 2 ? "" : "s"}... This message will be edited when done.`); data.permissions = 0; @@ -49,5 +51,6 @@ async function detonate(msg, data) { trySend(msg.client, msg, { content: mes + "<#" + cant.join(">,\n<#") + ">", split: split }); } msg.guild.setDb("settings", msg.guild.DB.settings); + block = false; return pleaseWait.edit(`Create Mute Role: ${ROLE} **Done**`); } \ No newline at end of file