@pikokr/command.ts 3.0.2 → 3.0.3

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.
@@ -40,7 +40,6 @@ const discord_js_1 = require("discord.js");
40
40
  const walk_sync_1 = __importDefault(require("walk-sync"));
41
41
  const v9_1 = require("discord-api-types/v9");
42
42
  const fs = __importStar(require("fs"));
43
- const BuiltInModule_1 = require("../builtinModules/BuiltInModule");
44
43
  class Registry {
45
44
  constructor(client) {
46
45
  this.client = client;
@@ -183,12 +182,12 @@ class Registry {
183
182
  reloadAll() {
184
183
  return __awaiter(this, void 0, void 0, function* () {
185
184
  const results = [];
186
- for (const [, module] of this.modules.filter((x) => !!x.path || !(x instanceof BuiltInModule_1.BuiltInModule))) {
185
+ for (const [, module] of this.modules.filter((x) => !!x.path && !Reflect.getMetadata(constants_1.KBuiltInModule, x))) {
187
186
  try {
188
187
  yield this.reloadModule(module);
189
188
  results.push({
190
189
  path: module.path,
191
- success: false,
190
+ success: true,
192
191
  });
193
192
  }
194
193
  catch (e) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pikokr/command.ts",
3
3
  "description": "Discord.js command framework for typescript.",
4
- "version": "3.0.2",
4
+ "version": "3.0.3",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "MIT",
@@ -10,7 +10,6 @@ import { ArgumentConverter } from '../command'
10
10
  import { SlashCommand } from '../slashCommand'
11
11
  import { Routes } from 'discord-api-types/v9'
12
12
  import * as fs from 'fs'
13
- import { BuiltInModule } from '../builtinModules/BuiltInModule'
14
13
 
15
14
  type ListenerExecutor = {
16
15
  event: string
@@ -180,12 +179,12 @@ export class Registry {
180
179
  error?: Error
181
180
  }[] = []
182
181
 
183
- for (const [, module] of this.modules.filter((x) => !!x.path || !(x instanceof BuiltInModule))) {
182
+ for (const [, module] of this.modules.filter((x) => !!x.path && !Reflect.getMetadata(KBuiltInModule, x))) {
184
183
  try {
185
184
  await this.reloadModule(module)
186
185
  results.push({
187
186
  path: module.path!,
188
- success: false,
187
+ success: true,
189
188
  })
190
189
  } catch (e: any) {
191
190
  results.push({
@@ -0,0 +1,25 @@
1
+ import { BuiltInModule, CommandClient, ownerOnly, slashCommand } from '../../src'
2
+ import { CommandInteraction } from 'discord.js'
3
+ import { SlashCommandBuilder } from '@discordjs/builders'
4
+
5
+ export class Dev extends BuiltInModule {
6
+ constructor(private cts: CommandClient) {
7
+ super()
8
+ }
9
+
10
+ @slashCommand({
11
+ command: new SlashCommandBuilder().setName('reload').setDescription('리로드 커맨드'),
12
+ })
13
+ @ownerOnly
14
+ async reload(i: CommandInteraction) {
15
+ const data = await this.cts.registry.reloadAll()
16
+ await i.reply({
17
+ ephemeral: true,
18
+ content: '```\n' + data.map((x) => (x.success ? `✅ ${x.path}` : `❌ ${x.path}\n${x.error}`)).join('\n') + '```',
19
+ })
20
+ }
21
+ }
22
+
23
+ export function install(cts: CommandClient) {
24
+ return new Dev(cts)
25
+ }