@pikokr/command.ts 4.0.0 → 4.0.1
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 +310 -10
- package/dist/index.js +1 -22
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
- package/publish-version.js +7 -3
- package/src/applicationCommand/AppCommand.ts +4 -0
- package/src/applicationCommand/decorator.ts +4 -0
- package/src/applicationCommand/index.ts +4 -0
- package/src/builtinModules/BuiltInModule.ts +4 -0
- package/src/builtinModules/BuiltinApplicationCommandConverters.ts +4 -0
- package/src/builtinModules/BuiltinCommandConverters.ts +4 -0
- package/src/builtinModules/CommandHandler.ts +4 -0
- package/src/builtinModules/index.ts +4 -0
- package/src/command/ArgumentConverter.ts +4 -0
- package/src/command/Command.ts +4 -0
- 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 +4 -0
- package/src/command/index.ts +4 -0
- package/src/command/utils.ts +4 -0
- package/src/constants.ts +4 -0
- package/src/error/ArgumentConverterNotFound.ts +4 -0
- package/src/error/ArgumentNotProvided.ts +4 -0
- package/src/error/CommandCheckFailed.ts +4 -0
- 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 +4 -0
- package/src/error/checks/index.ts +4 -0
- package/src/error/index.ts +4 -0
- package/src/index.ts +4 -0
- 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 +4 -0
- package/src/messageComponents/button.ts +4 -0
- package/src/messageComponents/index.ts +4 -0
- package/src/messageComponents/selectMenu.ts +4 -0
- package/src/structures/CommandClient.ts +4 -0
- package/src/structures/Module.ts +4 -0
- package/src/structures/Registry.ts +37 -12
- package/src/structures/index.ts +4 -0
- package/src/typings.ts +4 -0
- package/src/utils.ts +4 -0
- package/test/index.ts +4 -0
- package/test/modules/dev.ts +4 -0
- package/test/modules/test.ts +5 -1
- package/tsup.config.ts +14 -0
- package/dist/applicationCommand/AppCommand.d.ts +0 -18
- package/dist/applicationCommand/AppCommand.js +0 -22
- package/dist/applicationCommand/AppCommand.js.map +0 -1
- package/dist/applicationCommand/decorator.d.ts +0 -10
- package/dist/applicationCommand/decorator.js +0 -39
- package/dist/applicationCommand/decorator.js.map +0 -1
- package/dist/applicationCommand/index.d.ts +0 -2
- package/dist/applicationCommand/index.js +0 -15
- package/dist/applicationCommand/index.js.map +0 -1
- package/dist/builtinModules/BuiltInModule.d.ts +0 -4
- package/dist/builtinModules/BuiltInModule.js +0 -13
- package/dist/builtinModules/BuiltInModule.js.map +0 -1
- package/dist/builtinModules/BuiltinApplicationCommandConverters.d.ts +0 -8
- package/dist/builtinModules/BuiltinApplicationCommandConverters.js +0 -13
- package/dist/builtinModules/BuiltinApplicationCommandConverters.js.map +0 -1
- package/dist/builtinModules/BuiltinCommandConverters.d.ts +0 -16
- package/dist/builtinModules/BuiltinCommandConverters.js +0 -127
- package/dist/builtinModules/BuiltinCommandConverters.js.map +0 -1
- 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/builtinModules/CommandHandler.d.ts +0 -14
- package/dist/builtinModules/CommandHandler.js +0 -357
- package/dist/builtinModules/CommandHandler.js.map +0 -1
- package/dist/builtinModules/index.d.ts +0 -3
- package/dist/builtinModules/index.js +0 -16
- package/dist/builtinModules/index.js.map +0 -1
- package/dist/command/ArgumentConverter.d.ts +0 -15
- package/dist/command/ArgumentConverter.js +0 -25
- package/dist/command/ArgumentConverter.js.map +0 -1
- package/dist/command/Command.d.ts +0 -20
- package/dist/command/Command.js +0 -22
- package/dist/command/Command.js.map +0 -1
- package/dist/command/cooldown/adapter.d.ts +0 -10
- package/dist/command/cooldown/adapter.js +0 -31
- package/dist/command/cooldown/adapter.js.map +0 -1
- package/dist/command/cooldown/decorator.d.ts +0 -2
- package/dist/command/cooldown/decorator.js +0 -73
- package/dist/command/cooldown/decorator.js.map +0 -1
- package/dist/command/cooldown/error.d.ts +0 -4
- package/dist/command/cooldown/error.js +0 -11
- package/dist/command/cooldown/error.js.map +0 -1
- package/dist/command/cooldown/index.d.ts +0 -5
- package/dist/command/cooldown/index.js +0 -18
- package/dist/command/cooldown/index.js.map +0 -1
- package/dist/command/cooldown/type.d.ts +0 -8
- package/dist/command/cooldown/type.js +0 -13
- package/dist/command/cooldown/type.js.map +0 -1
- package/dist/command/decorator.d.ts +0 -17
- package/dist/command/decorator.js +0 -138
- package/dist/command/decorator.js.map +0 -1
- package/dist/command/index.d.ts +0 -5
- package/dist/command/index.js +0 -18
- package/dist/command/index.js.map +0 -1
- package/dist/command/utils.d.ts +0 -2
- package/dist/command/utils.js +0 -30
- package/dist/command/utils.js.map +0 -1
- package/dist/constants.d.ts +0 -14
- package/dist/constants.js +0 -18
- package/dist/constants.js.map +0 -1
- package/dist/error/ArgumentConverterNotFound.d.ts +0 -13
- package/dist/error/ArgumentConverterNotFound.js +0 -20
- package/dist/error/ArgumentConverterNotFound.js.map +0 -1
- package/dist/error/ArgumentNotProvided.d.ts +0 -8
- package/dist/error/ArgumentNotProvided.js +0 -13
- package/dist/error/ArgumentNotProvided.js.map +0 -1
- package/dist/error/CommandCheckFailed.d.ts +0 -13
- package/dist/error/CommandCheckFailed.js +0 -20
- package/dist/error/CommandCheckFailed.js.map +0 -1
- package/dist/error/CommandNotFound.d.ts +0 -7
- package/dist/error/CommandNotFound.js +0 -13
- package/dist/error/CommandNotFound.js.map +0 -1
- package/dist/error/InvalidTargetError.d.ts +0 -3
- package/dist/error/InvalidTargetError.js +0 -10
- package/dist/error/InvalidTargetError.js.map +0 -1
- package/dist/error/ModuleError.d.ts +0 -6
- package/dist/error/ModuleError.js +0 -14
- package/dist/error/ModuleError.js.map +0 -1
- package/dist/error/PermissionRequired.d.ts +0 -10
- package/dist/error/PermissionRequired.js +0 -19
- package/dist/error/PermissionRequired.js.map +0 -1
- package/dist/error/checks/DMOnlyCommand.d.ts +0 -3
- package/dist/error/checks/DMOnlyCommand.js +0 -10
- package/dist/error/checks/DMOnlyCommand.js.map +0 -1
- package/dist/error/checks/GuildOnlyCommand.d.ts +0 -3
- package/dist/error/checks/GuildOnlyCommand.js +0 -10
- package/dist/error/checks/GuildOnlyCommand.js.map +0 -1
- package/dist/error/checks/OwnerOnlyCommand.d.ts +0 -3
- package/dist/error/checks/OwnerOnlyCommand.js +0 -10
- package/dist/error/checks/OwnerOnlyCommand.js.map +0 -1
- package/dist/error/checks/SlashCommandGlobalCheckError.d.ts +0 -5
- package/dist/error/checks/SlashCommandGlobalCheckError.js +0 -11
- package/dist/error/checks/SlashCommandGlobalCheckError.js.map +0 -1
- package/dist/error/checks/index.d.ts +0 -3
- package/dist/error/checks/index.js +0 -16
- package/dist/error/checks/index.js.map +0 -1
- package/dist/error/index.d.ts +0 -7
- package/dist/error/index.js +0 -20
- package/dist/error/index.js.map +0 -1
- package/dist/interface/index.d.ts +0 -1
- package/dist/interface/index.js +0 -4
- package/dist/interface/index.js.map +0 -1
- package/dist/listener/Listener.d.ts +0 -5
- package/dist/listener/Listener.js +0 -11
- package/dist/listener/Listener.js.map +0 -1
- package/dist/listener/decorator.d.ts +0 -2
- package/dist/listener/decorator.js +0 -22
- package/dist/listener/decorator.js.map +0 -1
- package/dist/listener/index.d.ts +0 -2
- package/dist/listener/index.js +0 -15
- package/dist/listener/index.js.map +0 -1
- package/dist/messageComponents/base.d.ts +0 -10
- package/dist/messageComponents/base.js +0 -15
- package/dist/messageComponents/base.js.map +0 -1
- package/dist/messageComponents/button.d.ts +0 -5
- package/dist/messageComponents/button.js +0 -28
- package/dist/messageComponents/button.js.map +0 -1
- package/dist/messageComponents/index.d.ts +0 -2
- package/dist/messageComponents/index.js +0 -15
- package/dist/messageComponents/index.js.map +0 -1
- package/dist/messageComponents/selectMenu.d.ts +0 -5
- package/dist/messageComponents/selectMenu.js +0 -28
- package/dist/messageComponents/selectMenu.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 -11
- package/dist/slashCommand/decorator.js +0 -39
- package/dist/slashCommand/decorator.js.map +0 -1
- package/dist/slashCommand/index.d.ts +0 -2
- package/dist/slashCommand/index.js +0 -15
- package/dist/slashCommand/index.js.map +0 -1
- package/dist/structures/CommandClient.d.ts +0 -45
- package/dist/structures/CommandClient.js +0 -94
- package/dist/structures/CommandClient.js.map +0 -1
- package/dist/structures/Module.d.ts +0 -21
- package/dist/structures/Module.js +0 -38
- package/dist/structures/Module.js.map +0 -1
- package/dist/structures/Registry.d.ts +0 -30
- package/dist/structures/Registry.js +0 -226
- package/dist/structures/Registry.js.map +0 -1
- package/dist/structures/index.d.ts +0 -3
- package/dist/structures/index.js +0 -16
- package/dist/structures/index.js.map +0 -1
- package/dist/typings.d.ts +0 -30
- package/dist/typings.js +0 -3
- package/dist/typings.js.map +0 -1
- package/dist/utils.d.ts +0 -1
- package/dist/utils.js +0 -11
- package/dist/utils.js.map +0 -1
package/publish-version.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022 pikokr. Licensed under the MIT license
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
// DO NOT RUN THIS ON DEV ENVIRONMENT
|
|
2
6
|
// **CI ONLY**
|
|
3
7
|
|
|
4
|
-
const
|
|
8
|
+
const pkg = require('./package.json')
|
|
5
9
|
const fs = require('fs')
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
pkg.version = pkg.version + '-dev.' + process.env.COMMIT_ID
|
|
8
12
|
|
|
9
|
-
fs.writeFileSync('package.json', JSON.stringify(
|
|
13
|
+
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2))
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022 pikokr. Licensed under the MIT license
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
import { ApplicationCommandDataResolvable, Collection, Snowflake } from 'discord.js'
|
|
2
6
|
import { checkTarget } from '../utils'
|
|
3
7
|
import { KSlashCommandOptions, KApplicationCommands } from '../constants'
|
package/src/command/Command.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022 pikokr. Licensed under the MIT license
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
import { Module } from '../structures'
|
|
2
6
|
import { CommandInteraction, ContextMenuInteraction, Message, MessageComponentInteraction } from 'discord.js'
|
|
3
7
|
import { KCommandChecks } from '../constants'
|
package/src/command/decorator.ts
CHANGED
package/src/command/index.ts
CHANGED
package/src/command/utils.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022 pikokr. Licensed under the MIT license
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
import { CommandInteraction, ContextMenuInteraction, Message, MessageComponentInteraction } from 'discord.js'
|
|
2
6
|
import type { CheckFunction, ApplicationCommandCheckFunction } from './Command'
|
|
3
7
|
import { KCommandChecks, KApplicationCommandChecks } from '../constants'
|
package/src/constants.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022 pikokr. Licensed under the MIT license
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
import { CommandInteraction, ContextMenuInteraction, Message, MessageComponentInteraction } from 'discord.js'
|
|
2
6
|
import { Command } from '../command'
|
|
3
7
|
import { AppCommand } from '../applicationCommand'
|
package/src/error/ModuleError.ts
CHANGED
package/src/error/index.ts
CHANGED
package/src/index.ts
CHANGED
package/src/interface/index.ts
CHANGED
package/src/listener/Listener.ts
CHANGED
package/src/listener/index.ts
CHANGED
package/src/structures/Module.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022 pikokr. Licensed under the MIT license
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
import { KArgumentConverters, KCommands, KListeners, KMessageComponentHandlers, KModulePath, KSlashArgumentConverters, KApplicationCommands } from '../constants'
|
|
2
6
|
import type { Command } from '../command'
|
|
3
7
|
import { Listener } from '../listener'
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022 pikokr. Licensed under the MIT license
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
import { CommandClient } from './CommandClient'
|
|
2
6
|
import { Module } from './Module'
|
|
3
7
|
import { Command, ApplicationCommandArgumentConverter } from '../command'
|
|
@@ -140,28 +144,49 @@ export class Registry {
|
|
|
140
144
|
this.logger.debug(`Syncing commands...`)
|
|
141
145
|
const commands = this.applicationCommands.filter((x) => !x.guild)
|
|
142
146
|
const guild = this.client.options.applicationCommands.guild
|
|
147
|
+
const syncForGuild = async (g: Guild, commands: AppCommand[]) => {
|
|
148
|
+
this.logger.debug(`Syncing for guild ${g.name}(${g.id})`)
|
|
149
|
+
const commandsToRegister = [
|
|
150
|
+
...commands.map((x) => x.command),
|
|
151
|
+
...this.applicationCommands.filter((y) => y.guild === g.id || y.guild?.includes(g.id) || false).map((x) => x.command),
|
|
152
|
+
]
|
|
153
|
+
this.logger.debug(`Command List: ${commandsToRegister.map((x) => x.name).join(', ')}`)
|
|
154
|
+
await g.commands.set(commandsToRegister)
|
|
155
|
+
}
|
|
143
156
|
if (guild) {
|
|
144
|
-
const syncForGuild = async (g: Guild) => {
|
|
145
|
-
this.logger.debug(`Syncing for guild ${g.name}(${g.id})`)
|
|
146
|
-
const commandsToRegister = [
|
|
147
|
-
...commands.map((x) => x.command),
|
|
148
|
-
...this.applicationCommands.filter((y) => y.guild === g.id || y.guild?.includes(g.id) || false).map((x) => x.command),
|
|
149
|
-
]
|
|
150
|
-
this.logger.debug(`Command List: ${commandsToRegister.map((x) => x.name).join(', ')}`)
|
|
151
|
-
await g.commands.set(commandsToRegister)
|
|
152
|
-
}
|
|
153
|
-
|
|
154
157
|
if (typeof guild === 'string') {
|
|
155
|
-
await syncForGuild(await this.client.client.guilds.fetch(guild))
|
|
158
|
+
await syncForGuild(await this.client.client.guilds.fetch(guild), commands)
|
|
156
159
|
} else {
|
|
157
160
|
for (const g of guild) {
|
|
158
|
-
await syncForGuild(await this.client.client.guilds.fetch(g))
|
|
161
|
+
await syncForGuild(await this.client.client.guilds.fetch(g), commands)
|
|
159
162
|
}
|
|
160
163
|
}
|
|
161
164
|
} else {
|
|
162
165
|
this.logger.debug('Syncing global...')
|
|
163
166
|
await this.client.client.application?.commands.set(commands.map((x) => x.command))
|
|
164
167
|
}
|
|
168
|
+
const commandsWithGuild = this.applicationCommands.filter((x) => x.guild)
|
|
169
|
+
|
|
170
|
+
const guilds = new Set<string>()
|
|
171
|
+
|
|
172
|
+
for (const command of commandsWithGuild) {
|
|
173
|
+
if (!command.guild) continue
|
|
174
|
+
if (typeof command.guild === 'string') {
|
|
175
|
+
guilds.add(command.guild)
|
|
176
|
+
} else {
|
|
177
|
+
for (const guild of command.guild) {
|
|
178
|
+
guilds.add(guild)
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
for (const guild of guilds) {
|
|
184
|
+
await syncForGuild(
|
|
185
|
+
await this.client.client.guilds.fetch(guild),
|
|
186
|
+
commandsWithGuild.filter((x) => x.guild && typeof (x.guild === 'string' ? guild === x.guild : x.guild.includes(guild))),
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
|
|
165
190
|
this.logger.debug('Syncing ended.')
|
|
166
191
|
}
|
|
167
192
|
|
package/src/structures/index.ts
CHANGED
package/src/typings.ts
CHANGED
package/src/utils.ts
CHANGED
package/test/index.ts
CHANGED
package/test/modules/dev.ts
CHANGED
package/test/modules/test.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
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'
|
|
2
6
|
import {
|
|
3
7
|
ButtonInteraction,
|
|
4
8
|
CommandInteraction,
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022 pikokr. Licensed under the MIT license
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { defineConfig } from 'tsup'
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
entry: ['src/index.ts'],
|
|
9
|
+
sourcemap: true,
|
|
10
|
+
splitting: false,
|
|
11
|
+
clean: true,
|
|
12
|
+
dts: true,
|
|
13
|
+
minify: true,
|
|
14
|
+
})
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Module } from '../structures';
|
|
2
|
-
import { ApplicationCommandDataResolvable, Snowflake } from 'discord.js';
|
|
3
|
-
import { ApplicationCommandCheckFunction } from '../command';
|
|
4
|
-
export declare type AppCommandArgument = {
|
|
5
|
-
type: any;
|
|
6
|
-
name?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare class AppCommand {
|
|
9
|
-
command: ApplicationCommandDataResolvable;
|
|
10
|
-
private run;
|
|
11
|
-
module: Module;
|
|
12
|
-
params: AppCommandArgument[];
|
|
13
|
-
guild: Snowflake | Snowflake[] | undefined;
|
|
14
|
-
private key;
|
|
15
|
-
get checks(): ApplicationCommandCheckFunction[];
|
|
16
|
-
execute(module: Module, args: any[]): any;
|
|
17
|
-
constructor(command: ApplicationCommandDataResolvable, run: Function, module: Module, params: AppCommandArgument[], guild: Snowflake | Snowflake[] | undefined, key: string | symbol);
|
|
18
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppCommand = void 0;
|
|
4
|
-
const constants_1 = require("../constants");
|
|
5
|
-
class AppCommand {
|
|
6
|
-
constructor(command, run, module, params, guild, key) {
|
|
7
|
-
this.command = command;
|
|
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.KApplicationCommandChecks, this.module, this.key) || [];
|
|
16
|
-
}
|
|
17
|
-
execute(module, args) {
|
|
18
|
-
return this.run.apply(module, args);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.AppCommand = AppCommand;
|
|
22
|
-
//# sourceMappingURL=AppCommand.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AppCommand.js","sourceRoot":"","sources":["../../src/applicationCommand/AppCommand.ts"],"names":[],"mappings":";;;AAEA,4CAAwD;AAQxD,MAAa,UAAU;IASrB,YACS,OAAyC,EACxC,GAAa,EACd,MAAc,EACd,MAA4B,EAC5B,KAA0C,EACzC,GAAoB;QALrB,YAAO,GAAP,OAAO,CAAkC;QACxC,QAAG,GAAH,GAAG,CAAU;QACd,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAsB;QAC5B,UAAK,GAAL,KAAK,CAAqC;QACzC,QAAG,GAAH,GAAG,CAAiB;IAC3B,CAAC;IAfJ,IAAI,MAAM;QACR,OAAO,OAAO,CAAC,WAAW,CAAC,qCAAyB,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;IACpF,CAAC;IAED,OAAO,CAAC,MAAc,EAAE,IAAW;QACjC,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACrC,CAAC;CAUF;AAjBD,gCAiBC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ApplicationCommandDataResolvable, Snowflake } from 'discord.js';
|
|
2
|
-
declare type ApplicationCommandOptions = {
|
|
3
|
-
guild: Snowflake | Snowflake[];
|
|
4
|
-
optionTypes?: any[];
|
|
5
|
-
};
|
|
6
|
-
export declare const applicationCommand: (opt: Partial<ApplicationCommandOptions> & {
|
|
7
|
-
command: ApplicationCommandDataResolvable;
|
|
8
|
-
}) => (target: Object, propertyKey: string) => void;
|
|
9
|
-
export declare const option: (key: string) => ParameterDecorator;
|
|
10
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.option = exports.applicationCommand = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const constants_1 = require("../constants");
|
|
7
|
-
const AppCommand_1 = require("./AppCommand");
|
|
8
|
-
const applicationCommand = (opt) => {
|
|
9
|
-
return (target, propertyKey) => {
|
|
10
|
-
var _a;
|
|
11
|
-
utils_1.checkTarget(target);
|
|
12
|
-
let properties = Reflect.getMetadata(constants_1.KApplicationCommands, target);
|
|
13
|
-
const params = (_a = opt.optionTypes) !== null && _a !== void 0 ? _a : Reflect.getMetadata('design:paramtypes', target, propertyKey);
|
|
14
|
-
const options = Reflect.getMetadata(constants_1.KSlashCommandOptions, target, propertyKey) || new discord_js_1.Collection();
|
|
15
|
-
const command = new AppCommand_1.AppCommand(opt.command, Reflect.get(target, propertyKey), target, params.map((x, i) => ({
|
|
16
|
-
type: x,
|
|
17
|
-
name: options.get(i),
|
|
18
|
-
})), opt.guild, propertyKey);
|
|
19
|
-
if (properties) {
|
|
20
|
-
properties.push(command);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
properties = [command];
|
|
24
|
-
Reflect.defineMetadata(constants_1.KApplicationCommands, properties, target);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
exports.applicationCommand = applicationCommand;
|
|
29
|
-
const option = (key) => (target, propertyKey, parameterIndex) => {
|
|
30
|
-
utils_1.checkTarget(target);
|
|
31
|
-
let properties = Reflect.getMetadata(constants_1.KSlashCommandOptions, target, propertyKey);
|
|
32
|
-
if (!properties) {
|
|
33
|
-
properties = new discord_js_1.Collection();
|
|
34
|
-
Reflect.defineMetadata(constants_1.KSlashCommandOptions, properties, target, propertyKey);
|
|
35
|
-
}
|
|
36
|
-
properties.set(parameterIndex, key);
|
|
37
|
-
};
|
|
38
|
-
exports.option = option;
|
|
39
|
-
//# sourceMappingURL=decorator.js.map
|