@pikokr/command.ts 3.2.4 → 4.0.0-dev.fddc66b
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/applicationCommand/AppCommand.d.ts +18 -0
- package/dist/applicationCommand/AppCommand.js +25 -0
- package/dist/applicationCommand/AppCommand.js.map +1 -0
- package/dist/applicationCommand/decorator.d.ts +10 -0
- package/dist/{slashCommand → applicationCommand}/decorator.js +12 -8
- package/dist/applicationCommand/decorator.js.map +1 -0
- package/dist/applicationCommand/index.d.ts +2 -0
- package/dist/{slashCommand → applicationCommand}/index.js +4 -1
- package/dist/applicationCommand/index.js.map +1 -0
- package/dist/builtinModules/BuiltInModule.js +3 -0
- package/dist/builtinModules/BuiltInModule.js.map +1 -1
- package/dist/builtinModules/BuiltinApplicationCommandConverters.d.ts +8 -0
- package/dist/builtinModules/BuiltinApplicationCommandConverters.js +16 -0
- package/dist/builtinModules/BuiltinApplicationCommandConverters.js.map +1 -0
- package/dist/builtinModules/BuiltinCommandConverters.d.ts +1 -1
- package/dist/builtinModules/BuiltinCommandConverters.js +3 -0
- package/dist/builtinModules/BuiltinCommandConverters.js.map +1 -1
- package/dist/builtinModules/CommandHandler.d.ts +4 -1
- package/dist/builtinModules/CommandHandler.js +149 -19
- package/dist/builtinModules/CommandHandler.js.map +1 -1
- package/dist/builtinModules/index.d.ts +1 -1
- package/dist/builtinModules/index.js +4 -1
- package/dist/builtinModules/index.js.map +1 -1
- package/dist/command/ArgumentConverter.d.ts +3 -3
- package/dist/command/ArgumentConverter.js +6 -3
- package/dist/command/ArgumentConverter.js.map +1 -1
- package/dist/command/Command.d.ts +2 -2
- package/dist/command/Command.js +3 -0
- package/dist/command/Command.js.map +1 -1
- package/dist/command/cooldown/adapter.js +3 -0
- package/dist/command/cooldown/adapter.js.map +1 -1
- package/dist/command/cooldown/decorator.js +3 -0
- package/dist/command/cooldown/decorator.js.map +1 -1
- package/dist/command/cooldown/error.js +3 -0
- package/dist/command/cooldown/error.js.map +1 -1
- package/dist/command/cooldown/index.js +3 -0
- package/dist/command/cooldown/index.js.map +1 -1
- package/dist/command/cooldown/type.js +3 -0
- package/dist/command/cooldown/type.js.map +1 -1
- package/dist/command/decorator.d.ts +2 -1
- package/dist/command/decorator.js +9 -5
- package/dist/command/decorator.js.map +1 -1
- package/dist/command/index.js +3 -0
- package/dist/command/index.js.map +1 -1
- package/dist/command/utils.d.ts +2 -2
- package/dist/command/utils.js +9 -6
- package/dist/command/utils.js.map +1 -1
- package/dist/constants.d.ts +3 -2
- package/dist/constants.js +7 -3
- package/dist/constants.js.map +1 -1
- package/dist/error/ArgumentConverterNotFound.d.ts +6 -6
- package/dist/error/ArgumentConverterNotFound.js +6 -3
- package/dist/error/ArgumentConverterNotFound.js.map +1 -1
- package/dist/error/ArgumentNotProvided.js +3 -0
- package/dist/error/ArgumentNotProvided.js.map +1 -1
- package/dist/error/CommandCheckFailed.d.ts +6 -6
- package/dist/error/CommandCheckFailed.js +6 -3
- package/dist/error/CommandCheckFailed.js.map +1 -1
- package/dist/error/CommandNotFound.js +3 -0
- package/dist/error/CommandNotFound.js.map +1 -1
- package/dist/error/InvalidTargetError.js +3 -0
- package/dist/error/InvalidTargetError.js.map +1 -1
- package/dist/error/ModuleError.js +3 -0
- package/dist/error/ModuleError.js.map +1 -1
- package/dist/error/PermissionRequired.js +3 -0
- package/dist/error/PermissionRequired.js.map +1 -1
- package/dist/error/checks/DMOnlyCommand.js +3 -0
- package/dist/error/checks/DMOnlyCommand.js.map +1 -1
- package/dist/error/checks/GuildOnlyCommand.js +3 -0
- package/dist/error/checks/GuildOnlyCommand.js.map +1 -1
- package/dist/error/checks/OwnerOnlyCommand.js +3 -0
- package/dist/error/checks/OwnerOnlyCommand.js.map +1 -1
- package/dist/error/checks/SlashCommandGlobalCheckError.d.ts +5 -0
- package/dist/error/checks/SlashCommandGlobalCheckError.js +14 -0
- package/dist/error/checks/SlashCommandGlobalCheckError.js.map +1 -0
- package/dist/error/checks/index.js +3 -0
- package/dist/error/checks/index.js.map +1 -1
- package/dist/error/index.js +3 -0
- package/dist/error/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/interface/index.js +3 -1
- package/dist/interface/index.js.map +1 -1
- package/dist/listener/Listener.js +3 -0
- package/dist/listener/Listener.js.map +1 -1
- package/dist/listener/decorator.js +3 -0
- package/dist/listener/decorator.js.map +1 -1
- package/dist/listener/index.js +3 -0
- package/dist/listener/index.js.map +1 -1
- package/dist/messageComponents/base.d.ts +10 -0
- package/dist/messageComponents/base.js +18 -0
- package/dist/messageComponents/base.js.map +1 -0
- package/dist/messageComponents/button.d.ts +5 -0
- package/dist/messageComponents/button.js +31 -0
- package/dist/messageComponents/button.js.map +1 -0
- package/dist/messageComponents/index.d.ts +2 -0
- package/dist/messageComponents/index.js +18 -0
- package/dist/messageComponents/index.js.map +1 -0
- package/dist/messageComponents/selectMenu.d.ts +5 -0
- package/dist/messageComponents/selectMenu.js +31 -0
- package/dist/messageComponents/selectMenu.js.map +1 -0
- package/dist/structures/CommandClient.d.ts +8 -3
- package/dist/structures/CommandClient.js +11 -8
- package/dist/structures/CommandClient.js.map +1 -1
- package/dist/structures/Module.d.ts +6 -4
- package/dist/structures/Module.js +9 -3
- package/dist/structures/Module.js.map +1 -1
- package/dist/structures/Registry.d.ts +6 -4
- package/dist/structures/Registry.js +21 -15
- package/dist/structures/Registry.js.map +1 -1
- package/dist/structures/index.js +3 -0
- package/dist/structures/index.js.map +1 -1
- package/dist/typings.d.ts +14 -2
- package/dist/typings.js +3 -0
- package/dist/typings.js.map +1 -1
- package/dist/utils.js +3 -0
- package/dist/utils.js.map +1 -1
- package/package.json +3 -5
- package/publish-version.js +7 -3
- package/src/applicationCommand/AppCommand.ts +32 -0
- package/src/{slashCommand → applicationCommand}/decorator.ts +14 -10
- package/src/applicationCommand/index.ts +6 -0
- package/src/builtinModules/BuiltInModule.ts +4 -0
- package/src/builtinModules/BuiltinApplicationCommandConverters.ts +16 -0
- package/src/builtinModules/BuiltinCommandConverters.ts +4 -0
- package/src/builtinModules/CommandHandler.ts +178 -22
- package/src/builtinModules/index.ts +5 -1
- package/src/command/ArgumentConverter.ts +7 -3
- package/src/command/Command.ts +6 -2
- package/src/command/cooldown/adapter.ts +4 -0
- package/src/command/cooldown/decorator.ts +4 -0
- package/src/command/cooldown/error.ts +4 -0
- package/src/command/cooldown/index.ts +4 -0
- package/src/command/cooldown/type.ts +4 -0
- package/src/command/decorator.ts +10 -5
- package/src/command/index.ts +4 -0
- package/src/command/utils.ts +13 -9
- package/src/constants.ts +8 -2
- package/src/error/ArgumentConverterNotFound.ts +8 -4
- package/src/error/ArgumentNotProvided.ts +4 -0
- package/src/error/CommandCheckFailed.ts +8 -4
- package/src/error/CommandNotFound.ts +4 -0
- package/src/error/InvalidTargetError.ts +4 -0
- package/src/error/ModuleError.ts +4 -0
- package/src/error/PermissionRequired.ts +4 -0
- package/src/error/checks/DMOnlyCommand.ts +4 -0
- package/src/error/checks/GuildOnlyCommand.ts +4 -0
- package/src/error/checks/OwnerOnlyCommand.ts +4 -0
- package/src/error/checks/SlashCommandGlobalCheckError.ts +11 -0
- package/src/error/checks/index.ts +4 -0
- package/src/error/index.ts +4 -0
- package/src/index.ts +6 -1
- package/src/interface/index.ts +4 -0
- package/src/listener/Listener.ts +4 -0
- package/src/listener/decorator.ts +4 -0
- package/src/listener/index.ts +4 -0
- package/src/messageComponents/base.ts +16 -0
- package/src/messageComponents/button.ts +30 -0
- package/src/messageComponents/index.ts +6 -0
- package/src/messageComponents/selectMenu.ts +30 -0
- package/src/structures/CommandClient.ts +22 -10
- package/src/structures/Module.ts +15 -6
- package/src/structures/Registry.ts +29 -19
- package/src/structures/index.ts +4 -0
- package/src/typings.ts +18 -2
- package/src/utils.ts +4 -0
- package/test/index.ts +6 -2
- package/test/modules/dev.ts +13 -5
- package/test/modules/test.ts +92 -15
- package/dist/builtinModules/BuiltinSlashCommandConverters.d.ts +0 -10
- package/dist/builtinModules/BuiltinSlashCommandConverters.js +0 -42
- package/dist/builtinModules/BuiltinSlashCommandConverters.js.map +0 -1
- package/dist/slashCommand/SlashCommand.d.ts +0 -19
- package/dist/slashCommand/SlashCommand.js +0 -22
- package/dist/slashCommand/SlashCommand.js.map +0 -1
- package/dist/slashCommand/decorator.d.ts +0 -10
- package/dist/slashCommand/decorator.js.map +0 -1
- package/dist/slashCommand/index.d.ts +0 -2
- package/dist/slashCommand/index.js.map +0 -1
- package/src/builtinModules/BuiltinSlashCommandConverters.ts +0 -23
- package/src/slashCommand/SlashCommand.ts +0 -29
- package/src/slashCommand/index.ts +0 -2
package/test/modules/test.ts
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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'
|
|
4
18
|
|
|
5
19
|
class Test extends Module {
|
|
6
20
|
constructor(private client: CommandClient) {
|
|
7
21
|
super()
|
|
8
22
|
}
|
|
9
23
|
|
|
24
|
+
// region lifetime method
|
|
10
25
|
load() {
|
|
11
26
|
console.log('load')
|
|
12
27
|
}
|
|
@@ -22,6 +37,7 @@ class Test extends Module {
|
|
|
22
37
|
afterReload() {
|
|
23
38
|
console.log('after reload')
|
|
24
39
|
}
|
|
40
|
+
// endregion
|
|
25
41
|
|
|
26
42
|
@listener('ready')
|
|
27
43
|
ready() {
|
|
@@ -35,8 +51,8 @@ class Test extends Module {
|
|
|
35
51
|
}
|
|
36
52
|
console.error(err)
|
|
37
53
|
}
|
|
38
|
-
@listener('
|
|
39
|
-
slashCommandError(err: Error, msg: CommandInteraction) {
|
|
54
|
+
@listener('applicationCommandError')
|
|
55
|
+
slashCommandError(err: Error, msg: CommandInteraction | ContextMenuInteraction) {
|
|
40
56
|
if (err instanceof CoolDownError) {
|
|
41
57
|
return msg.reply({
|
|
42
58
|
content: `쿨다운: <t:${(err.endsAt.getTime() / 1000).toFixed(0)}:R>`,
|
|
@@ -46,22 +62,83 @@ class Test extends Module {
|
|
|
46
62
|
console.error(err)
|
|
47
63
|
}
|
|
48
64
|
|
|
49
|
-
@
|
|
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
|
+
})
|
|
50
79
|
@coolDown(CoolDownType.USER, 10)
|
|
51
|
-
|
|
52
|
-
|
|
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
|
+
})
|
|
53
99
|
}
|
|
54
100
|
|
|
55
|
-
@
|
|
56
|
-
command:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
101
|
+
@applicationCommand({
|
|
102
|
+
command: {
|
|
103
|
+
type: 'MESSAGE',
|
|
104
|
+
name: 'contextMenuTest',
|
|
105
|
+
defaultPermission: true,
|
|
106
|
+
},
|
|
60
107
|
})
|
|
61
108
|
@coolDown(CoolDownType.USER, 10)
|
|
62
|
-
async
|
|
109
|
+
async contextMenuMessage(i: MessageContextMenuInteraction) {
|
|
63
110
|
return i.reply({
|
|
64
|
-
content:
|
|
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: [],
|
|
65
142
|
})
|
|
66
143
|
}
|
|
67
144
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BuiltInModule } from './BuiltInModule';
|
|
2
|
-
import { Client, CommandInteraction, CommandInteractionOptionResolver } from 'discord.js';
|
|
3
|
-
import { CommandClient } from '../structures';
|
|
4
|
-
export declare class BuiltinSlashCommandConverters extends BuiltInModule {
|
|
5
|
-
private cts;
|
|
6
|
-
client: Client;
|
|
7
|
-
constructor(cts: CommandClient);
|
|
8
|
-
message(interaction: CommandInteraction): CommandInteraction;
|
|
9
|
-
optionResolver(interaction: CommandInteraction): CommandInteractionOptionResolver;
|
|
10
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.BuiltinSlashCommandConverters = void 0;
|
|
13
|
-
const BuiltInModule_1 = require("./BuiltInModule");
|
|
14
|
-
const command_1 = require("../command");
|
|
15
|
-
const discord_js_1 = require("discord.js");
|
|
16
|
-
class BuiltinSlashCommandConverters extends BuiltInModule_1.BuiltInModule {
|
|
17
|
-
constructor(cts) {
|
|
18
|
-
super();
|
|
19
|
-
this.cts = cts;
|
|
20
|
-
this.client = cts.client;
|
|
21
|
-
}
|
|
22
|
-
message(interaction) {
|
|
23
|
-
return interaction;
|
|
24
|
-
}
|
|
25
|
-
optionResolver(interaction) {
|
|
26
|
-
return interaction.options;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
__decorate([
|
|
30
|
-
command_1.slashArgumentConverter(discord_js_1.CommandInteraction),
|
|
31
|
-
__metadata("design:type", Function),
|
|
32
|
-
__metadata("design:paramtypes", [discord_js_1.CommandInteraction]),
|
|
33
|
-
__metadata("design:returntype", void 0)
|
|
34
|
-
], BuiltinSlashCommandConverters.prototype, "message", null);
|
|
35
|
-
__decorate([
|
|
36
|
-
command_1.slashArgumentConverter(discord_js_1.CommandInteractionOptionResolver),
|
|
37
|
-
__metadata("design:type", Function),
|
|
38
|
-
__metadata("design:paramtypes", [discord_js_1.CommandInteraction]),
|
|
39
|
-
__metadata("design:returntype", discord_js_1.CommandInteractionOptionResolver)
|
|
40
|
-
], BuiltinSlashCommandConverters.prototype, "optionResolver", null);
|
|
41
|
-
exports.BuiltinSlashCommandConverters = BuiltinSlashCommandConverters;
|
|
42
|
-
//# sourceMappingURL=BuiltinSlashCommandConverters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BuiltinSlashCommandConverters.js","sourceRoot":"","sources":["../../src/builtinModules/BuiltinSlashCommandConverters.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAA+C;AAC/C,wCAAmD;AACnD,2CAAyF;AAGzF,MAAa,6BAA8B,SAAQ,6BAAa;IAG9D,YAAoB,GAAkB;QACpC,KAAK,EAAE,CAAA;QADW,QAAG,GAAH,GAAG,CAAe;QAEpC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAA;IAC1B,CAAC;IAGD,OAAO,CAAC,WAA+B;QACrC,OAAO,WAAW,CAAA;IACpB,CAAC;IAGD,cAAc,CAAC,WAA+B;QAC5C,OAAO,WAAW,CAAC,OAAO,CAAA;IAC5B,CAAC;CACF;AARC;IADC,gCAAsB,CAAC,+BAAkB,CAAC;;qCACtB,+BAAkB;;4DAEtC;AAGD;IADC,gCAAsB,CAAC,6CAAgC,CAAC;;qCAC7B,+BAAkB;oCAAG,6CAAgC;mEAEhF;AAhBH,sEAiBC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { SlashCommandBuilder } from '@discordjs/builders';
|
|
2
|
-
import { Module } from '../structures';
|
|
3
|
-
import { Snowflake } from 'discord.js';
|
|
4
|
-
import { SlashCheckFunction } from '../command';
|
|
5
|
-
export declare type SlashArgument = {
|
|
6
|
-
type: any;
|
|
7
|
-
name?: string;
|
|
8
|
-
};
|
|
9
|
-
export declare class SlashCommand {
|
|
10
|
-
commandBuilder: SlashCommandBuilder | Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
|
11
|
-
private run;
|
|
12
|
-
module: Module;
|
|
13
|
-
params: SlashArgument[];
|
|
14
|
-
guild: Snowflake | Snowflake[] | undefined;
|
|
15
|
-
private key;
|
|
16
|
-
get checks(): SlashCheckFunction[];
|
|
17
|
-
execute(module: Module, args: any[]): any;
|
|
18
|
-
constructor(commandBuilder: SlashCommandBuilder | Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>, run: Function, module: Module, params: SlashArgument[], guild: Snowflake | Snowflake[] | undefined, key: string | symbol);
|
|
19
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SlashCommand = void 0;
|
|
4
|
-
const constants_1 = require("../constants");
|
|
5
|
-
class SlashCommand {
|
|
6
|
-
constructor(commandBuilder, run, module, params, guild, key) {
|
|
7
|
-
this.commandBuilder = commandBuilder;
|
|
8
|
-
this.run = run;
|
|
9
|
-
this.module = module;
|
|
10
|
-
this.params = params;
|
|
11
|
-
this.guild = guild;
|
|
12
|
-
this.key = key;
|
|
13
|
-
}
|
|
14
|
-
get checks() {
|
|
15
|
-
return Reflect.getMetadata(constants_1.KSlashCommandChecks, this.module, this.key) || [];
|
|
16
|
-
}
|
|
17
|
-
execute(module, args) {
|
|
18
|
-
return this.run.apply(module, args);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.SlashCommand = SlashCommand;
|
|
22
|
-
//# sourceMappingURL=SlashCommand.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SlashCommand.js","sourceRoot":"","sources":["../../src/slashCommand/SlashCommand.ts"],"names":[],"mappings":";;;AAGA,4CAAkD;AAQlD,MAAa,YAAY;IASvB,YACS,cAAuG,EACtG,GAAa,EACd,MAAc,EACd,MAAuB,EACvB,KAA0C,EACzC,GAAoB;QALrB,mBAAc,GAAd,cAAc,CAAyF;QACtG,QAAG,GAAH,GAAG,CAAU;QACd,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAiB;QACvB,UAAK,GAAL,KAAK,CAAqC;QACzC,QAAG,GAAH,GAAG,CAAiB;IAC3B,CAAC;IAfJ,IAAI,MAAM;QACR,OAAO,OAAO,CAAC,WAAW,CAAC,+BAAmB,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;IAC9E,CAAC;IAED,OAAO,CAAC,MAAc,EAAE,IAAW;QACjC,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACrC,CAAC;CAUF;AAjBD,oCAiBC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Snowflake } from 'discord.js';
|
|
2
|
-
import { SlashCommandBuilder } from '@discordjs/builders';
|
|
3
|
-
declare type SlashOptions = {
|
|
4
|
-
guild: Snowflake | Snowflake[];
|
|
5
|
-
};
|
|
6
|
-
export declare const slashCommand: (opt: Partial<SlashOptions> & {
|
|
7
|
-
command: SlashCommandBuilder | Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
|
8
|
-
}) => (target: Object, propertyKey: string) => void;
|
|
9
|
-
export declare const option: (key: string) => ParameterDecorator;
|
|
10
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../src/slashCommand/decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAkD;AAClD,oCAAsC;AACtC,4CAAmE;AAEnE,iDAA6C;AAOtC,MAAM,YAAY,GAAG,CAAC,GAAiI,EAAE,EAAE;IAChK,OAAO,CACL,MAAc,EACd,WAAmB,EAEnB,EAAE;QACF,mBAAW,CAAC,MAAM,CAAC,CAAA;QAEnB,IAAI,UAAU,GAAmB,OAAO,CAAC,WAAW,CAAC,0BAAc,EAAE,MAAM,CAAC,CAAA;QAE5E,MAAM,MAAM,GAAU,OAAO,CAAC,WAAW,CAAC,mBAAmB,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;QAEnF,MAAM,OAAO,GAA+B,OAAO,CAAC,WAAW,CAAC,gCAAoB,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,IAAI,uBAAU,EAAkB,CAAA;QAE9I,MAAM,OAAO,GAAG,IAAI,2BAAY,CAC9B,GAAG,CAAC,OAAO,EACX,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAChC,MAAgB,EAChB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YACpB,IAAI,EAAE,CAAC;YACP,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;SACrB,CAAC,CAAC,EACH,GAAG,CAAC,KAAK,EACT,WAAW,CACZ,CAAA;QAED,IAAI,UAAU,EAAE;YACd,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;SACzB;aAAM;YACL,UAAU,GAAG,CAAC,OAAO,CAAC,CAAA;YACtB,OAAO,CAAC,cAAc,CAAC,0BAAc,EAAE,UAAU,EAAE,MAAM,CAAC,CAAA;SAC3D;IACH,CAAC,CAAA;AACH,CAAC,CAAA;AAjCY,QAAA,YAAY,gBAiCxB;AAEM,MAAM,MAAM,GAAG,CAAC,GAAW,EAAsB,EAAE,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,EAAE;IACjG,mBAAW,CAAC,MAAM,CAAC,CAAA;IAEnB,IAAI,UAAU,GAA+B,OAAO,CAAC,WAAW,CAAC,gCAAoB,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;IAE3G,IAAI,CAAC,UAAU,EAAE;QACf,UAAU,GAAG,IAAI,uBAAU,EAAkB,CAAA;QAC7C,OAAO,CAAC,cAAc,CAAC,gCAAoB,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;KAC9E;IAED,UAAU,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;AACrC,CAAC,CAAA;AAXY,QAAA,MAAM,UAWlB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/slashCommand/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA2B;AAC3B,iDAA8B"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { BuiltInModule } from './BuiltInModule'
|
|
2
|
-
import { slashArgumentConverter } from '../command'
|
|
3
|
-
import { Client, CommandInteraction, CommandInteractionOptionResolver } from 'discord.js'
|
|
4
|
-
import { CommandClient } from '../structures'
|
|
5
|
-
|
|
6
|
-
export class BuiltinSlashCommandConverters extends BuiltInModule {
|
|
7
|
-
client: Client
|
|
8
|
-
|
|
9
|
-
constructor(private cts: CommandClient) {
|
|
10
|
-
super()
|
|
11
|
-
this.client = cts.client
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
@slashArgumentConverter(CommandInteraction)
|
|
15
|
-
message(interaction: CommandInteraction) {
|
|
16
|
-
return interaction
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@slashArgumentConverter(CommandInteractionOptionResolver)
|
|
20
|
-
optionResolver(interaction: CommandInteraction): CommandInteractionOptionResolver {
|
|
21
|
-
return interaction.options
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { SlashCommandBuilder } from '@discordjs/builders'
|
|
2
|
-
import { Module } from '../structures'
|
|
3
|
-
import { Snowflake } from 'discord.js'
|
|
4
|
-
import { KSlashCommandChecks } from '../constants'
|
|
5
|
-
import { SlashCheckFunction } from '../command'
|
|
6
|
-
|
|
7
|
-
export type SlashArgument = {
|
|
8
|
-
type: any
|
|
9
|
-
name?: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class SlashCommand {
|
|
13
|
-
get checks(): SlashCheckFunction[] {
|
|
14
|
-
return Reflect.getMetadata(KSlashCommandChecks, this.module, this.key) || []
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
execute(module: Module, args: any[]) {
|
|
18
|
-
return this.run.apply(module, args)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
constructor(
|
|
22
|
-
public commandBuilder: SlashCommandBuilder | Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>,
|
|
23
|
-
private run: Function,
|
|
24
|
-
public module: Module,
|
|
25
|
-
public params: SlashArgument[],
|
|
26
|
-
public guild: Snowflake | Snowflake[] | undefined,
|
|
27
|
-
private key: string | symbol,
|
|
28
|
-
) {}
|
|
29
|
-
}
|