Skip to content

Commit 8825834

Browse files
committed
[FEAT] implements killall method
1 parent 8b28342 commit 8825834

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/commands/cron.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Repete uma mensagem em um determinado período de tempo. Cada mensagem é repres
1313
\`\`\`--stop\`\`\` -> _para uma thread._
1414
\`\`\`--start\`\`\` -> _inicia uma thread._
1515
\`\`\`--log\`\`\` -> _mostra as threads existentes._
16+
\`\`\`--killall\`\`\` -> _para e apaga todas as threads._
1617
\`\`\`--help\`\`\` -> _mostra esta mensagem._
1718
1819
*kwargs válidos:*
@@ -124,6 +125,14 @@ class Cron {
124125
return output.trim();
125126
}
126127

128+
killall() {
129+
this.threads.forEach((t) => {
130+
this.destroy(t.id);
131+
});
132+
133+
return 'Todas as threads foram destruidas.';
134+
}
135+
127136
runs(data, message) {
128137
const methods = {
129138
log: () => this.log(),
@@ -132,6 +141,7 @@ class Cron {
132141
start: () => this.start(data.text),
133142
stop: () => this.stop(data.text),
134143
help: () => this.strings.help,
144+
killall: () => this.killall(),
135145
};
136146

137147
if (methods[data.args[0]]) {

0 commit comments

Comments
 (0)