1 | <!DOCTYPE html>
|
2 | <html lang="en">
|
3 | <head>
|
4 | <meta charset="utf-8">
|
5 | <title>JSDoc: Source: Command.js</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">Source: Command.js</h1>
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | <section>
|
28 | <article>
|
29 | <pre class="prettyprint source linenums"><code>"use strict";
|
30 | Object.defineProperty(exports, "__esModule", { value: true });
|
31 | exports.Command = void 0;
|
32 | const Utils_1 = require("./Utils");
|
33 | class Command {
|
34 | /**
|
35 | * Create a new command
|
36 | * @param {CommandOptions} opts - Parameters for the command
|
37 | * @param {CommandCallback} run - The actual function to run when the command is called
|
38 | */
|
39 | constructor(opts, run) {
|
40 | this.run = run;
|
41 | this.opts = opts;
|
42 | // if name is "name" convert it to "[name]"
|
43 | if (typeof opts.names === "string")
|
44 | this.opts.names = [opts.names];
|
45 | if (opts.cooldown) {
|
46 | const cd = Utils_1.toMillisec(opts.cooldown.toString());
|
47 | if (!cd)
|
48 | throw new Error(`Cooldown for command ${this.opts.names[0]} is not in a valid format.`);
|
49 | this.opts.cooldown = cd;
|
50 | }
|
51 | if (opts.globalCooldown) {
|
52 | const cd = Utils_1.toMillisec(opts.globalCooldown.toString());
|
53 | if (!cd)
|
54 | throw new Error(`Global cooldown for command ${this.opts.names[0]} is not in a valid format.`);
|
55 | this.opts.globalCooldown = cd;
|
56 | }
|
57 | }
|
58 | }
|
59 | exports.Command = Command;
|
60 | exports.default = Command;
|
61 | //# sourceMappingURL=Command.js.map</code></pre>
|
62 | </article>
|
63 | </section>
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | </div>
|
69 |
|
70 | <nav>
|
71 | <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>
|
72 | </nav>
|
73 |
|
74 | <br class="clear">
|
75 |
|
76 | <footer>
|
77 | 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)
|
78 | </footer>
|
79 |
|
80 | <script> prettyPrint(); </script>
|
81 | <script src="scripts/linenumber.js"> </script>
|
82 | </body>
|
83 | </html>
|