Files
NitoriBot/src/modules/command_loop.js
T

43 lines
966 B
JavaScript
Raw Normal View History

2025-08-12 10:39:50 -05:00
class command_loop {
2025-05-07 07:27:41 -04:00
constructor(context) {
const bot = context.bot;
bot.cloop = {
list: [],
add(command, interval) {
let timer;
timer = {
timer: setInterval(() => bot.core.run(command), interval),
command,
interval,
};
this.list.push(timer);
2024-09-07 21:13:24 -04:00
2025-08-14 10:13:54 -05:00
/* bot.on("end", () => {
2025-05-07 07:27:41 -04:00
this.clear();
});
2024-09-07 21:13:24 -04:00
2025-05-07 07:27:41 -04:00
bot.on("packet.login", () => {
if (this.list.length === 0) return;
timer = {
timer: setInterval(() => bot.core.run(command), interval),
command,
interval,
};
this.list.push(timer);
2025-08-14 10:13:54 -05:00
});*/
2025-05-07 07:27:41 -04:00
},
2024-07-07 15:44:16 -04:00
2025-05-07 07:27:41 -04:00
remove(index) {
clearInterval(this.list[index].timer);
bot.cloop.list.splice(index, 1);
},
2024-09-07 21:13:24 -04:00
2025-05-07 07:27:41 -04:00
clear() {
for (const cloop of this.list) clearInterval(cloop.timer);
this.list = [];
},
};
2024-07-07 15:44:16 -04:00
}
}
2025-08-12 10:39:50 -05:00
module.exports = command_loop;