@pikokr/command.ts 4.0.7 → 5.0.0-dev.44dc47f
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/docs.yml +2 -2
- 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/README.md +2 -0
- package/dist/index.d.ts +140 -292
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/docs/index.yml +1 -1
- package/package.json +22 -16
- package/publish-version.js +20 -0
- package/renovate.json +5 -0
- package/scripts/docs.ts +8 -4
- package/src/applicationCommand/ApplicationCommand.ts +17 -0
- package/src/applicationCommand/ApplicationCommandExtension.ts +169 -0
- package/src/applicationCommand/ApplicationCommandOption.ts +16 -0
- package/src/applicationCommand/index.ts +10 -6
- package/src/core/components/BaseComponent.ts +62 -0
- package/src/core/components/ComponentArgument.ts +15 -0
- package/src/core/components/ComponentArgumentDecorator.ts +25 -0
- package/src/core/components/decoratorCreator.ts +81 -0
- package/src/core/components/index.ts +13 -0
- 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 -0
- package/src/core/hooks/moduleHook.ts +39 -0
- package/src/core/index.ts +15 -0
- package/src/core/listener/index.ts +29 -0
- package/src/core/structures/CommandClient.ts +78 -0
- package/src/core/structures/Registry.ts +110 -0
- package/src/core/structures/index.ts +10 -0
- package/src/core/symbols.ts +13 -0
- 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 -16
- package/src/textCommand/TextCommand.ts +20 -0
- package/src/textCommand/TextCommandExtension.ts +128 -0
- package/src/textCommand/index.ts +11 -0
- package/src/textCommand/parameters.ts +14 -0
- package/test/index.ts +85 -20
- package/tsconfig.json +3 -3
- package/tsconfig.prod.json +8 -0
- package/tsup.config.ts +9 -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 -44
- package/test/modules/test.ts +0 -148
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
|
2
|
+
# to commit it to your repository.
|
|
3
|
+
#
|
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
|
5
|
+
# or to provide custom queries or build logic.
|
|
6
|
+
#
|
|
7
|
+
# ******** NOTE ********
|
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
|
10
|
+
# supported CodeQL languages.
|
|
11
|
+
#
|
|
12
|
+
name: 'CodeQL'
|
|
13
|
+
|
|
14
|
+
on:
|
|
15
|
+
push:
|
|
16
|
+
branches: [dev]
|
|
17
|
+
pull_request:
|
|
18
|
+
# The branches below must be a subset of the branches above
|
|
19
|
+
branches: [dev]
|
|
20
|
+
schedule:
|
|
21
|
+
- cron: '31 4 * * 2'
|
|
22
|
+
|
|
23
|
+
jobs:
|
|
24
|
+
analyze:
|
|
25
|
+
name: Analyze
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
permissions:
|
|
28
|
+
actions: read
|
|
29
|
+
contents: read
|
|
30
|
+
security-events: write
|
|
31
|
+
|
|
32
|
+
strategy:
|
|
33
|
+
fail-fast: false
|
|
34
|
+
matrix:
|
|
35
|
+
language: ['javascript']
|
|
36
|
+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
|
37
|
+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
|
38
|
+
|
|
39
|
+
steps:
|
|
40
|
+
- name: Checkout repository
|
|
41
|
+
uses: actions/checkout@v2
|
|
42
|
+
|
|
43
|
+
# Initializes the CodeQL tools for scanning.
|
|
44
|
+
- name: Initialize CodeQL
|
|
45
|
+
uses: github/codeql-action/init@v2
|
|
46
|
+
with:
|
|
47
|
+
languages: ${{ matrix.language }}
|
|
48
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
49
|
+
# By default, queries listed here will override any specified in a config file.
|
|
50
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
51
|
+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
|
52
|
+
|
|
53
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
|
54
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
|
55
|
+
- name: Autobuild
|
|
56
|
+
uses: github/codeql-action/autobuild@v2
|
|
57
|
+
|
|
58
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
|
59
|
+
# 📚 https://git.io/JvXDl
|
|
60
|
+
|
|
61
|
+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
|
62
|
+
# and modify them (or add more) to build your code if your project
|
|
63
|
+
# uses a compiled language
|
|
64
|
+
|
|
65
|
+
#- run: |
|
|
66
|
+
# make bootstrap
|
|
67
|
+
# make release
|
|
68
|
+
|
|
69
|
+
- name: Perform CodeQL Analysis
|
|
70
|
+
uses: github/codeql-action/analyze@v2
|
|
@@ -33,7 +33,7 @@ jobs:
|
|
|
33
33
|
run: yarn docs
|
|
34
34
|
|
|
35
35
|
- name: Upload artifacts
|
|
36
|
-
uses: actions/upload-artifact@
|
|
36
|
+
uses: actions/upload-artifact@v3
|
|
37
37
|
with:
|
|
38
38
|
name: docs
|
|
39
39
|
path: docs/docs.json
|
|
@@ -76,4 +76,4 @@ jobs:
|
|
|
76
76
|
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
|
77
77
|
git add .
|
|
78
78
|
git commit -m "Docs build for ${BRANCH_OR_TAG} ${BRANCH_NAME}: ${SHA}" || true
|
|
79
|
-
git push
|
|
79
|
+
git push
|
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/pikokr/command.ts/actions/workflows/publish.yml) <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
4
4
|
[](#contributors-)
|
|
5
|
+
|
|
5
6
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
6
7
|
|
|
7
8
|

|
|
@@ -11,6 +12,7 @@ Command framework for discord.js
|
|
|
11
12
|
[Discord](https://discord.gg/EEhcPzsGHV) / [문서](https://v3.cts.pikokr.dev) / [V2 문서](https://command-ts-docs-ezojnktwv-pikokr.vercel.app/)
|
|
12
13
|
|
|
13
14
|
## Contributors
|
|
15
|
+
|
|
14
16
|
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
15
17
|
<!-- prettier-ignore-start -->
|
|
16
18
|
<!-- markdownlint-disable -->
|
package/dist/index.d.ts
CHANGED
|
@@ -1,321 +1,169 @@
|
|
|
1
|
+
import * as discord_js from 'discord.js';
|
|
2
|
+
import { Collection, Snowflake, Interaction, ChatInputCommandInteraction, MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction, Message, Client, UserApplicationCommandData, MessageApplicationCommandData, ChatInputApplicationCommandData, ApplicationCommandType, APIApplicationCommandOption } from 'discord.js';
|
|
3
|
+
import EventEmitter from 'events';
|
|
1
4
|
import * as tslog from 'tslog';
|
|
2
5
|
import { Logger } from 'tslog';
|
|
3
|
-
import { ApplicationCommandDataResolvable, Snowflake, MessageComponentInteraction, MessageComponentType, Collection, Message, CommandInteraction, Interaction, Client, ContextMenuInteraction, PermissionResolvable, GuildMember, Permissions } from 'discord.js';
|
|
4
6
|
|
|
5
|
-
declare
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
declare const
|
|
12
|
-
|
|
13
|
-
declare
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
declare type ModuleHookStore = Collection<string, Function[]>;
|
|
8
|
+
declare const getModuleHookStore: (target: object) => ModuleHookStore;
|
|
9
|
+
declare const moduleHook: (name: string) => MethodDecorator;
|
|
10
|
+
|
|
11
|
+
declare type ComponentHookFn = (...args: any[]) => void | Promise<void>;
|
|
12
|
+
declare type ComponentHookStore = Collection<string, ComponentHookFn[]>;
|
|
13
|
+
declare const createComponentHook: (name: string, fn: ComponentHookFn) => MethodDecorator;
|
|
14
|
+
|
|
15
|
+
declare class ComponentArgumentDecorator<Options = unknown> {
|
|
16
|
+
options: Options;
|
|
17
|
+
constructor(options: Partial<Options>);
|
|
18
|
+
defaultOptions(): Options;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare class ComponentArgument {
|
|
22
|
+
type: unknown;
|
|
23
|
+
decorators: ComponentArgumentDecorator[];
|
|
24
|
+
constructor(type: unknown);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare class BaseComponent<Options = unknown, OptionsArg = Options> {
|
|
28
|
+
options: Options;
|
|
29
|
+
method: Function;
|
|
30
|
+
hooks: ComponentHookStore;
|
|
31
|
+
argTypes: Collection<number, ComponentArgument>;
|
|
32
|
+
constructor(options: OptionsArg, method: Function, argTypes: unknown[]);
|
|
33
|
+
convertOptions(options: OptionsArg): Options;
|
|
34
|
+
executeHook(target: object, name: string, args: unknown[]): Promise<void>;
|
|
35
|
+
execute(target: object, args: unknown[], beforeCallArgs?: unknown[]): Promise<any>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
declare type ComponentStore = Collection<string | symbol, BaseComponent>;
|
|
39
|
+
declare type ComponentArgumentStore = Collection<number, ComponentArgumentDecorator>;
|
|
40
|
+
declare const getComponentStore: (target: object) => ComponentStore;
|
|
41
|
+
declare const getComponent: (target: object, key: string | symbol) => BaseComponent<unknown, unknown> | undefined;
|
|
42
|
+
declare const createComponentDecorator: <Options, OptionArgs>(type: {
|
|
43
|
+
new (options: OptionArgs, method: Function, argTypes: unknown[]): BaseComponent<Options, OptionArgs>;
|
|
44
|
+
}) => (options: OptionArgs) => MethodDecorator;
|
|
45
|
+
declare const getComponentArgumentStore: (target: object, key: string | symbol) => ComponentArgumentStore;
|
|
46
|
+
declare const createArgumentDecorator: <Options>(type: {
|
|
47
|
+
new (options: Partial<Options>): ComponentArgumentDecorator<Options>;
|
|
48
|
+
}) => (options: Options) => ParameterDecorator;
|
|
49
|
+
|
|
50
|
+
declare type Options = {
|
|
51
|
+
component: typeof BaseComponent<unknown>;
|
|
52
|
+
type: Function;
|
|
53
|
+
parameterless: boolean;
|
|
16
54
|
};
|
|
17
|
-
declare
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
declare const option: (key: string) => ParameterDecorator;
|
|
21
|
-
|
|
22
|
-
declare type AppCommandArgument = {
|
|
23
|
-
type: any;
|
|
24
|
-
name?: string;
|
|
25
|
-
};
|
|
26
|
-
declare class AppCommand {
|
|
27
|
-
command: ApplicationCommandDataResolvable;
|
|
28
|
-
private run;
|
|
29
|
-
module: Module;
|
|
30
|
-
params: AppCommandArgument[];
|
|
31
|
-
guild: Snowflake | Snowflake[] | undefined;
|
|
32
|
-
private key;
|
|
33
|
-
get checks(): ApplicationCommandCheckFunction[];
|
|
34
|
-
execute(module: Module, args: any[]): any;
|
|
35
|
-
constructor(command: ApplicationCommandDataResolvable, run: Function, module: Module, params: AppCommandArgument[], guild: Snowflake | Snowflake[] | undefined, key: string | symbol);
|
|
55
|
+
declare class ConverterComponent extends BaseComponent<Options, Omit<Options, 'parameterless'> & {
|
|
56
|
+
parameterless?: boolean;
|
|
57
|
+
}> {
|
|
36
58
|
}
|
|
59
|
+
declare const argConverter: (options: Omit<Options, "parameterless"> & {
|
|
60
|
+
parameterless?: boolean | undefined;
|
|
61
|
+
}) => MethodDecorator;
|
|
37
62
|
|
|
38
|
-
declare
|
|
39
|
-
declare
|
|
40
|
-
componentId: string;
|
|
41
|
-
componentType: Exclude<MessageComponentType, 'ACTION_ROW'>;
|
|
42
|
-
execute: MessageComponentExecutor;
|
|
43
|
-
constructor(componentId: string, componentType: Exclude<MessageComponentType, 'ACTION_ROW'>, execute: MessageComponentExecutor);
|
|
44
|
-
run(module: Module, i: MessageComponentInteraction): void | Promise<void>;
|
|
45
|
-
}
|
|
63
|
+
declare const createCheckDecorator: (fn: ComponentHookFn) => MethodDecorator;
|
|
64
|
+
declare const ownerOnly: MethodDecorator;
|
|
46
65
|
|
|
47
|
-
declare class
|
|
48
|
-
client: CommandClient;
|
|
49
|
-
constructor(client: CommandClient);
|
|
50
|
-
modules: Collection<symbol, Module>;
|
|
51
|
-
private get logger();
|
|
52
|
-
get commands(): Command[];
|
|
53
|
-
get argumentConverters(): ArgumentConverter[];
|
|
54
|
-
get applicationCommandArgumentConverters(): ApplicationCommandArgumentConverter[];
|
|
55
|
-
get applicationCommands(): AppCommand[];
|
|
56
|
-
get messageComponentHandlers(): MessageComponentHandler[];
|
|
57
|
-
registerModule(module: Module): Module;
|
|
58
|
-
loadModulesIn(dir: string, absolute?: boolean): Promise<void>;
|
|
59
|
-
loadModule(file: string, absolute?: boolean): Promise<Module>;
|
|
60
|
-
syncCommands(): Promise<void>;
|
|
61
|
-
unregisterModule(module: Module): Promise<Module>;
|
|
62
|
-
unloadModule(module: Module): Promise<void>;
|
|
63
|
-
reloadModule(module: Module): Promise<boolean>;
|
|
64
|
-
reloadAll(): Promise<{
|
|
65
|
-
path: string;
|
|
66
|
-
success: boolean;
|
|
67
|
-
error?: Error | undefined;
|
|
68
|
-
}[]>;
|
|
66
|
+
declare class OwnerOnlyError {
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
interface CommandClientOptions {
|
|
84
|
-
command: CommandOptions$1;
|
|
85
|
-
owners: 'auto' | Snowflake[];
|
|
86
|
-
slashCommands: SlashCommandOptions;
|
|
87
|
-
applicationCommands: ApplicationCommandOptions;
|
|
88
|
-
}
|
|
89
|
-
interface CommandClientOptionsParam {
|
|
90
|
-
command: Partial<CommandOptions$1>;
|
|
91
|
-
owners: 'auto' | string[];
|
|
92
|
-
slashCommands: Partial<SlashCommandOptions>;
|
|
93
|
-
applicationCommands: Partial<ApplicationCommandOptions>;
|
|
94
|
-
}
|
|
95
|
-
declare class CommandClient {
|
|
96
|
-
options: CommandClientOptions;
|
|
97
|
-
owners: string[];
|
|
98
|
-
registry: Registry;
|
|
99
|
-
client: Client;
|
|
100
|
-
coolDownAdapter: CoolDownAdapter;
|
|
101
|
-
logger: Logger;
|
|
102
|
-
private _isReady;
|
|
103
|
-
private fetchOwners;
|
|
104
|
-
ready(): Promise<void>;
|
|
105
|
-
constructor({ client, coolDownAdapter, logger, ...options }: Partial<CommandClientOptionsParam> & {
|
|
106
|
-
client: Client;
|
|
107
|
-
coolDownAdapter?: CoolDownAdapter;
|
|
108
|
-
logger?: Logger;
|
|
109
|
-
});
|
|
69
|
+
declare class ListenerComponent extends BaseComponent<{
|
|
70
|
+
emitter: string;
|
|
71
|
+
event: string;
|
|
72
|
+
}, {
|
|
73
|
+
emitter?: string;
|
|
74
|
+
event: string;
|
|
75
|
+
}> {
|
|
76
|
+
defaultOptions(): {
|
|
77
|
+
emitter: string;
|
|
78
|
+
};
|
|
79
|
+
constructor(options: ListenerComponent['options'], method: Function, argTypes: unknown[]);
|
|
110
80
|
}
|
|
81
|
+
declare const listener: (options: {
|
|
82
|
+
emitter?: string | undefined;
|
|
83
|
+
event: string;
|
|
84
|
+
}) => MethodDecorator;
|
|
111
85
|
|
|
112
|
-
declare
|
|
113
|
-
commandClient: CommandClient;
|
|
114
|
-
get
|
|
115
|
-
|
|
116
|
-
get
|
|
117
|
-
|
|
118
|
-
get applicationCommandArgumentConverters(): ApplicationCommandArgumentConverter[];
|
|
119
|
-
get applicationCommands(): AppCommand[];
|
|
120
|
-
get messageComponentHandlers(): MessageComponentHandler[];
|
|
121
|
-
get path(): string | undefined;
|
|
122
|
-
load(): void;
|
|
123
|
-
unload(): void;
|
|
124
|
-
beforeReload(): void;
|
|
125
|
-
afterReload(): void;
|
|
86
|
+
declare class Extension {
|
|
87
|
+
protected get commandClient(): CommandClient;
|
|
88
|
+
protected get client(): discord_js.Client<boolean>;
|
|
89
|
+
protected _logger?: Logger;
|
|
90
|
+
protected get logger(): Logger;
|
|
91
|
+
protected convertArguments(component: typeof BaseComponent<unknown>, argList: unknown[], args: Collection<number, ComponentArgument>, getConverterArgs: (arg: ComponentArgument, index: number, converter: ConverterComponent) => unknown[] | Promise<unknown[]>): Promise<void>;
|
|
126
92
|
}
|
|
127
93
|
|
|
128
|
-
declare
|
|
129
|
-
|
|
130
|
-
type: any;
|
|
131
|
-
rest: boolean;
|
|
132
|
-
};
|
|
133
|
-
declare type CheckFunction = (msg: Message) => boolean | Promise<boolean>;
|
|
134
|
-
declare type ApplicationCommandCheckFunction = (i: CommandInteraction | MessageComponentInteraction | ContextMenuInteraction) => boolean | Promise<boolean>;
|
|
135
|
-
declare class Command {
|
|
136
|
-
private run;
|
|
137
|
-
argTypes: Argument[];
|
|
138
|
-
name: string;
|
|
139
|
-
aliases: string[] | ((msg: Message) => string[] | Promise<string[]>);
|
|
140
|
-
module: Module;
|
|
141
|
-
key: symbol | string;
|
|
142
|
-
execute(module: Module, args: any[]): any;
|
|
143
|
-
get checks(): CheckFunction[];
|
|
144
|
-
constructor(run: Function, argTypes: Argument[], name: string, aliases: string[] | ((msg: Message) => string[] | Promise<string[]>), module: Module, key: symbol | string);
|
|
94
|
+
declare class CTSExtension extends Extension {
|
|
95
|
+
protected get logger(): tslog.Logger;
|
|
145
96
|
}
|
|
146
97
|
|
|
147
|
-
declare type
|
|
98
|
+
declare type ApplicationCommandExtensionConfig = {
|
|
99
|
+
guilds?: Snowflake[];
|
|
100
|
+
};
|
|
101
|
+
declare class ApplicationCommandExtension extends CTSExtension {
|
|
102
|
+
config: ApplicationCommandExtensionConfig;
|
|
103
|
+
constructor(config: ApplicationCommandExtensionConfig);
|
|
104
|
+
interactionCreate(i: Interaction): Promise<void>;
|
|
105
|
+
load(): Promise<void>;
|
|
106
|
+
sync(): Promise<void>;
|
|
107
|
+
chatInteraction(i: ChatInputCommandInteraction): Promise<ChatInputCommandInteraction<discord_js.CacheType>>;
|
|
108
|
+
messageInteraction(i: MessageContextMenuCommandInteraction): Promise<MessageContextMenuCommandInteraction<discord_js.CacheType>>;
|
|
109
|
+
userInteraction(i: UserContextMenuCommandInteraction): Promise<UserContextMenuCommandInteraction<discord_js.CacheType>>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
declare type TextCommandOptions = {
|
|
148
113
|
name: string;
|
|
149
|
-
aliases
|
|
150
|
-
|
|
114
|
+
aliases?: string;
|
|
115
|
+
description?: string;
|
|
151
116
|
};
|
|
152
|
-
declare
|
|
153
|
-
declare const argumentConverter: (type: object, requireParameter?: boolean) => (target: Object, propertyKey: string) => void;
|
|
154
|
-
declare const applicationCommandArgumentConverter: (type: object) => (target: Object, propertyKey: string) => void;
|
|
155
|
-
declare const optional: ParameterDecorator;
|
|
156
|
-
declare const rest: ParameterDecorator;
|
|
157
|
-
declare const ownerOnly: MethodDecorator;
|
|
158
|
-
declare const guildOnly: MethodDecorator;
|
|
159
|
-
declare const dmOnly: MethodDecorator;
|
|
160
|
-
declare const requireUserPermissions: (permission: PermissionResolvable) => MethodDecorator;
|
|
161
|
-
declare const requireClientPermissions: (permission: PermissionResolvable) => MethodDecorator;
|
|
162
|
-
|
|
163
|
-
declare class ArgumentConverter {
|
|
164
|
-
type: object;
|
|
165
|
-
private run;
|
|
166
|
-
withoutParameter: boolean;
|
|
167
|
-
execute(module: Module, msg: Message, arg?: string): any;
|
|
168
|
-
constructor(type: object, run: Function, withoutParameter: boolean);
|
|
169
|
-
}
|
|
170
|
-
declare class ApplicationCommandArgumentConverter {
|
|
171
|
-
type: object;
|
|
172
|
-
private run;
|
|
173
|
-
execute(module: Module, interaction: CommandInteraction | ContextMenuInteraction): any;
|
|
174
|
-
constructor(type: object, run: Function);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
declare const createCheckDecorator: (execute: ((msg: Message) => boolean | Promise<boolean>) | null, executeApplicationCommand?: ((i: CommandInteraction | MessageComponentInteraction | ContextMenuInteraction) => boolean | Promise<boolean>) | undefined) => MethodDecorator;
|
|
178
|
-
|
|
179
|
-
declare enum CoolDownType {
|
|
180
|
-
USER = 0,
|
|
181
|
-
CHANNEL = 1,
|
|
182
|
-
GUILD = 2,
|
|
183
|
-
ROLE = 3,
|
|
184
|
-
CATEGORY = 4,
|
|
185
|
-
MEMBER = 5
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
declare const coolDown: (type: CoolDownType, seconds: number) => MethodDecorator;
|
|
189
|
-
|
|
190
|
-
interface CoolDownAdapter {
|
|
191
|
-
get(id: string): Promise<number | undefined>;
|
|
192
|
-
set(id: string, value: number): Promise<void>;
|
|
193
|
-
}
|
|
194
|
-
declare class DefaultCoolDownAdapter implements CoolDownAdapter {
|
|
195
|
-
map: Collection<string, number>;
|
|
196
|
-
get(id: string): Promise<number | undefined>;
|
|
197
|
-
set(id: string, value: number): Promise<void>;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
declare class CoolDownError extends Error {
|
|
201
|
-
endsAt: Date;
|
|
202
|
-
constructor(endsAt: Date);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
declare module 'discord.js' {
|
|
206
|
-
interface Message {
|
|
207
|
-
data: {
|
|
208
|
-
command: Command | null;
|
|
209
|
-
prefix: string;
|
|
210
|
-
cts: CommandClient;
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
interface CommandInteraction {
|
|
214
|
-
data: {
|
|
215
|
-
command: AppCommand;
|
|
216
|
-
cts: CommandClient;
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
interface MessageComponentInteraction {
|
|
220
|
-
data: {
|
|
221
|
-
command: AppCommand;
|
|
222
|
-
cts: CommandClient;
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
interface ContextMenuInteraction {
|
|
226
|
-
data: {
|
|
227
|
-
command: AppCommand;
|
|
228
|
-
cts: CommandClient;
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
declare class InvalidTargetError extends Error {
|
|
234
|
-
constructor();
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
declare class ModuleLoadError extends Error {
|
|
238
|
-
error: Error;
|
|
239
|
-
constructor(file: string, error: Error);
|
|
240
|
-
}
|
|
241
|
-
declare class InvalidModuleError extends Error {
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
declare class ArgumentNotProvided extends Error {
|
|
245
|
-
index: number;
|
|
246
|
-
command: Command;
|
|
247
|
-
msg: Message;
|
|
248
|
-
constructor(index: number, command: Command, msg: Message);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
declare class ArgumentConverterNotFound extends Error {
|
|
252
|
-
type: Argument;
|
|
253
|
-
msg: Message;
|
|
254
|
-
constructor(type: Argument, msg: Message);
|
|
255
|
-
}
|
|
256
|
-
declare class ApplicationCommandArgumentConverterNotFound extends Error {
|
|
257
|
-
type: AppCommandArgument;
|
|
258
|
-
interaction: CommandInteraction | ContextMenuInteraction;
|
|
259
|
-
constructor(type: AppCommandArgument, interaction: CommandInteraction | ContextMenuInteraction);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
declare class CommandCheckFailed extends Error {
|
|
263
|
-
msg: Message;
|
|
264
|
-
command: Command;
|
|
265
|
-
constructor(msg: Message, command: Command);
|
|
266
|
-
}
|
|
267
|
-
declare class ApplicationCommandCheckFailed extends Error {
|
|
268
|
-
interaction: CommandInteraction | MessageComponentInteraction | ContextMenuInteraction;
|
|
269
|
-
command: AppCommand;
|
|
270
|
-
constructor(interaction: CommandInteraction | MessageComponentInteraction | ContextMenuInteraction, command: AppCommand);
|
|
117
|
+
declare class TextCommandComponent extends BaseComponent<TextCommandOptions> {
|
|
271
118
|
}
|
|
119
|
+
declare const command: (options: TextCommandOptions) => MethodDecorator;
|
|
272
120
|
|
|
273
|
-
declare
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
constructor(user: GuildMember, permissions: Permissions);
|
|
277
|
-
}
|
|
278
|
-
declare class ClientPermissionRequired extends Error {
|
|
279
|
-
permissions: Permissions;
|
|
280
|
-
constructor(permissions: Permissions);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
declare class OwnerOnlyCommandError extends Error {
|
|
284
|
-
constructor();
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
declare class GuildOnlyCommandError extends Error {
|
|
288
|
-
constructor();
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
declare class DMOnlyCommandError extends Error {
|
|
292
|
-
constructor();
|
|
293
|
-
}
|
|
121
|
+
declare type TextCommandConfig = {
|
|
122
|
+
prefix: string | string[] | ((msg: Message) => Promise<string | string[]> | string | string[]);
|
|
123
|
+
};
|
|
294
124
|
|
|
295
|
-
declare class
|
|
296
|
-
i: CommandInteraction;
|
|
297
|
-
constructor(i: CommandInteraction);
|
|
125
|
+
declare class TextCommandRestOption extends ComponentArgumentDecorator<void> {
|
|
298
126
|
}
|
|
127
|
+
declare const rest: (options: void) => ParameterDecorator;
|
|
299
128
|
|
|
300
|
-
declare class
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
129
|
+
declare class CommandClient extends EventEmitter {
|
|
130
|
+
discord: Client;
|
|
131
|
+
logger: Logger;
|
|
132
|
+
ctsLogger: Logger;
|
|
133
|
+
registry: Registry;
|
|
134
|
+
owners: Set<Snowflake>;
|
|
135
|
+
constructor(discord: Client, logger?: Logger);
|
|
136
|
+
fetchOwners(): Promise<void>;
|
|
137
|
+
enableApplicationCommandsExtension(config: ApplicationCommandExtensionConfig): Promise<void>;
|
|
138
|
+
enableTextCommandsExtension(config: TextCommandConfig): Promise<void>;
|
|
139
|
+
getApplicationCommandsExtension(): ApplicationCommandExtension | undefined;
|
|
140
|
+
static getFromModule(ext: object): CommandClient;
|
|
305
141
|
}
|
|
306
142
|
|
|
307
|
-
declare class
|
|
308
|
-
|
|
143
|
+
declare class Registry {
|
|
144
|
+
client: CommandClient;
|
|
145
|
+
extensions: object[];
|
|
146
|
+
emitters: Collection<string, EventEmitter>;
|
|
147
|
+
logger: Logger;
|
|
148
|
+
constructor(logger: Logger, client: CommandClient);
|
|
149
|
+
getComponentsWithTypeGlobal<T extends typeof BaseComponent<Config>, Config>(type: T): InstanceType<T>[];
|
|
150
|
+
getComponentsWithType<T extends typeof BaseComponent<Config>, Config>(ext: object, type: T): InstanceType<T>[];
|
|
151
|
+
registerEventListeners(ext: object): void;
|
|
152
|
+
unregisterEventListeners(ext: object): void;
|
|
153
|
+
registerModule(ext: object): Promise<void>;
|
|
154
|
+
unregisterModule(ext: object): Promise<void>;
|
|
155
|
+
runModuleHook(ext: object, hookName: string, ...args: unknown[]): void;
|
|
156
|
+
registerEventEmitter(name: string, emitter: EventEmitter): void;
|
|
309
157
|
}
|
|
310
158
|
|
|
311
|
-
declare class
|
|
312
|
-
|
|
159
|
+
declare class ApplicationCommandComponent extends BaseComponent<(UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, 'options'>) & {
|
|
160
|
+
type: ApplicationCommandType;
|
|
161
|
+
}> {
|
|
313
162
|
}
|
|
314
|
-
declare const
|
|
163
|
+
declare const applicationCommand: (options: (UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, "options">) & {
|
|
164
|
+
type: ApplicationCommandType;
|
|
165
|
+
}) => MethodDecorator;
|
|
315
166
|
|
|
316
|
-
declare
|
|
317
|
-
constructor(id: string, execute: MessageComponentExecutor);
|
|
318
|
-
}
|
|
319
|
-
declare const messageSelectMenu: (id: string) => MethodDecorator;
|
|
167
|
+
declare const option: (options: APIApplicationCommandOption) => ParameterDecorator;
|
|
320
168
|
|
|
321
|
-
export {
|
|
169
|
+
export { ApplicationCommandComponent, BaseComponent, CommandClient, ComponentArgument, ComponentArgumentDecorator, ComponentHookStore, ConverterComponent, Extension, ListenerComponent, OwnerOnlyError, Registry, TextCommandComponent, TextCommandConfig, TextCommandRestOption, applicationCommand, argConverter, command, createArgumentDecorator, createCheckDecorator, createComponentDecorator, createComponentHook, getComponent, getComponentArgumentStore, getComponentStore, getModuleHookStore, listener, moduleHook, option, ownerOnly, rest };
|