Skip to content

Commit

Permalink
fix: cachemembers
Browse files Browse the repository at this point in the history
  • Loading branch information
Faf4a committed Sep 15, 2023
1 parent 35b2ef3 commit 531d9ad
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/functions/user/cacheMembers.js
Original file line number Diff line number Diff line change
@@ -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),
};
};

0 comments on commit 531d9ad

Please sign in to comment.