@pikokr/command.ts 5.0.0-dev.a0bc517 → 5.0.0-dev.d04bd18
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/dist/index.d.ts +114 -33
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
- package/publish-version.js +10 -0
- package/scripts/docs.ts +8 -8
- package/src/applicationCommand/ApplicationCommand.ts +14 -18
- package/src/applicationCommand/ApplicationCommandExtension.ts +169 -0
- package/src/applicationCommand/ApplicationCommandOption.ts +9 -2
- package/src/applicationCommand/index.ts +8 -0
- package/src/core/components/BaseComponent.ts +36 -14
- package/src/core/components/ComponentArgument.ts +8 -0
- package/src/core/components/ComponentArgumentDecorator.ts +8 -0
- package/src/core/components/decoratorCreator.ts +17 -3
- package/src/core/components/index.ts +13 -3
- package/src/core/converter/index.ts +16 -0
- package/src/core/extensions/CTSExtension.ts +17 -0
- package/src/core/extensions/Extension.ts +62 -0
- package/src/core/extensions/index.ts +9 -0
- package/src/core/hooks/componentHook.ts +40 -0
- package/src/core/hooks/index.ts +11 -1
- package/src/core/hooks/moduleHook.ts +11 -3
- package/src/core/index.ts +13 -1
- package/src/core/listener/index.ts +22 -2
- package/src/core/structures/CommandClient.ts +61 -4
- package/src/core/structures/Registry.ts +29 -5
- package/src/core/structures/index.ts +8 -0
- package/src/core/symbols.ts +13 -4
- package/src/core/utils/checks.ts +27 -0
- package/src/core/utils/errors.ts +9 -0
- package/src/core/utils/index.ts +10 -0
- package/src/index.ts +11 -10
- package/src/textCommand/TextCommand.ts +11 -0
- package/src/textCommand/index.ts +1 -0
- package/test/index.ts +40 -26
- package/tsconfig.prod.json +1 -0
- package/tsup.config.ts +8 -8
package/src/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
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'
|
|
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'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createComponentDecorator } from '../core/components/decoratorCreator'
|
|
2
|
+
import { BaseComponent } from '../core/components/BaseComponent'
|
|
3
|
+
|
|
4
|
+
type TextCommandOptions = {
|
|
5
|
+
name: string
|
|
6
|
+
description?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class TextCommandComponent extends BaseComponent<TextCommandOptions> {}
|
|
10
|
+
|
|
11
|
+
export const command = createComponentDecorator(TextCommandComponent)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TextCommand'
|
package/test/index.ts
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
*/
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
import { ApplicationCommandOptionType, ApplicationCommandType, ChatInputCommandInteraction, Client } from 'discord.js'
|
|
10
|
+
import { applicationCommand, CommandClient, moduleHook, option, ownerOnly, listener, Extension } from '../dist'
|
|
11
|
+
import 'dotenv/config'
|
|
12
|
+
import { Logger } from 'tslog'
|
|
13
|
+
import chalk from 'chalk'
|
|
14
|
+
|
|
15
|
+
class Test extends Extension {
|
|
6
16
|
@applicationCommand({
|
|
17
|
+
type: ApplicationCommandType.ChatInput,
|
|
7
18
|
name: 'test',
|
|
8
19
|
description: 'wow this is test',
|
|
9
20
|
})
|
|
10
|
-
async testCommand(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
description: '와아',
|
|
14
|
-
type: ApplicationCommandOptionType.String,
|
|
15
|
-
})
|
|
16
|
-
hello: string,
|
|
17
|
-
world: string,
|
|
18
|
-
) {}
|
|
21
|
+
async testCommand(i: ChatInputCommandInteraction) {
|
|
22
|
+
i.reply('Wow')
|
|
23
|
+
}
|
|
19
24
|
|
|
25
|
+
@ownerOnly
|
|
20
26
|
@applicationCommand({
|
|
27
|
+
type: ApplicationCommandType.ChatInput,
|
|
21
28
|
name: 'test2',
|
|
22
29
|
description: 'wow this is test wow',
|
|
23
30
|
})
|
|
@@ -26,23 +33,28 @@ class Test {
|
|
|
26
33
|
name: 'sans',
|
|
27
34
|
description: '와',
|
|
28
35
|
type: ApplicationCommandOptionType.String,
|
|
36
|
+
required: true,
|
|
29
37
|
})
|
|
30
38
|
wa: string,
|
|
31
|
-
|
|
39
|
+
i: ChatInputCommandInteraction,
|
|
40
|
+
) {
|
|
41
|
+
i.reply(wa)
|
|
42
|
+
}
|
|
32
43
|
|
|
33
44
|
@moduleHook('load')
|
|
34
45
|
load() {
|
|
35
|
-
|
|
46
|
+
this.logger.info('Load')
|
|
36
47
|
}
|
|
37
48
|
|
|
38
49
|
@moduleHook('unload')
|
|
39
50
|
unload() {
|
|
40
|
-
|
|
51
|
+
this.logger.info('Unload')
|
|
41
52
|
}
|
|
42
53
|
|
|
43
|
-
@listener({ event: '
|
|
44
|
-
testEvent() {
|
|
45
|
-
|
|
54
|
+
@listener({ event: 'ready' })
|
|
55
|
+
async testEvent() {
|
|
56
|
+
this.logger.info(`Login: ${chalk.green(client.user!.tag)}`)
|
|
57
|
+
await this.commandClient.fetchOwners()
|
|
46
58
|
}
|
|
47
59
|
}
|
|
48
60
|
|
|
@@ -50,20 +62,22 @@ const ext = new Test()
|
|
|
50
62
|
|
|
51
63
|
const client = new Client({ intents: [] })
|
|
52
64
|
|
|
53
|
-
const
|
|
65
|
+
const logger = new Logger({ dateTimeTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone })
|
|
66
|
+
|
|
67
|
+
const cc = new CommandClient(client, logger)
|
|
54
68
|
|
|
55
69
|
const registry = cc.registry
|
|
56
70
|
|
|
57
71
|
const run = async () => {
|
|
58
|
-
await
|
|
72
|
+
await cc.enableApplicationCommandsExtension({
|
|
73
|
+
guilds: ['832938554438844438'],
|
|
74
|
+
})
|
|
59
75
|
|
|
60
|
-
|
|
61
|
-
client.emit('test')
|
|
76
|
+
await registry.registerModule(ext)
|
|
62
77
|
|
|
63
|
-
await
|
|
78
|
+
await client.login(process.env.TOKEN)
|
|
64
79
|
|
|
65
|
-
|
|
66
|
-
client.emit('test')
|
|
80
|
+
await cc.getApplicationCommandsExtension()!.sync()
|
|
67
81
|
}
|
|
68
82
|
|
|
69
83
|
run()
|
package/tsconfig.prod.json
CHANGED
package/tsup.config.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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({
|