@pikokr/command.ts 4.0.6 → 5.0.0-dev.84d717c
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/.github/workflows/codeql-analysis.yml +70 -0
- package/.github/workflows/publish.stable.yml +1 -1
- package/.github/workflows/publish.yml +1 -1
- package/.vscode/settings.json +10 -0
- package/.vscode/templates/ts.lict +5 -0
- package/dist/index.d.ts +41 -307
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +13 -10
- package/publish-version.js +10 -0
- package/scripts/docs.ts +8 -4
- package/src/applicationCommand/ApplicationCommand.ts +17 -0
- package/src/applicationCommand/ApplicationCommandOption.ts +9 -0
- package/src/applicationCommand/index.ts +2 -6
- package/src/core/components/BaseComponent.ts +32 -0
- package/src/core/components/ComponentArgument.ts +7 -0
- package/src/core/components/ComponentArgumentDecorator.ts +17 -0
- package/src/core/components/decoratorCreator.ts +68 -0
- package/src/core/components/index.ts +3 -0
- package/src/core/hooks/index.ts +1 -0
- package/src/core/hooks/moduleHook.ts +31 -0
- package/src/core/index.ts +3 -0
- package/src/core/structures/Registry.ts +30 -0
- package/src/core/structures/index.ts +1 -0
- package/src/core/symbols.ts +3 -0
- package/src/index.ts +10 -16
- package/test/index.ts +46 -23
- package/tsconfig.json +1 -1
- package/tsconfig.prod.json +4 -0
- package/tsup.config.ts +8 -4
- package/src/applicationCommand/AppCommand.ts +0 -32
- package/src/applicationCommand/decorator.ts +0 -62
- package/src/builtinModules/BuiltInModule.ts +0 -13
- package/src/builtinModules/BuiltinApplicationCommandConverters.ts +0 -16
- package/src/builtinModules/BuiltinCommandConverters.ts +0 -87
- package/src/builtinModules/CommandHandler.ts +0 -363
- package/src/builtinModules/index.ts +0 -7
- package/src/command/ArgumentConverter.ts +0 -22
- package/src/command/Command.ts +0 -35
- package/src/command/cooldown/adapter.ts +0 -22
- package/src/command/cooldown/decorator.ts +0 -67
- package/src/command/cooldown/error.ts +0 -9
- package/src/command/cooldown/index.ts +0 -9
- package/src/command/cooldown/type.ts +0 -12
- package/src/command/decorator.ts +0 -185
- package/src/command/index.ts +0 -9
- package/src/command/utils.ts +0 -33
- package/src/constants.ts +0 -31
- package/src/error/ArgumentConverterNotFound.ts +0 -18
- package/src/error/ArgumentNotProvided.ts +0 -12
- package/src/error/CommandCheckFailed.ts +0 -19
- package/src/error/CommandNotFound.ts +0 -11
- package/src/error/InvalidTargetError.ts +0 -9
- package/src/error/ModuleError.ts +0 -11
- package/src/error/PermissionRequired.ts +0 -17
- package/src/error/checks/DMOnlyCommand.ts +0 -9
- package/src/error/checks/GuildOnlyCommand.ts +0 -9
- package/src/error/checks/OwnerOnlyCommand.ts +0 -9
- package/src/error/checks/SlashCommandGlobalCheckError.ts +0 -11
- package/src/error/checks/index.ts +0 -8
- package/src/error/index.ts +0 -12
- package/src/interface/index.ts +0 -7
- package/src/listener/Listener.ts +0 -7
- package/src/listener/decorator.ts +0 -29
- package/src/listener/index.ts +0 -6
- package/src/messageComponents/base.ts +0 -16
- package/src/messageComponents/button.ts +0 -30
- package/src/messageComponents/index.ts +0 -6
- package/src/messageComponents/selectMenu.ts +0 -30
- package/src/structures/CommandClient.ts +0 -103
- package/src/structures/Module.ts +0 -54
- package/src/structures/Registry.ts +0 -253
- package/src/structures/index.ts +0 -7
- package/src/typings.ts +0 -35
- package/src/utils.ts +0 -10
- package/test/config.example.json +0 -3
- package/test/modules/dev.ts +0 -45
- package/test/modules/test.ts +0 -148
package/test/modules/test.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022 pikokr. Licensed under the MIT license
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { CommandClient, coolDown, CoolDownError, CoolDownType, listener, messageButton, messageSelectMenu, Module, option, applicationCommand } from '../../src'
|
|
6
|
-
import {
|
|
7
|
-
ButtonInteraction,
|
|
8
|
-
CommandInteraction,
|
|
9
|
-
ContextMenuInteraction,
|
|
10
|
-
Message,
|
|
11
|
-
MessageActionRow,
|
|
12
|
-
MessageButton,
|
|
13
|
-
MessageContextMenuInteraction,
|
|
14
|
-
MessageSelectMenu,
|
|
15
|
-
SelectMenuInteraction,
|
|
16
|
-
UserContextMenuInteraction,
|
|
17
|
-
} from 'discord.js'
|
|
18
|
-
|
|
19
|
-
class Test extends Module {
|
|
20
|
-
constructor(private client: CommandClient) {
|
|
21
|
-
super()
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// region lifetime method
|
|
25
|
-
load() {
|
|
26
|
-
console.log('load')
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
unload() {
|
|
30
|
-
console.log('unload')
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
beforeReload() {
|
|
34
|
-
console.log('before reload')
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
afterReload() {
|
|
38
|
-
console.log('after reload')
|
|
39
|
-
}
|
|
40
|
-
// endregion
|
|
41
|
-
|
|
42
|
-
@listener('ready')
|
|
43
|
-
ready() {
|
|
44
|
-
console.log(`Logged in as ${this.client.client.user!.tag}`)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@listener('commandError')
|
|
48
|
-
error(err: Error, msg: Message) {
|
|
49
|
-
if (err instanceof CoolDownError) {
|
|
50
|
-
return msg.reply(`쿨다운: <t:${(err.endsAt.getTime() / 1000).toFixed(0)}:R>`)
|
|
51
|
-
}
|
|
52
|
-
console.error(err)
|
|
53
|
-
}
|
|
54
|
-
@listener('applicationCommandError')
|
|
55
|
-
slashCommandError(err: Error, msg: CommandInteraction | ContextMenuInteraction) {
|
|
56
|
-
if (err instanceof CoolDownError) {
|
|
57
|
-
return msg.reply({
|
|
58
|
-
content: `쿨다운: <t:${(err.endsAt.getTime() / 1000).toFixed(0)}:R>`,
|
|
59
|
-
ephemeral: true,
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
console.error(err)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
@applicationCommand({
|
|
66
|
-
command: {
|
|
67
|
-
type: 'CHAT_INPUT',
|
|
68
|
-
name: 'test',
|
|
69
|
-
description: 'test',
|
|
70
|
-
options: [
|
|
71
|
-
{
|
|
72
|
-
type: 'STRING',
|
|
73
|
-
name: 'asdf',
|
|
74
|
-
description: 'test',
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
},
|
|
78
|
-
})
|
|
79
|
-
@coolDown(CoolDownType.USER, 10)
|
|
80
|
-
coolDownSlash(i: CommandInteraction, @option('asdf') asdf: string = 'wa sans') {
|
|
81
|
-
i.reply({
|
|
82
|
-
content: asdf,
|
|
83
|
-
components: [
|
|
84
|
-
new MessageActionRow().addComponents(new MessageButton().setLabel('test').setCustomId('testButton').setStyle('PRIMARY')),
|
|
85
|
-
new MessageActionRow().addComponents(
|
|
86
|
-
new MessageSelectMenu()
|
|
87
|
-
.setCustomId('testSelectMenu')
|
|
88
|
-
.setPlaceholder('test')
|
|
89
|
-
.setMinValues(1)
|
|
90
|
-
.setOptions(
|
|
91
|
-
new Array(10).fill(1).map((_, i) => ({
|
|
92
|
-
label: `${i}`,
|
|
93
|
-
value: `${i}`,
|
|
94
|
-
})),
|
|
95
|
-
),
|
|
96
|
-
),
|
|
97
|
-
],
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
@applicationCommand({
|
|
102
|
-
command: {
|
|
103
|
-
type: 'MESSAGE',
|
|
104
|
-
name: 'contextMenuTest',
|
|
105
|
-
defaultPermission: true,
|
|
106
|
-
},
|
|
107
|
-
})
|
|
108
|
-
@coolDown(CoolDownType.USER, 10)
|
|
109
|
-
async contextMenuMessage(i: MessageContextMenuInteraction) {
|
|
110
|
-
return i.reply({
|
|
111
|
-
content: `message id: ${i.targetMessage.id}`,
|
|
112
|
-
})
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
@applicationCommand({
|
|
116
|
-
command: {
|
|
117
|
-
type: 'USER',
|
|
118
|
-
name: 'contextMenuTest',
|
|
119
|
-
defaultPermission: true,
|
|
120
|
-
},
|
|
121
|
-
})
|
|
122
|
-
@coolDown(CoolDownType.USER, 10)
|
|
123
|
-
async contextMenuUser(i: UserContextMenuInteraction) {
|
|
124
|
-
return i.reply({
|
|
125
|
-
content: `user id: ${i.targetUser.id}`,
|
|
126
|
-
})
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
@messageButton('testButton')
|
|
130
|
-
async testButton(i: ButtonInteraction) {
|
|
131
|
-
await i.update({
|
|
132
|
-
content: 'test',
|
|
133
|
-
components: [],
|
|
134
|
-
})
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
@messageSelectMenu('testSelectMenu')
|
|
138
|
-
async testSelectMenu(i: SelectMenuInteraction) {
|
|
139
|
-
await i.update({
|
|
140
|
-
content: i.values.join(', '),
|
|
141
|
-
components: [],
|
|
142
|
-
})
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export function install(client: CommandClient) {
|
|
147
|
-
return new Test(client)
|
|
148
|
-
}
|