/[sudobot]/trunk/scripts/make-command.js
ViewVC logotype

Contents of /trunk/scripts/make-command.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 575 - (show annotations)
Mon Jul 29 17:59:26 2024 UTC (8 months ago) by rakinar2
File MIME type: text/javascript
File size: 2767 byte(s)
chore: add trunk
1 #!/usr/bin/env node
2
3 /*
4 * This file is part of SudoBot.
5 *
6 * Copyright (C) 2021-2023 OSN Developers.
7 *
8 * SudoBot is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * SudoBot is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with SudoBot. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 const fs = require("fs");
23 const path = require("path");
24
25 if (process.argv.length < 3) {
26 console.log("A command name and group is required to generate!");
27 process.exit(-1);
28 }
29
30 if (process.argv.length < 4) {
31 console.log("A command name is required to generate!");
32 process.exit(-1);
33 }
34
35 const template = `/**
36 * This file is part of SudoBot.
37 *
38 * Copyright (C) 2021-${new Date().getFullYear()} OSN Developers.
39 *
40 * SudoBot is free software; you can redistribute it and/or modify it
41 * under the terms of the GNU Affero General Public License as published by
42 * the Free Software Foundation, either version 3 of the License, or
43 * (at your option) any later version.
44 *
45 * SudoBot is distributed in the hope that it will be useful, but
46 * WITHOUT ANY WARRANTY; without even the implied warranty of
47 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 * GNU Affero General Public License for more details.
49 *
50 * You should have received a copy of the GNU Affero General Public License
51 * along with SudoBot. If not, see <https://www.gnu.org/licenses/>.
52 */
53
54 import { EmbedBuilder, PermissionsBitField } from "discord.js";
55 import Command, { AnyCommandContext, ArgumentType, CommandMessage, CommandReturn, ValidationRule } from "../../core/Command";
56
57 export default class %commandName%Command extends Command {
58 public readonly name = "%commandNameLowerCase%";
59 public readonly validationRules: ValidationRule[] = [];
60 public readonly permissions = [];
61
62 async execute(message: CommandMessage, context: AnyCommandContext): Promise<CommandReturn> {
63
64 }
65 }
66 `
67 .replace("%commandName%", process.argv[3])
68 .replace("%commandNameLowerCase%", process.argv[3].toLowerCase());
69
70 fs.writeFileSync(
71 path.join(
72 __dirname,
73 fs.existsSync(path.join(__dirname, "src")) ? "." : "..",
74 "src/commands",
75 process.argv[2],
76 process.argv[3] + "Command.ts"
77 ),
78 template
79 );
80 console.log("Successfully created: ", process.argv[3] + "Command");

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26