From 531d9addf99e79fe33e6ba4561499603bc8498bf Mon Sep 17 00:00:00 2001 From: Faf4a Date: Fri, 15 Sep 2023 03:09:01 +0200 Subject: [PATCH] fix: cachemembers --- src/functions/user/cacheMembers.js | 40 ++++++++++++++++-------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/functions/user/cacheMembers.js b/src/functions/user/cacheMembers.js index a35261ab2..ff84608a9 100644 --- a/src/functions/user/cacheMembers.js +++ b/src/functions/user/cacheMembers.js @@ -1,24 +1,26 @@ module.exports = async (d) => { - const {code} = d.command; - const inside = d.unpack(); - const [guildID = d.guild.Id, returnCount = "false"] = inside.splits; - let result; + const data = d.util.aoiFunc(d); + if (data.err) return d.error(data.err); + const [guildID = d.guild.id, returnCount = "false"] = data.inside.splits; + let result; - const guild = await d.util.getGuild(d, guildID); - if (!guild) return d.aoiError.fnError(d, "guild", {inside}); + const guild = await d.util.getGuild(d, guildID); + if (!guild) return d.aoiError.fnError(d, "guild", { inside: data.inside }); - if (guild.memberCount > guild.members.cache.size) { - result = await guild.members.fetch().catch((err) => { - d.aoiError.fnError( - d, - "custom", - {}, - "Failed To Fetch Members With Reason :" + err, - ); - }); - } + if (guild.memberCount > guild.members.cache.size) { + result = await guild.members.fetch().catch((err) => { + d.aoiError.fnError( + d, + "custom", + {}, + "Failed To Fetch Members With Reason :" + err + ); + }); + } - return { - code: d.util.setCode({function: d.func, code, inside, result}), - }; + data.result = returnCount === "true" ? guild.members.cache.size.toString() : undefined; + + return { + code: d.util.setCode(data), + }; };