From 136e180bf8fcd2c3cf95385311d1780bda9407f5 Mon Sep 17 00:00:00 2001 From: Emi <136156874+aho-emi@users.noreply.github.com> Date: Sun, 17 Dec 2023 17:27:15 +0545 Subject: [PATCH 1/3] added $isValidColor --- src/functions/util/isValidColor.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/functions/util/isValidColor.js diff --git a/src/functions/util/isValidColor.js b/src/functions/util/isValidColor.js new file mode 100644 index 000000000..ce5c4599f --- /dev/null +++ b/src/functions/util/isValidColor.js @@ -0,0 +1,13 @@ +module.exports = d => { + const data = d.util.aoiFunc(d); + if (data.err) return d.error(data.err); + + let [hex] = data.inside.splits; + const regex = /^#?([0-9A-Fa-f]{3}){1,2}$/; + + data.result = regex.test(hex) + + return { + code: d.util.setCode(data) + } +} From cb7604c403741e4ee1b47de00cc9ab503c8468fb Mon Sep 17 00:00:00 2001 From: Emi <136156874+aho-emi@users.noreply.github.com> Date: Sun, 17 Dec 2023 17:28:58 +0545 Subject: [PATCH 2/3] Update isValidHex.js --- src/functions/util/isValidHex.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/functions/util/isValidHex.js b/src/functions/util/isValidHex.js index ce5c4599f..5e0e93c8d 100644 --- a/src/functions/util/isValidHex.js +++ b/src/functions/util/isValidHex.js @@ -3,9 +3,9 @@ module.exports = d => { if (data.err) return d.error(data.err); let [hex] = data.inside.splits; - const regex = /^#?([0-9A-Fa-f]{3}){1,2}$/; - - data.result = regex.test(hex) + hex = hex.addBrackets().replace('#', ''); + + data.result = isNaN(parseInt(hex, 16)) ? false : true; return { code: d.util.setCode(data) From d2c9cb42c8973c01db475b6bdcc2f04843367ec5 Mon Sep 17 00:00:00 2001 From: Emi <136156874+aho-emi@users.noreply.github.com> Date: Sun, 17 Dec 2023 18:46:27 +0545 Subject: [PATCH 3/3] added status change inside loop --- src/handler/status.js | 48 +++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/src/handler/status.js b/src/handler/status.js index f4d3100bd..b28e4f4c1 100644 --- a/src/handler/status.js +++ b/src/handler/status.js @@ -1,56 +1,46 @@ -module.exports = async (statuses, client) => { - if (statuses.size === 0) { +module.exports = async (status, client) => { + let statuses = client.statuses.allValues() + if (statuses.size <= 0) { return; } - const statusArray = statuses.allValues(); let y = 0; const processStatus = async () => { - if (!statusArray[y]) { + statuses = client.statuses.allValues() + if (!statuses[y]) { y = 0; } const stats = { - activity: { - type: statusArray[y].activity.type, - url: statusArray[y].activity.url, - }, + activity: statuses[y].activity, }; - if (statusArray[y].activity.name) { - if (statusArray[y].activity.name.includes("$")) { + if (name = stats?.activity?.name) { + if (name.includes("$")) { stats.activity.name = ( - await client.functionManager.interpreter( - client, - {}, - [], - { code: statusArray[y].activity.name }, - client.db, - true - ) + await client.functionManager.interpreter( + client, + {}, + [], + { code: statuses[y].activity.name }, + client.db, + true + ) )?.code; - } else { - stats.activity.name = statusArray[y].activity.name; } } else { throw new TypeError(`Missing or invalid 'name' method in status[${y}]`); } client.user.setPresence({ - status: statusArray[y].status, + status: statuses[y].status, activities: [stats.activity], - afk: statusArray[y].afk, + afk: statuses[y].afk, }); + setTimeout(processStatus, statuses[y]?.time * 1000 || 0); y++; - - if (y < statusArray.length) { - setTimeout(processStatus, statusArray[y]?.time * 1000 || 0); - } else { - y = 0; - setTimeout(processStatus, statusArray[y]?.time * 1000 || 0); - } }; await processStatus();