Skip to content

Commit

Permalink
Merge pull request #525 from aho-emi/v6
Browse files Browse the repository at this point in the history
added status change inside loop
  • Loading branch information
USERSATOSHI authored Dec 17, 2023
2 parents d30df9a + d2c9cb4 commit 9ba03ab
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 32 deletions.
13 changes: 13 additions & 0 deletions src/functions/util/isValidColor.js
Original file line number Diff line number Diff line change
@@ -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)
}
}
6 changes: 3 additions & 3 deletions src/functions/util/isValidHex.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
48 changes: 19 additions & 29 deletions src/handler/status.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down

0 comments on commit 9ba03ab

Please sign in to comment.