@pikokr/command.ts 5.5.0 → 5.6.0-dev.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. package/.eslintrc.js +19 -0
  2. package/.github/workflows/docs.yml +22 -6
  3. package/.github/workflows/lint.yml +41 -0
  4. package/.github/workflows/release.yml +49 -0
  5. package/.vscode/settings.json +6 -3
  6. package/dist/index.d.ts +48 -46
  7. package/dist/index.js +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/package.json +20 -3
  10. package/publish-version.js +1 -23
  11. package/scripts/docs.ts +8 -8
  12. package/src/applicationCommand/ApplicationCommand.ts +1 -9
  13. package/src/applicationCommand/ApplicationCommandExtension.ts +14 -17
  14. package/src/applicationCommand/ApplicationCommandOption.ts +1 -9
  15. package/src/applicationCommand/group.ts +2 -1
  16. package/src/applicationCommand/index.ts +4 -12
  17. package/src/core/components/BaseComponent.ts +3 -11
  18. package/src/core/components/ComponentArgument.ts +1 -9
  19. package/src/core/components/ComponentArgumentDecorator.ts +0 -8
  20. package/src/core/components/decoratorCreator.ts +4 -12
  21. package/src/core/components/index.ts +5 -13
  22. package/src/core/converter/index.ts +8 -15
  23. package/src/core/extensions/CTSExtension.ts +0 -8
  24. package/src/core/extensions/Extension.ts +5 -13
  25. package/src/core/extensions/index.ts +0 -8
  26. package/src/core/hooks/componentHook.ts +4 -11
  27. package/src/core/hooks/index.ts +3 -11
  28. package/src/core/hooks/moduleHook.ts +2 -9
  29. package/src/core/index.ts +0 -8
  30. package/src/core/listener/index.ts +0 -8
  31. package/src/core/structures/CommandClient.ts +7 -12
  32. package/src/core/structures/Registry.ts +8 -16
  33. package/src/core/structures/index.ts +0 -8
  34. package/src/core/symbols.ts +6 -14
  35. package/src/core/utils/checks.ts +5 -12
  36. package/src/core/utils/errors.ts +0 -8
  37. package/src/core/utils/index.ts +3 -11
  38. package/src/index.ts +3 -11
  39. package/src/textCommand/TextCommand.ts +0 -8
  40. package/src/textCommand/TextCommandExtension.ts +11 -32
  41. package/src/textCommand/index.ts +0 -8
  42. package/src/textCommand/parameters.ts +6 -14
  43. package/src/utils/types.ts +1 -0
  44. package/test/index.ts +5 -4
  45. package/tsup.config.ts +8 -8
  46. package/.github/workflows/publish.stable.yml +0 -18
  47. package/.github/workflows/publish.yml +0 -20
  48. package/.yarn/releases/yarn-3.2.3.cjs +0 -783
  49. package/.yarn/sdks/integrations.yml +0 -5
  50. package/.yarn/sdks/prettier/index.js +0 -20
  51. package/.yarn/sdks/prettier/package.json +0 -6
  52. package/.yarn/sdks/typescript/bin/tsc +0 -20
  53. package/.yarn/sdks/typescript/bin/tsserver +0 -20
  54. package/.yarn/sdks/typescript/lib/tsc.js +0 -20
  55. package/.yarn/sdks/typescript/lib/tsserver.js +0 -196
  56. package/.yarn/sdks/typescript/lib/tsserverlibrary.js +0 -196
  57. package/.yarn/sdks/typescript/lib/typescript.js +0 -20
  58. package/.yarn/sdks/typescript/package.json +0 -6
  59. package/.yarnrc.yml +0 -1
@@ -1,11 +1,3 @@
1
- /*
2
- * File: ComponentArgumentDecorator.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  import _ from 'lodash'
10
2
 
11
3
  export class ComponentArgumentDecorator<Options = unknown> {
@@ -1,17 +1,9 @@
1
- /*
2
- * File: decoratorCreator.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  import { Collection } from 'discord.js'
10
- import { ComponentHookStore } from '../hooks'
2
+ import type { ComponentHookStore } from '../hooks'
11
3
  import { getComponentHookStore } from '../hooks/componentHook'
12
4
  import { ComponentStoreSymbol } from '../symbols'
13
- import { BaseComponent } from './BaseComponent'
14
- import { ComponentArgumentDecorator } from './ComponentArgumentDecorator'
5
+ import type { BaseComponent } from './BaseComponent'
6
+ import type { ComponentArgumentDecorator } from './ComponentArgumentDecorator'
15
7
 
16
8
  export type ComponentStore = Collection<string | symbol, BaseComponent>
17
9
  export type ComponentArgumentStore = Collection<number, ComponentArgumentDecorator>
@@ -69,7 +61,7 @@ export const getComponentArgumentStore = (target: object, key: string | symbol):
69
61
  export const createArgumentDecorator = <Options>(type: typeof ComponentArgumentDecorator<Options>) => {
70
62
  return (options: Options): ParameterDecorator => {
71
63
  return (target, key, idx) => {
72
- var arg: ComponentArgumentDecorator<Options> = new type(options)
64
+ const arg: ComponentArgumentDecorator<Options> = new type(options)
73
65
 
74
66
  const store = getComponentArgumentStore(target, key)
75
67
 
@@ -1,13 +1,5 @@
1
- /*
2
- * File: index.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
- import 'reflect-metadata'
10
- export * from './decoratorCreator'
11
- export * from './ComponentArgument'
12
- export * from './ComponentArgumentDecorator'
13
- export * from './BaseComponent'
1
+ import 'reflect-metadata'
2
+ export * from './decoratorCreator'
3
+ export * from './ComponentArgument'
4
+ export * from './ComponentArgumentDecorator'
5
+ export * from './BaseComponent'
@@ -1,27 +1,20 @@
1
- /*
2
- * File: index.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  import { BaseComponent } from '../components/BaseComponent'
10
2
  import { createComponentDecorator } from '../components/decoratorCreator'
11
3
 
12
- type Options = { component: unknown; type: Function; parameterless: boolean }
4
+ type Options<T> = { component: unknown; type: T; parameterless: boolean }
13
5
 
14
- type OptionsArg = Omit<Options, 'parameterless'> & { parameterless?: boolean }
6
+ type OptionsArg<T> = Omit<Options<T>, 'parameterless'> & { parameterless?: boolean }
15
7
 
16
- export class ConverterComponent extends BaseComponent {
17
- options: Options
8
+ export class ConverterComponent<T> extends BaseComponent {
9
+ options: Options<T>
18
10
 
19
- constructor(options: OptionsArg) {
11
+ constructor(options: OptionsArg<T>) {
20
12
  super()
21
- this.options = options as Options
13
+ this.options = options as Options<T>
22
14
  }
23
15
  }
24
16
 
25
- export const argConverter = (options: OptionsArg) => createComponentDecorator(new ConverterComponent(options))
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ export const argConverter = <T>(options: OptionsArg<T>) => createComponentDecorator(new ConverterComponent(options))
26
19
 
27
20
  export { Options as ArgumentConvertOptions, OptionsArg as ArgumentConvertOptionsArg }
@@ -1,11 +1,3 @@
1
- /*
2
- * File: CTSExtension.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  import chalk from 'chalk'
10
2
  import { Extension } from './Extension'
11
3
 
@@ -1,15 +1,7 @@
1
- /*
2
- * File: Extension.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  import chalk from 'chalk'
10
2
  import { Collection } from 'discord.js'
11
- import { Logger } from 'tslog'
12
- import { ComponentArgument } from '../components/ComponentArgument'
3
+ import type { Logger } from 'tslog'
4
+ import type { ComponentArgument } from '../components/ComponentArgument'
13
5
  import { ConverterComponent } from '../converter'
14
6
  import { CommandClient } from '../structures'
15
7
 
@@ -33,12 +25,12 @@ export class Extension {
33
25
  component: unknown,
34
26
  argList: unknown[],
35
27
  args: Collection<number, ComponentArgument>,
36
- getConverterArgs: (arg: ComponentArgument, index: number, converter: ConverterComponent) => unknown[] | Promise<unknown[]>,
28
+ getConverterArgs: (arg: ComponentArgument, index: number, converter: ConverterComponent<unknown>) => unknown[] | Promise<unknown[]>,
37
29
  ) {
38
- const items = new Collection<unknown, { ext: object; component: ConverterComponent }>()
30
+ const items = new Collection<unknown, { ext: object; component: ConverterComponent<unknown> }>()
39
31
 
40
32
  for (const extension of this.commandClient.registry.extensions) {
41
- for (const converter of this.commandClient.registry.getComponentsWithType<ConverterComponent>(extension, ConverterComponent)) {
33
+ for (const converter of this.commandClient.registry.getComponentsWithType<ConverterComponent<unknown>>(extension, ConverterComponent)) {
42
34
  if (converter.options.component != component) continue
43
35
 
44
36
  items.set(converter.options.type, { component: converter, ext: extension })
@@ -1,9 +1 @@
1
- /*
2
- * File: index.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  export * from './Extension'
@@ -1,17 +1,9 @@
1
- /*
2
- * File: componentHook.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  import { Collection } from 'discord.js'
10
2
  import { ComponentHookSymbol } from '../symbols'
11
3
 
12
- export type ComponentHookFn = (...args: any[]) => void | Promise<void>
4
+ export type ComponentHookFn<T extends unknown[]> = (...args: T) => void | Promise<void>
13
5
 
14
- export type ComponentHookStore = Collection<string, ComponentHookFn[]>
6
+ export type ComponentHookStore = Collection<string, ComponentHookFn<unknown[]>[]>
15
7
 
16
8
  export const getComponentHookStore = (target: object, property: string | symbol): ComponentHookStore => {
17
9
  let data = Reflect.getMetadata(ComponentHookSymbol, target, property) as ComponentHookStore
@@ -24,7 +16,7 @@ export const getComponentHookStore = (target: object, property: string | symbol)
24
16
  return data
25
17
  }
26
18
 
27
- export const createComponentHook = (name: string, fn: ComponentHookFn): MethodDecorator => {
19
+ export const createComponentHook = <T extends unknown[]>(name: string, fn: ComponentHookFn<T>): MethodDecorator => {
28
20
  return (target, key) => {
29
21
  const store = getComponentHookStore(target, key)
30
22
 
@@ -35,6 +27,7 @@ export const createComponentHook = (name: string, fn: ComponentHookFn): MethodDe
35
27
  store.set(name, hooks)
36
28
  }
37
29
 
30
+ // @ts-expect-error unknown type
38
31
  hooks.unshift(fn)
39
32
  }
40
33
  }
@@ -1,11 +1,3 @@
1
- /*
2
- * File: index.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
- export * from './moduleHook'
10
- export { createComponentHook, type ComponentHookFn } from './componentHook'
11
- export type { ComponentHookStore } from './componentHook'
1
+ export * from './moduleHook'
2
+ export { createComponentHook, type ComponentHookFn } from './componentHook'
3
+ export type { ComponentHookStore } from './componentHook'
@@ -1,15 +1,8 @@
1
- /*
2
- * File: moduleHook.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  import { Collection } from 'discord.js'
10
2
  import { ModuleHookStoreSymbol } from '../symbols'
3
+ import type { ComponentHookFn } from './componentHook'
11
4
 
12
- export type ModuleHookStore = Collection<string, Function[]>
5
+ export type ModuleHookStore = Collection<string, ComponentHookFn<unknown[]>[]>
13
6
 
14
7
  export const getModuleHookStore = (target: object) => {
15
8
  let result: ModuleHookStore | null = Reflect.getMetadata(ModuleHookStoreSymbol, target)
package/src/core/index.ts CHANGED
@@ -1,11 +1,3 @@
1
- /*
2
- * File: index.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  export * from './components'
10
2
  export * from './hooks'
11
3
  export * from './converter'
@@ -1,11 +1,3 @@
1
- /*
2
- * File: index.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  import _ from 'lodash'
10
2
  import { BaseComponent } from '../components/BaseComponent'
11
3
  import { createComponentDecorator } from '../components/decoratorCreator'
@@ -1,17 +1,12 @@
1
- /*
2
- * File: CommandClient.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  import chalk from 'chalk'
10
- import { Client, Snowflake, Team, User } from 'discord.js'
2
+ import type { Client, Snowflake } from 'discord.js'
3
+ import { Team, User } from 'discord.js'
11
4
  import EventEmitter from 'events'
12
- import { ISettingsParam, Logger } from 'tslog'
13
- import { ApplicationCommandExtension, ApplicationCommandExtensionConfig } from '../../applicationCommand/ApplicationCommandExtension'
14
- import { TextCommandConfig } from '../../textCommand'
5
+ import type { ISettingsParam } from 'tslog'
6
+ import { Logger } from 'tslog'
7
+ import type { ApplicationCommandExtensionConfig } from '../../applicationCommand/ApplicationCommandExtension'
8
+ import { ApplicationCommandExtension } from '../../applicationCommand/ApplicationCommandExtension'
9
+ import type { TextCommandConfig } from '../../textCommand'
15
10
  import { TextCommandExtension } from '../../textCommand/TextCommandExtension'
16
11
  import { CommandClientSymbol } from '../symbols'
17
12
  import { Registry } from './Registry'
@@ -1,24 +1,16 @@
1
- /*
2
- * File: Registry.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  import chalk from 'chalk'
10
2
  import { Collection } from 'discord.js'
11
- import EventEmitter from 'events'
12
- import _, { result } from 'lodash'
13
- import { Logger } from 'tslog'
3
+ import type EventEmitter from 'events'
4
+ import _ from 'lodash'
5
+ import type { Logger } from 'tslog'
14
6
  import { getComponentStore } from '../components'
15
7
  import { getModuleHookStore } from '../hooks'
16
8
  import { ListenerComponent } from '../listener'
17
9
  import { CommandClientSymbol, FilePathSymbol } from '../symbols'
18
- import { CommandClient } from './CommandClient'
10
+ import type { CommandClient } from './CommandClient'
19
11
  import walkSync from 'walk-sync'
20
12
  import path from 'path'
21
- import { ComponentHookFn } from '../hooks/componentHook'
13
+ import type { ComponentHookFn } from '../hooks/componentHook'
22
14
 
23
15
  export class Registry {
24
16
  extensions: object[] = []
@@ -27,7 +19,7 @@ export class Registry {
27
19
 
28
20
  logger: Logger<unknown>
29
21
 
30
- globalHooks: Record<string, ComponentHookFn[]> = {}
22
+ globalHooks: Record<string, ComponentHookFn<unknown[]>[]> = {}
31
23
 
32
24
  constructor(logger: Logger<unknown>, public client: CommandClient) {
33
25
  this.logger = logger.getSubLogger({
@@ -35,7 +27,7 @@ export class Registry {
35
27
  })
36
28
  }
37
29
 
38
- addGlobalHook(name: string, fn: ComponentHookFn) {
30
+ addGlobalHook(name: string, fn: ComponentHookFn<unknown[]>) {
39
31
  let hooks = this.globalHooks[name]
40
32
 
41
33
  if (!hooks) {
@@ -110,7 +102,7 @@ export class Registry {
110
102
 
111
103
  const p = require.resolve(file)
112
104
 
113
- const mod = require(p)
105
+ const mod = await import(p)
114
106
 
115
107
  if (typeof mod.setup !== 'function') throw new Error('Extension must have a setup function')
116
108
 
@@ -1,10 +1,2 @@
1
- /*
2
- * File: index.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  export * from './Registry'
10
2
  export * from './CommandClient'
@@ -1,14 +1,6 @@
1
- /*
2
- * File: symbols.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
- export const ComponentStoreSymbol = Symbol()
10
- export const ComponentArgStoreSymbol = Symbol()
11
- export const ModuleHookStoreSymbol = Symbol()
12
- export const CommandClientSymbol = Symbol()
13
- export const ComponentHookSymbol = Symbol()
14
- export const FilePathSymbol = Symbol()
1
+ export const ComponentStoreSymbol = Symbol()
2
+ export const ComponentArgStoreSymbol = Symbol()
3
+ export const ModuleHookStoreSymbol = Symbol()
4
+ export const CommandClientSymbol = Symbol()
5
+ export const ComponentHookSymbol = Symbol()
6
+ export const FilePathSymbol = Symbol()
@@ -1,18 +1,11 @@
1
- /*
2
- * File: checks.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
- import { BaseInteraction, Interaction, Message } from 'discord.js'
1
+ import type { Interaction } from 'discord.js'
2
+ import { BaseInteraction, Message } from 'discord.js'
10
3
  import { createComponentHook } from '../hooks'
11
- import { ComponentHookFn } from '../hooks/componentHook'
12
- import { CommandClient } from '../structures'
4
+ import type { ComponentHookFn } from '../hooks/componentHook'
5
+ import type { CommandClient } from '../structures'
13
6
  import { OwnerOnlyError } from './errors'
14
7
 
15
- export const createCheckDecorator = (fn: ComponentHookFn) => createComponentHook('beforeCall', fn)
8
+ export const createCheckDecorator = (fn: ComponentHookFn<[CommandClient, Interaction | Message]>) => createComponentHook('beforeCall', fn)
16
9
 
17
10
  export const ownerOnly = createCheckDecorator(async (client: CommandClient, i: Interaction | Message) => {
18
11
  let isOwner = false
@@ -1,9 +1 @@
1
- /*
2
- * File: errors.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  export class OwnerOnlyError {}
@@ -1,11 +1,3 @@
1
- /*
2
- * File: index.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
- export * from './checks'
10
- export * from './errors'
11
- export * from './decorators'
1
+ export * from './checks'
2
+ export * from './errors'
3
+ export * from './decorators'
package/src/index.ts CHANGED
@@ -1,11 +1,3 @@
1
- /*
2
- * File: index.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
- export * from './core'
10
- export * from './applicationCommand'
11
- export * from './textCommand'
1
+ export * from './core'
2
+ export * from './applicationCommand'
3
+ export * from './textCommand'
@@ -1,11 +1,3 @@
1
- /*
2
- * File: TextCommand.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  import { createComponentDecorator } from '../core/components/decoratorCreator'
10
2
  import { BaseComponent } from '../core/components/BaseComponent'
11
3
 
@@ -1,11 +1,3 @@
1
- /*
2
- * File: TextCommandExtension.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  import { listener } from '../core/listener'
10
2
  import { Message } from 'discord.js'
11
3
  import { CTSExtension } from '../core/extensions/CTSExtension'
@@ -14,10 +6,7 @@ import { TextCommandRestOption } from './parameters'
14
6
  import { argConverter } from '../core'
15
7
 
16
8
  export type TextCommandConfig = {
17
- prefix:
18
- | string
19
- | string[]
20
- | ((msg: Message) => Promise<string | string[]> | string | string[])
9
+ prefix: string | string[] | ((msg: Message) => Promise<string | string[]> | string | string[])
21
10
  }
22
11
 
23
12
  declare module 'discord.js' {
@@ -68,10 +57,7 @@ export class TextCommandExtension extends CTSExtension {
68
57
  const extensions = new Map<TextCommandComponent, object>()
69
58
 
70
59
  for (const ext of this.commandClient.registry.extensions) {
71
- for (const cmd of this.commandClient.registry.getComponentsWithType<TextCommandComponent>(
72
- ext,
73
- TextCommandComponent
74
- )) {
60
+ for (const cmd of this.commandClient.registry.getComponentsWithType<TextCommandComponent>(ext, TextCommandComponent)) {
75
61
  commands.push(cmd)
76
62
  extensions.set(cmd, ext)
77
63
  }
@@ -112,23 +98,16 @@ export class TextCommandExtension extends CTSExtension {
112
98
 
113
99
  let argStrings = content.slice(commandNameLength + 1).split(/ /g)
114
100
 
115
- await this.convertArguments(
116
- TextCommandComponent,
117
- args,
118
- command.argTypes,
119
- async (arg, i, converter) => {
120
- if (converter.options.parameterless) return [msg]
121
-
122
- if (
123
- arg.decorators.find((x) => x.constructor === TextCommandRestOption)
124
- ) {
125
- const text = argStrings.join(' ')
126
- argStrings = []
127
- return [text, msg]
128
- }
129
- return [argStrings.shift(), msg]
101
+ await this.convertArguments(TextCommandComponent, args, command.argTypes, async (arg, i, converter) => {
102
+ if (converter.options.parameterless) return [msg]
103
+
104
+ if (arg.decorators.find((x) => x.constructor === TextCommandRestOption)) {
105
+ const text = argStrings.join(' ')
106
+ argStrings = []
107
+ return [text, msg]
130
108
  }
131
- )
109
+ return [argStrings.shift(), msg]
110
+ })
132
111
 
133
112
  await command.execute(ext, args, [msg])
134
113
  } catch (e) {
@@ -1,11 +1,3 @@
1
- /*
2
- * File: index.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
1
  export * from './TextCommand'
10
2
  export type { TextCommandConfig } from './TextCommandExtension'
11
3
  export * from './parameters'
@@ -1,14 +1,6 @@
1
- /*
2
- * File: parameters.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
9
- import { ComponentArgumentDecorator } from '../core'
10
- import { createArgumentDecorator } from '../core'
11
-
12
- export class TextCommandRestOption extends ComponentArgumentDecorator<void> {}
13
-
14
- export const rest = createArgumentDecorator(TextCommandRestOption)
1
+ import { ComponentArgumentDecorator } from '../core'
2
+ import { createArgumentDecorator } from '../core'
3
+
4
+ export class TextCommandRestOption extends ComponentArgumentDecorator<void> {}
5
+
6
+ export const rest = createArgumentDecorator(TextCommandRestOption)
@@ -0,0 +1 @@
1
+ export type AnyFunction = (...args: unknown[]) => unknown
package/test/index.ts CHANGED
@@ -6,7 +6,8 @@
6
6
  * Licensed under MIT License. Please see more defails in LICENSE file.
7
7
  */
8
8
 
9
- import { ApplicationCommandOptionType, ApplicationCommandType, ChatInputCommandInteraction, Client, Message } from 'discord.js'
9
+ import type { ChatInputCommandInteraction, Message } from 'discord.js'
10
+ import { ApplicationCommandOptionType, ApplicationCommandType, Client } from 'discord.js'
10
11
  import { applicationCommand, CommandClient, moduleHook, option, ownerOnly, listener, Extension, command, rest, SubCommandGroup } from '../src'
11
12
  import 'dotenv/config'
12
13
  import { Logger } from 'tslog'
@@ -70,7 +71,7 @@ class Test extends Extension {
70
71
 
71
72
  @listener({ event: 'ready' })
72
73
  async testEvent() {
73
- this.logger.info(`Login: ${chalk.green(client.user!.tag)}`)
74
+ this.logger.info(`Login: ${chalk.green(client.user?.tag ?? 'Unknown')}`)
74
75
  await this.commandClient.fetchOwners()
75
76
  }
76
77
 
@@ -85,7 +86,7 @@ const ext = new Test()
85
86
 
86
87
  const client = new Client({ intents: ['GuildMessages', 'MessageContent', 'DirectMessages', 'Guilds'] })
87
88
 
88
- const logger = new Logger({ })
89
+ const logger = new Logger({})
89
90
 
90
91
  const cc = new CommandClient(client, logger)
91
92
 
@@ -106,7 +107,7 @@ const run = async () => {
106
107
 
107
108
  await client.application?.commands.set([])
108
109
 
109
- await cc.getApplicationCommandsExtension()!.sync()
110
+ await cc.getApplicationCommandsExtension()?.sync()
110
111
  }
111
112
 
112
113
  run()
package/tsup.config.ts CHANGED
@@ -1,11 +1,11 @@
1
- /*
2
- * File: tsup.config.ts
3
- *
4
- * Copyright (c) 2022-2022 pikokr
5
- *
6
- * Licensed under MIT License. Please see more defails in LICENSE file.
7
- */
8
-
1
+ /*
2
+ * File: tsup.config.ts
3
+ *
4
+ * Copyright (c) 2022-2022 pikokr
5
+ *
6
+ * Licensed under MIT License. Please see more defails in LICENSE file.
7
+ */
8
+
9
9
  import { defineConfig } from 'tsup'
10
10
 
11
11
  export default defineConfig({
@@ -1,18 +0,0 @@
1
- on:
2
- push:
3
- branches:
4
- - stable
5
-
6
- jobs:
7
- publish:
8
- runs-on: ubuntu-latest
9
- if: "!contains(github.event.head_commit.message, '[skip ci]')"
10
- steps:
11
- - uses: actions/checkout@v3
12
- - uses: actions/setup-node@v3
13
- with:
14
- node-version: 16.16
15
- - run: yarn
16
- - uses: JS-DevTools/npm-publish@v1
17
- with:
18
- token: ${{ secrets.NPM_TOKEN }}
@@ -1,20 +0,0 @@
1
- on:
2
- push:
3
- branches:
4
- - dev
5
-
6
- jobs:
7
- publish:
8
- runs-on: ubuntu-latest
9
- if: "!contains(github.event.head_commit.message, '[skip ci]')"
10
- steps:
11
- - uses: actions/checkout@v3
12
- - uses: actions/setup-node@v3
13
- with:
14
- node-version: 16.16
15
- - run: yarn
16
- - run: COMMIT_ID=$(git rev-parse --short HEAD) node publish-version.js
17
- - uses: JS-DevTools/npm-publish@v1
18
- with:
19
- token: ${{ secrets.NPM_TOKEN }}
20
- tag: dev