generator-discord 1.1.7 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/app/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import Generator from 'yeoman-generator';
2
+ export default class DiscordGenerator extends Generator {
3
+ private answers;
4
+ constructor(args: string | string[], options: Generator.GeneratorOptions);
5
+ prompting(): Promise<void>;
6
+ logo(): void;
7
+ writing(): void;
8
+ install(): Promise<void>;
9
+ end(): Promise<void>;
10
+ }
package/app/index.js ADDED
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const yeoman_generator_1 = __importDefault(require("yeoman-generator"));
16
+ const path_1 = __importDefault(require("path"));
17
+ const TEMPLATE_DIR = '../templates/';
18
+ const USER_DIR = '.';
19
+ const OPEN = '<%= ';
20
+ const CLOSE = ' %>';
21
+ const BOT_NAME = 'bot-name';
22
+ const BOT_TOKEN = 'bot-token';
23
+ class DiscordGenerator extends yeoman_generator_1.default {
24
+ constructor(args, options) {
25
+ super(args, options);
26
+ }
27
+ prompting() {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ this.logo();
30
+ this.answers = yield this.prompt([
31
+ {
32
+ type: 'input',
33
+ name: 'botName',
34
+ message: 'Your Discord Bot name:',
35
+ default: 'my-bot',
36
+ validate: (input) => new RegExp("^(?:@[a-z0-9-*~][a-z0-9-*._~]*/)?[a-z0-9-~][a-z0-9-._~]*$").test(input)
37
+ ? true
38
+ : 'Invalid bot name. Please use only lowercase letters, numbers, and hyphens. Must start with a letter.'
39
+ },
40
+ {
41
+ type: 'list',
42
+ name: 'botType',
43
+ message: 'The type of Discord Bot you want to create.',
44
+ choices: [
45
+ {
46
+ name: 'New Discord Bot (TypeScript)',
47
+ value: 'typescript'
48
+ },
49
+ {
50
+ name: 'New Discord Bot (JavaScript)',
51
+ value: 'javascript'
52
+ },
53
+ {
54
+ name: 'New Discord Bot (Python)',
55
+ value: 'python'
56
+ }
57
+ ]
58
+ },
59
+ {
60
+ type: 'input',
61
+ name: 'botToken',
62
+ message: 'Your Discord Bot Token. (Enter to leave blank)',
63
+ default: 'your-bot-token'
64
+ }
65
+ ]);
66
+ });
67
+ }
68
+ logo() {
69
+ this.log(" \x1b[36m_____ _ _ \x1b[31m_ ");
70
+ this.log(" \x1b[36m| __ \\(_) | | \x1b[31m(_) ");
71
+ this.log(" \x1b[36m| | | |_ ___ ___ ___ _ __ __| | \x1b[33m_ ___ ");
72
+ this.log(" \x1b[36m| | | | / __|/ __/ _ \\| '__/ _` | \x1b[33m| / __|");
73
+ this.log(" \x1b[36m| |__| | \\__ \\ (_| (_) | | | (_| |\x1b[37m_\x1b[32m| \\__ \\");
74
+ this.log(" \x1b[36m|_____/|_|___/\\___\\___/|_| \\__,_\x1b[37m(_) \x1b[32m|___/");
75
+ this.log(" \x1b[34m_/ | ");
76
+ this.log(" \x1b[35m|__/ ");
77
+ this.log("\x1b[0m");
78
+ }
79
+ writing() {
80
+ this.sourceRoot(path_1.default.join(__dirname, TEMPLATE_DIR + this.answers.botType));
81
+ ['.'].forEach((path) => {
82
+ const replaceWords = (answers, content) => [
83
+ [BOT_NAME, this.answers.botName],
84
+ [BOT_TOKEN, this.answers.botToken]
85
+ ].reduce((acc, [templateWord, userAnswer]) => acc.replace(new RegExp(`${OPEN}${templateWord}${CLOSE}`, 'g'), userAnswer), content.toString());
86
+ this.fs.copy(this.templatePath(path), this.destinationPath(USER_DIR, this.answers.botName, path), {
87
+ process: (content) => replaceWords(this.answers, content)
88
+ });
89
+ });
90
+ }
91
+ install() {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ this.log('');
94
+ if (this.answers.botType === 'typescript' || this.answers.botType === 'javascript') {
95
+ const options = { cwd: this.destinationPath(USER_DIR, this.answers.botName) };
96
+ this.spawnCommandSync('npm', ['install'], options);
97
+ if (this.answers.botType === 'typescript') {
98
+ this.spawnCommandSync('npm', ['run', 'build'], options);
99
+ }
100
+ }
101
+ this.log('Your Discord Bot ' + this.answers.botName + ' has been created!');
102
+ });
103
+ }
104
+ end() {
105
+ return __awaiter(this, void 0, void 0, function* () {
106
+ const answer = yield this.prompt({
107
+ type: 'list',
108
+ name: 'openWithCode',
109
+ message: 'Do you want to open your Discord Bot with Visual Studio Code?',
110
+ choices: [
111
+ {
112
+ name: 'open with `code`',
113
+ value: true
114
+ },
115
+ {
116
+ name: 'skip',
117
+ value: false
118
+ }
119
+ ]
120
+ });
121
+ this.log('');
122
+ if (answer && answer.openWithCode) {
123
+ this.spawnCommand('code', [this.destinationPath(USER_DIR, this.answers.botName)]);
124
+ }
125
+ });
126
+ }
127
+ }
128
+ exports.default = DiscordGenerator;
129
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,wEAAyC;AACzC,gDAAwB;AAGxB,MAAM,YAAY,GAAG,eAAe,CAAC;AACrC,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,MAAM,KAAK,GAAG,KAAK,CAAC;AAEpB,MAAM,QAAQ,GAAG,UAAU,CAAC;AAC5B,MAAM,SAAS,GAAG,WA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IC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "generator-discord",
3
3
  "displayName": "Generator-Discord",
4
- "version": "1.1.7",
4
+ "version": "1.2.1",
5
5
  "main": "./app/index.js",
6
6
  "description": "Yeoman generator for Discord.js",
7
7
  "keywords": [
@@ -14,7 +14,6 @@
14
14
  "build": "tsc",
15
15
  "watch": "tsc -w",
16
16
  "test": "vitest run",
17
- "publish": "npm run build && npm publish",
18
17
  "debug": "npx --node-arg=--inspect yo discord"
19
18
  },
20
19
  "files": [
@@ -8,6 +8,6 @@
8
8
  "start": "node ./src/index.js"
9
9
  },
10
10
  "dependencies": {
11
- "discord.js": "^13.13.1"
11
+ "discord.js": "^14.12.1",
12
12
  }
13
13
  }
@@ -1,8 +1,8 @@
1
- const { Client, Intents } = require('discord.js');
1
+ const { Client, GatewayIntentBits } = require('discord.js');
2
2
  const { token } = require('../config.json');
3
3
 
4
4
  // Create a new client instance with Intents that specify which privileged intents your bot requires
5
- const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
5
+ const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] });
6
6
  const prefix = '!';
7
7
 
8
8
  // Run this code when the client is ready. This event will only trigger one time after logging in
@@ -10,7 +10,7 @@
10
10
  "build": "tsc"
11
11
  },
12
12
  "dependencies": {
13
- "discord.js": "^13.13.1",
14
- "typescript": "^4.9.5"
13
+ "discord.js": "^14.12.1",
14
+ "typescript": "^5.1.6"
15
15
  }
16
16
  }
@@ -1,8 +1,8 @@
1
- import { Client, Intents } from 'discord.js';
1
+ import { Client, GatewayIntentBits } from 'discord.js';
2
2
  import { token } from '../config.json';
3
3
 
4
4
  // Create a new client instance with Intents that specify which privileged intents your bot requires
5
- const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
5
+ const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] });
6
6
  const prefix = '!';
7
7
 
8
8
  // Run this code when the client is ready. This event will only trigger one time after logging in