1 | <!DOCTYPE html>
|
2 | <html lang="en">
|
3 | <head>
|
4 | <meta charset="utf-8">
|
5 | <title>JSDoc: Class: Handler</title>
|
6 |
|
7 | <script src="scripts/prettify/prettify.js"> </script>
|
8 | <script src="scripts/prettify/lang-css.js"> </script>
|
9 | |
10 |
|
11 |
|
12 | <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
13 | <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
14 | </head>
|
15 |
|
16 | <body>
|
17 |
|
18 | <div id="main">
|
19 |
|
20 | <h1 class="page-title">Class: Handler</h1>
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | <section>
|
28 |
|
29 | <header>
|
30 |
|
31 | <h2><span class="attribs"><span class="type-signature"></span></span>Handler<span class="signature">(opts)</span><span class="type-signature"></span></h2>
|
32 |
|
33 |
|
34 | </header>
|
35 |
|
36 | <article>
|
37 | <div class="container-overview">
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | <h4 class="name" id="Handler"><span class="type-signature"></span>new Handler<span class="signature">(opts)</span><span class="type-signature"></span></h4>
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | <div class="description">
|
52 | <p>Create a new command handler</p>
|
53 | </div>
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 | <h5>Parameters:</h5>
|
64 |
|
65 |
|
66 | <table class="params">
|
67 | <thead>
|
68 | <tr>
|
69 |
|
70 | <th>Name</th>
|
71 |
|
72 |
|
73 | <th>Type</th>
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | <th class="last">Description</th>
|
80 | </tr>
|
81 | </thead>
|
82 |
|
83 | <tbody>
|
84 |
|
85 |
|
86 | <tr>
|
87 |
|
88 | <td class="name"><code>opts</code></td>
|
89 |
|
90 |
|
91 | <td class="type">
|
92 |
|
93 |
|
94 | <span class="param-type">HandlerConstructor</span>
|
95 |
|
96 |
|
97 |
|
98 | </td>
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 | <td class="description last"><p>Put all options in this object. Only the client, prefix and commands directory are requred, everthing else is optional.</p></td>
|
105 | </tr>
|
106 |
|
107 |
|
108 | </tbody>
|
109 | </table>
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 | <dl class="details">
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 | <dt class="tag-source">Source:</dt>
|
144 | <dd class="tag-source"><ul class="dummy"><li>
|
145 | <a href="Handler.js.html">Handler.js</a>, <a href="Handler.js.html#line42">line 42</a>
|
146 | </li></ul></dd>
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 | </dl>
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 | </div>
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 | <h3 class="subsection-title">Methods</h3>
|
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 | <h4 class="name" id="dbConnect"><span class="type-signature">(async) </span>dbConnect<span class="signature">(uri)</span><span class="type-signature"></span></h4>
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 | <div class="description">
|
209 | <p>Connect to the database (for cooldowns)</p>
|
210 | </div>
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 | <h5>Parameters:</h5>
|
221 |
|
222 |
|
223 | <table class="params">
|
224 | <thead>
|
225 | <tr>
|
226 |
|
227 | <th>Name</th>
|
228 |
|
229 |
|
230 | <th>Type</th>
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 | <th class="last">Description</th>
|
237 | </tr>
|
238 | </thead>
|
239 |
|
240 | <tbody>
|
241 |
|
242 |
|
243 | <tr>
|
244 |
|
245 | <td class="name"><code>uri</code></td>
|
246 |
|
247 |
|
248 | <td class="type">
|
249 |
|
250 |
|
251 | <span class="param-type">string</span>
|
252 |
|
253 |
|
254 |
|
255 | </td>
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 | <td class="description last"><p>MongoDB connection string</p></td>
|
262 | </tr>
|
263 |
|
264 |
|
265 | </tbody>
|
266 | </table>
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 | <dl class="details">
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 | <dt class="tag-source">Source:</dt>
|
301 | <dd class="tag-source"><ul class="dummy"><li>
|
302 | <a href="Handler.js.html">Handler.js</a>, <a href="Handler.js.html#line358">line 358</a>
|
303 | </li></ul></dd>
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 | </dl>
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 | <h4 class="name" id="executeCommand"><span class="type-signature">(async) </span>executeCommand<span class="signature">(message, command)</span><span class="type-signature"></span></h4>
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 | <div class="description">
|
346 | <p>Execute a command.
|
347 | (this is the function used internally for launching the commands)</p>
|
348 | </div>
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 | <h5>Parameters:</h5>
|
359 |
|
360 |
|
361 | <table class="params">
|
362 | <thead>
|
363 | <tr>
|
364 |
|
365 | <th>Name</th>
|
366 |
|
367 |
|
368 | <th>Type</th>
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 | <th class="last">Description</th>
|
375 | </tr>
|
376 | </thead>
|
377 |
|
378 | <tbody>
|
379 |
|
380 |
|
381 | <tr>
|
382 |
|
383 | <td class="name"><code>message</code></td>
|
384 |
|
385 |
|
386 | <td class="type">
|
387 |
|
388 |
|
389 | <span class="param-type">Discord.Message</span>
|
390 |
|
391 |
|
392 |
|
393 | </td>
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 | <td class="description last"><p>The message that contains the command</p></td>
|
400 | </tr>
|
401 |
|
402 |
|
403 |
|
404 | <tr>
|
405 |
|
406 | <td class="name"><code>command</code></td>
|
407 |
|
408 |
|
409 | <td class="type">
|
410 |
|
411 |
|
412 | <span class="param-type"><a href="Command.html">Command</a></span>
|
413 |
|
414 |
|
415 |
|
416 | </td>
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 | <td class="description last"><p>The command to execute. (pro tip: combine with handler.getCommand)</p></td>
|
423 | </tr>
|
424 |
|
425 |
|
426 | </tbody>
|
427 | </table>
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 | <dl class="details">
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 | <dt class="tag-source">Source:</dt>
|
462 | <dd class="tag-source"><ul class="dummy"><li>
|
463 | <a href="Handler.js.html">Handler.js</a>, <a href="Handler.js.html#line193">line 193</a>
|
464 | </li></ul></dd>
|
465 |
|
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 | </dl>
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 | <h5>Returns:</h5>
|
489 |
|
490 |
|
491 | <div class="param-desc">
|
492 | <p>void</p>
|
493 | </div>
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 | <h4 class="name" id="getCommand"><span class="type-signature"></span>getCommand<span class="signature">(name)</span><span class="type-signature"></span></h4>
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 | <div class="description">
|
517 | <p>Find a command from any of its aliases
|
518 | (this is the function used internally for finding commands)</p>
|
519 | </div>
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 | <h5>Parameters:</h5>
|
530 |
|
531 |
|
532 | <table class="params">
|
533 | <thead>
|
534 | <tr>
|
535 |
|
536 | <th>Name</th>
|
537 |
|
538 |
|
539 | <th>Type</th>
|
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 | <th class="last">Description</th>
|
546 | </tr>
|
547 | </thead>
|
548 |
|
549 | <tbody>
|
550 |
|
551 |
|
552 | <tr>
|
553 |
|
554 | <td class="name"><code>name</code></td>
|
555 |
|
556 |
|
557 | <td class="type">
|
558 |
|
559 |
|
560 | <span class="param-type">string</span>
|
561 |
|
562 |
|
563 |
|
564 | </td>
|
565 |
|
566 |
|
567 |
|
568 |
|
569 |
|
570 | <td class="description last"><p>Name or names of a command</p></td>
|
571 | </tr>
|
572 |
|
573 |
|
574 | </tbody>
|
575 | </table>
|
576 |
|
577 |
|
578 |
|
579 |
|
580 |
|
581 |
|
582 | <dl class="details">
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 |
|
602 |
|
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 | <dt class="tag-source">Source:</dt>
|
610 | <dd class="tag-source"><ul class="dummy"><li>
|
611 | <a href="Handler.js.html">Handler.js</a>, <a href="Handler.js.html#line342">line 342</a>
|
612 | </li></ul></dd>
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 |
|
620 | </dl>
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 |
|
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 | <h5>Returns:</h5>
|
637 |
|
638 |
|
639 | <div class="param-desc">
|
640 | <p>The command or undefined if no command was found</p>
|
641 | </div>
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 |
|
656 |
|
657 | <h4 class="name" id="listen"><span class="type-signature"></span>listen<span class="signature">()</span><span class="type-signature"></span></h4>
|
658 |
|
659 |
|
660 |
|
661 |
|
662 |
|
663 |
|
664 | <div class="description">
|
665 | <p>Listen for messages</p>
|
666 | </div>
|
667 |
|
668 |
|
669 |
|
670 |
|
671 |
|
672 |
|
673 |
|
674 |
|
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 | <dl class="details">
|
681 |
|
682 |
|
683 |
|
684 |
|
685 |
|
686 |
|
687 |
|
688 |
|
689 |
|
690 |
|
691 |
|
692 |
|
693 |
|
694 |
|
695 |
|
696 |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 |
|
704 |
|
705 |
|
706 |
|
707 | <dt class="tag-source">Source:</dt>
|
708 | <dd class="tag-source"><ul class="dummy"><li>
|
709 | <a href="Handler.js.html">Handler.js</a>, <a href="Handler.js.html#line145">line 145</a>
|
710 | </li></ul></dd>
|
711 |
|
712 |
|
713 |
|
714 |
|
715 |
|
716 |
|
717 |
|
718 | </dl>
|
719 |
|
720 |
|
721 |
|
722 |
|
723 |
|
724 |
|
725 |
|
726 |
|
727 |
|
728 |
|
729 |
|
730 |
|
731 |
|
732 |
|
733 |
|
734 |
|
735 |
|
736 |
|
737 |
|
738 |
|
739 |
|
740 |
|
741 |
|
742 |
|
743 |
|
744 |
|
745 | <h4 class="name" id="loadCommands"><span class="type-signature">(async) </span>loadCommands<span class="signature">(dir, reload)</span><span class="type-signature"></span></h4>
|
746 |
|
747 |
|
748 |
|
749 |
|
750 |
|
751 |
|
752 | <div class="description">
|
753 | <p>Recursively reads a directory and loads all .js and .ts files
|
754 | (if these files don't export a command they will just be ignored)</p>
|
755 | </div>
|
756 |
|
757 |
|
758 |
|
759 |
|
760 |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 | <h5>Parameters:</h5>
|
766 |
|
767 |
|
768 | <table class="params">
|
769 | <thead>
|
770 | <tr>
|
771 |
|
772 | <th>Name</th>
|
773 |
|
774 |
|
775 | <th>Type</th>
|
776 |
|
777 |
|
778 |
|
779 |
|
780 | <th>Default</th>
|
781 |
|
782 |
|
783 | <th class="last">Description</th>
|
784 | </tr>
|
785 | </thead>
|
786 |
|
787 | <tbody>
|
788 |
|
789 |
|
790 | <tr>
|
791 |
|
792 | <td class="name"><code>dir</code></td>
|
793 |
|
794 |
|
795 | <td class="type">
|
796 |
|
797 |
|
798 | <span class="param-type">string</span>
|
799 |
|
800 |
|
801 |
|
802 | </td>
|
803 |
|
804 |
|
805 |
|
806 |
|
807 | <td class="default">
|
808 |
|
809 | </td>
|
810 |
|
811 |
|
812 | <td class="description last"><p>The directory to use</p></td>
|
813 | </tr>
|
814 |
|
815 |
|
816 |
|
817 | <tr>
|
818 |
|
819 | <td class="name"><code>reload</code></td>
|
820 |
|
821 |
|
822 | <td class="type">
|
823 |
|
824 |
|
825 | <span class="param-type">boolean</span>
|
826 |
|
827 |
|
828 |
|
829 | </td>
|
830 |
|
831 |
|
832 |
|
833 |
|
834 | <td class="default">
|
835 |
|
836 | false
|
837 |
|
838 | </td>
|
839 |
|
840 |
|
841 | <td class="description last"><p>Whether to clear the command list before reading (useful to reload the commands)</p></td>
|
842 | </tr>
|
843 |
|
844 |
|
845 | </tbody>
|
846 | </table>
|
847 |
|
848 |
|
849 |
|
850 |
|
851 |
|
852 |
|
853 | <dl class="details">
|
854 |
|
855 |
|
856 |
|
857 |
|
858 |
|
859 |
|
860 |
|
861 |
|
862 |
|
863 |
|
864 |
|
865 |
|
866 |
|
867 |
|
868 |
|
869 |
|
870 |
|
871 |
|
872 |
|
873 |
|
874 |
|
875 |
|
876 |
|
877 |
|
878 |
|
879 |
|
880 | <dt class="tag-source">Source:</dt>
|
881 | <dd class="tag-source"><ul class="dummy"><li>
|
882 | <a href="Handler.js.html">Handler.js</a>, <a href="Handler.js.html#line103">line 103</a>
|
883 | </li></ul></dd>
|
884 |
|
885 |
|
886 |
|
887 |
|
888 |
|
889 |
|
890 |
|
891 | </dl>
|
892 |
|
893 |
|
894 |
|
895 |
|
896 |
|
897 |
|
898 |
|
899 |
|
900 |
|
901 |
|
902 |
|
903 |
|
904 |
|
905 |
|
906 |
|
907 |
|
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 |
|
914 |
|
915 |
|
916 |
|
917 |
|
918 | <h4 class="name" id="makeEmbed"><span class="type-signature"></span>makeEmbed<span class="signature">(title, desc, color, thumbnail)</span><span class="type-signature"></span></h4>
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 | <div class="description">
|
926 | <p>A utility function to create nice embeds.</p>
|
927 | </div>
|
928 |
|
929 |
|
930 |
|
931 |
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 | <h5>Parameters:</h5>
|
938 |
|
939 |
|
940 | <table class="params">
|
941 | <thead>
|
942 | <tr>
|
943 |
|
944 | <th>Name</th>
|
945 |
|
946 |
|
947 | <th>Type</th>
|
948 |
|
949 |
|
950 |
|
951 |
|
952 |
|
953 | <th class="last">Description</th>
|
954 | </tr>
|
955 | </thead>
|
956 |
|
957 | <tbody>
|
958 |
|
959 |
|
960 | <tr>
|
961 |
|
962 | <td class="name"><code>title</code></td>
|
963 |
|
964 |
|
965 | <td class="type">
|
966 |
|
967 | </td>
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 | <td class="description last"></td>
|
974 | </tr>
|
975 |
|
976 |
|
977 |
|
978 | <tr>
|
979 |
|
980 | <td class="name"><code>desc</code></td>
|
981 |
|
982 |
|
983 | <td class="type">
|
984 |
|
985 | </td>
|
986 |
|
987 |
|
988 |
|
989 |
|
990 |
|
991 | <td class="description last"></td>
|
992 | </tr>
|
993 |
|
994 |
|
995 |
|
996 | <tr>
|
997 |
|
998 | <td class="name"><code>color</code></td>
|
999 |
|
1000 |
|
1001 | <td class="type">
|
1002 |
|
1003 | </td>
|
1004 |
|
1005 |
|
1006 |
|
1007 |
|
1008 |
|
1009 | <td class="description last"></td>
|
1010 | </tr>
|
1011 |
|
1012 |
|
1013 |
|
1014 | <tr>
|
1015 |
|
1016 | <td class="name"><code>thumbnail</code></td>
|
1017 |
|
1018 |
|
1019 | <td class="type">
|
1020 |
|
1021 | </td>
|
1022 |
|
1023 |
|
1024 |
|
1025 |
|
1026 |
|
1027 | <td class="description last"></td>
|
1028 | </tr>
|
1029 |
|
1030 |
|
1031 | </tbody>
|
1032 | </table>
|
1033 |
|
1034 |
|
1035 |
|
1036 |
|
1037 |
|
1038 |
|
1039 | <dl class="details">
|
1040 |
|
1041 |
|
1042 |
|
1043 |
|
1044 |
|
1045 |
|
1046 |
|
1047 |
|
1048 |
|
1049 |
|
1050 |
|
1051 |
|
1052 |
|
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 |
|
1063 |
|
1064 |
|
1065 |
|
1066 | <dt class="tag-source">Source:</dt>
|
1067 | <dd class="tag-source"><ul class="dummy"><li>
|
1068 | <a href="Handler.js.html">Handler.js</a>, <a href="Handler.js.html#line383">line 383</a>
|
1069 | </li></ul></dd>
|
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 |
|
1077 | </dl>
|
1078 |
|
1079 |
|
1080 |
|
1081 |
|
1082 |
|
1083 |
|
1084 |
|
1085 |
|
1086 |
|
1087 |
|
1088 |
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 |
|
1100 |
|
1101 |
|
1102 |
|
1103 |
|
1104 | </article>
|
1105 |
|
1106 | </section>
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 | </div>
|
1112 |
|
1113 | <nav>
|
1114 | <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Command.html">Command</a></li><li><a href="Handler.html">Handler</a></li></ul>
|
1115 | </nav>
|
1116 |
|
1117 | <br class="clear">
|
1118 |
|
1119 | <footer>
|
1120 | Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a> on Thu Jun 03 2021 13:46:08 GMT+0200 (Central European Summer Time)
|
1121 | </footer>
|
1122 |
|
1123 | <script> prettyPrint(); </script>
|
1124 | <script src="scripts/linenumber.js"> </script>
|
1125 | </body>
|
1126 | </html> |
\ | No newline at end of file |