11const events = require ( 'events' ) ;
22const { chattools, Time } = require ( '../utils' ) ;
33
4+ const STRINGS = {
5+ help : `
6+ Repete uma mensagem em um determinado período de tempo. Cada mensagem é representada por uma thread.
7+
8+ *uso:* \`\`\`!cron --args [--kwargs=<type>] ...\`\`\`
9+
10+ *args válidos:*
11+ \`\`\`--create\`\`\` -> _cria uma nova thread._
12+ \`\`\`--destroy\`\`\` -> _para e apaga uma thread._
13+ \`\`\`--stop\`\`\` -> _para uma thread._
14+ \`\`\`--start\`\`\` -> _inicia uma thread._
15+ \`\`\`--log\`\`\` -> _mostra as threads existentes._
16+ \`\`\`--help\`\`\` -> _mostra esta mensagem._
17+
18+ *kwargs válidos:*
19+ \`\`\`--s=<int>\`\`\` -> _define um periodo em segundos._
20+ \`\`\`--m=<int>\`\`\` -> _define um periodo em minutos._
21+ \`\`\`--h=<int>\`\`\` -> _define um periodo em horas._
22+ \`\`\`--d=<int>\`\`\` -> _define um periodo em dias._
23+ ` . trim ( ) ,
24+ } ;
425const emitter = new events . EventEmitter ( ) ;
526
627function Thread ( id , text , message , timer ) {
@@ -22,35 +43,18 @@ class Cron {
2243 this . name = 'cron' ;
2344 this . threads = [ ] ;
2445 this . counter = 0 ;
25- this . defaultMessage = `
26- Repete uma mensagem em um determinado período de tempo. Cada mensagem é representada por uma thread.
27-
28- *uso:* \`\`\`!command [--args] [--kwargs=<type>] ...\`\`\`
29-
30- *args válidos:*
31- \`\`\`--create\`\`\` -> _cria uma nova thread._
32- \`\`\`--destroy\`\`\` -> _para e apaga uma thread._
33- \`\`\`--stop\`\`\` -> _para uma thread._
34- \`\`\`--start\`\`\` -> _inicia uma thread._
35- \`\`\`--log\`\`\` -> _mostra as threads existentes._
36-
37- *kwargs válidos:*
38- \`\`\`--s=<int>\`\`\` -> _define um periodo em segundos._
39- \`\`\`--m=<int>\`\`\` -> _define um periodo em minutos._
40- \`\`\`--h=<int>\`\`\` -> _define um periodo em horas._
41- \`\`\`--d=<int>\`\`\` -> _define um periodo em dias._
42- ` . trim ( ) ;
46+ this . strings = STRINGS ;
4347 }
4448
4549 async execute ( data , message ) {
4650 const isAdm = await chattools . isAdm ( message ) ;
4751
48- if ( isAdm ) {
49- message . reply ( this . runs ( data , message ) ) ;
52+ if ( ! isAdm ) {
53+ message . reply ( 'staff only.' ) ;
5054 return ;
5155 }
5256
53- message . reply ( 'staff only.' ) ;
57+ message . reply ( this . runs ( data , message ) ) ;
5458 }
5559
5660 create ( data , message ) {
@@ -127,13 +131,14 @@ Repete uma mensagem em um determinado período de tempo. Cada mensagem é repres
127131 destroy : ( ) => this . destroy ( data . text ) ,
128132 start : ( ) => this . start ( data . text ) ,
129133 stop : ( ) => this . stop ( data . text ) ,
134+ help : ( ) => this . strings . help ,
130135 } ;
131136
132137 if ( methods [ data . args [ 0 ] ] ) {
133138 return methods [ data . args [ 0 ] ] ( ) ;
134139 }
135140
136- return this . defaultMessage ;
141+ throw new Error ( 'Nenhum arg válido foi passado.' ) ;
137142 }
138143
139144 isIdValid ( id ) {
0 commit comments