Skip to content

Commit

Permalink
stauts method insanely speed jump
Browse files Browse the repository at this point in the history
no longer recursive but loop
  • Loading branch information
Leref committed Sep 27, 2023
1 parent 25db254 commit 73ea61b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/functions/client/killClient.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = d => {
const data = d.util.aoiFunc(d);

data.result = d.client.destroy();
d.client.destroy();

return {
code: d.util.setCode(data)
Expand Down
95 changes: 50 additions & 45 deletions src/handler/status.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,54 @@
module.exports = async (statuses, client) => {
if (statuses.size !== 0) {
let y = 0;
if (statuses.size === 0) {
return;
}

let status = statuses.allValues();
const f = async () => {
if (!status[y]) {
y = 0;
}
setTimeout(async () => {
const stats = {};
stats.activity = {};

stats.activity.type = status[y].activity.type;
stats.activity.url = status[y].activity.url;

if (status[y].activity.name) {

if (status[y].activity.name.includes("$")) {
stats.activity.name = (
await client.functionManager.interpreter(
client,
{},
[],
{ code: status[y].activity.name },
client.db,
true,
)
)?.code;
} else {
stats.activity.name = status[y].activity.name;
}
} else {
throw new TypeError(`Use the name method or provide a name for status[${y}]`);
}

client.user.setPresence({
status: status[y].status,
activities: [stats.activity],
afk: status[y].afk,
});

y++;
await f();
}, (status[y]?.time || 12) * 1000);
const statusArray = statuses.allValues();
let y = 0;

const processStatus = async () => {
if (!statusArray[y]) {
y = 0;
}

const stats = {
activity: {
type: statusArray[y].activity.type,
url: statusArray[y].activity.url,
},
};
f();
}

if (statusArray[y].activity.name) {
if (statusArray[y].activity.name.includes("$")) {
stats.activity.name = (
await client.functionManager.interpreter(
client,
{},
[],
{ code: statusArray[y].activity.name },
client.db,
true
)
)?.code;
} else {
stats.activity.name = statusArray[y].activity.name;
}
} else {
throw new TypeError(`Use the name method or provide a name for status[${y}]`);
}

client.user.setPresence({
status: statusArray[y].status,
activities: [stats.activity],
afk: statusArray[y].afk,
});

y++;

if (y < statusArray.length) {
setTimeout(processStatus, statusArray[y]?.time * 1000 || 0);
}
};

await processStatus();
};

0 comments on commit 73ea61b

Please sign in to comment.