@pikokr/command.ts 4.0.7 → 5.0.0-dev.1687555
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 +1 -1
- 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 +134 -296
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/docs/index.yml +1 -1
- package/package.json +21 -14
- 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 +56 -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 +71 -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 +11 -0
- package/src/textCommand/index.ts +1 -0
- package/test/index.ts +75 -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@v1
|
|
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@v1
|
|
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@v1
|
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,159 @@
|
|
|
1
|
+
import * as discord_js from 'discord.js';
|
|
2
|
+
import { Collection, Snowflake, Interaction, ChatInputCommandInteraction, MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction, 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);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
declare type MessageComponentExecutor = (i: MessageComponentInteraction) => void | Promise<void>;
|
|
39
|
-
declare class MessageComponentHandler {
|
|
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>;
|
|
55
|
+
declare class ConverterComponent extends BaseComponent<Options, Options & {
|
|
56
|
+
parameterless?: boolean;
|
|
57
|
+
}> {
|
|
45
58
|
}
|
|
59
|
+
declare const argConverter: (options: Options & {
|
|
60
|
+
parameterless?: boolean | undefined;
|
|
61
|
+
}) => MethodDecorator;
|
|
46
62
|
|
|
47
|
-
declare
|
|
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
|
-
}[]>;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
interface CommandOptions$1 {
|
|
72
|
-
prefix: string | ((msg: any) => string | Promise<string | string[]> | string[]) | string[];
|
|
73
|
-
check: (msg: Message) => boolean | Promise<boolean>;
|
|
74
|
-
}
|
|
75
|
-
interface SlashCommandOptions {
|
|
76
|
-
check: (i: CommandInteraction) => boolean | Promise<boolean>;
|
|
77
|
-
}
|
|
78
|
-
interface ApplicationCommandOptions {
|
|
79
|
-
guild?: Snowflake | Snowflake[];
|
|
80
|
-
autoSync: boolean;
|
|
81
|
-
beforeRunCheck: (i: Interaction) => void | Promise<void>;
|
|
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
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
declare abstract class Module {
|
|
113
|
-
commandClient: CommandClient;
|
|
114
|
-
get logger(): tslog.Logger;
|
|
115
|
-
get commands(): Command[];
|
|
116
|
-
get listeners(): Listener[];
|
|
117
|
-
get argumentConverters(): ArgumentConverter[];
|
|
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;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
declare type Argument = {
|
|
129
|
-
optional: boolean;
|
|
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);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
declare type CommandOptions = {
|
|
148
|
-
name: string;
|
|
149
|
-
aliases: string[] | ((msg: Message) => string[]);
|
|
150
|
-
optionTypes?: any[];
|
|
151
|
-
};
|
|
152
|
-
declare const command: (options?: Partial<CommandOptions>) => (target: Object, propertyKey: string) => void;
|
|
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;
|
|
63
|
+
declare const createCheckDecorator: (fn: ComponentHookFn) => MethodDecorator;
|
|
157
64
|
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
65
|
|
|
179
|
-
declare
|
|
180
|
-
USER = 0,
|
|
181
|
-
CHANNEL = 1,
|
|
182
|
-
GUILD = 2,
|
|
183
|
-
ROLE = 3,
|
|
184
|
-
CATEGORY = 4,
|
|
185
|
-
MEMBER = 5
|
|
66
|
+
declare class OwnerOnlyError {
|
|
186
67
|
}
|
|
187
68
|
|
|
188
|
-
declare
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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[]);
|
|
198
80
|
}
|
|
81
|
+
declare const listener: (options: {
|
|
82
|
+
emitter?: string | undefined;
|
|
83
|
+
event: string;
|
|
84
|
+
}) => MethodDecorator;
|
|
199
85
|
|
|
200
|
-
declare class
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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 {
|
|
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) => unknown[] | Promise<unknown[]>): Promise<void>;
|
|
242
92
|
}
|
|
243
93
|
|
|
244
|
-
declare class
|
|
245
|
-
|
|
246
|
-
command: Command;
|
|
247
|
-
msg: Message;
|
|
248
|
-
constructor(index: number, command: Command, msg: Message);
|
|
94
|
+
declare class CTSExtension extends Extension {
|
|
95
|
+
protected get logger(): tslog.Logger;
|
|
249
96
|
}
|
|
250
97
|
|
|
251
|
-
declare
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
}
|
|
294
|
-
|
|
295
|
-
declare class SlashCommandGlobalCheckError extends Error {
|
|
296
|
-
i: CommandInteraction;
|
|
297
|
-
constructor(i: CommandInteraction);
|
|
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 class CommandClient extends EventEmitter {
|
|
113
|
+
discord: Client;
|
|
114
|
+
logger: Logger;
|
|
115
|
+
ctsLogger: Logger;
|
|
116
|
+
registry: Registry;
|
|
117
|
+
owners: Set<Snowflake>;
|
|
118
|
+
constructor(discord: Client, logger?: Logger);
|
|
119
|
+
fetchOwners(): Promise<void>;
|
|
120
|
+
enableApplicationCommandsExtension(config: ApplicationCommandExtensionConfig): Promise<void>;
|
|
121
|
+
getApplicationCommandsExtension(): ApplicationCommandExtension | undefined;
|
|
122
|
+
static getFromModule(ext: object): CommandClient;
|
|
298
123
|
}
|
|
299
124
|
|
|
300
|
-
declare class
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
125
|
+
declare class Registry {
|
|
126
|
+
client: CommandClient;
|
|
127
|
+
extensions: object[];
|
|
128
|
+
emitters: Collection<string, EventEmitter>;
|
|
129
|
+
logger: Logger;
|
|
130
|
+
constructor(logger: Logger, client: CommandClient);
|
|
131
|
+
getComponentsWithTypeGlobal<T extends typeof BaseComponent<Config>, Config>(type: T): InstanceType<T>[];
|
|
132
|
+
getComponentsWithType<T extends typeof BaseComponent<Config>, Config>(ext: object, type: T): InstanceType<T>[];
|
|
133
|
+
registerEventListeners(ext: object): void;
|
|
134
|
+
unregisterEventListeners(ext: object): void;
|
|
135
|
+
registerModule(ext: object): Promise<void>;
|
|
136
|
+
unregisterModule(ext: object): Promise<void>;
|
|
137
|
+
runModuleHook(ext: object, hookName: string, ...args: unknown[]): void;
|
|
138
|
+
registerEventEmitter(name: string, emitter: EventEmitter): void;
|
|
305
139
|
}
|
|
306
140
|
|
|
307
|
-
declare class
|
|
308
|
-
|
|
141
|
+
declare class ApplicationCommandComponent extends BaseComponent<(UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, 'options'>) & {
|
|
142
|
+
type: ApplicationCommandType;
|
|
143
|
+
}> {
|
|
309
144
|
}
|
|
145
|
+
declare const applicationCommand: (options: (UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, "options">) & {
|
|
146
|
+
type: ApplicationCommandType;
|
|
147
|
+
}) => MethodDecorator;
|
|
310
148
|
|
|
311
|
-
declare
|
|
312
|
-
constructor(id: string, execute: MessageComponentExecutor);
|
|
313
|
-
}
|
|
314
|
-
declare const messageButton: (id: string) => MethodDecorator;
|
|
149
|
+
declare const option: (options: APIApplicationCommandOption) => ParameterDecorator;
|
|
315
150
|
|
|
316
|
-
declare
|
|
317
|
-
|
|
151
|
+
declare type TextCommandOptions = {
|
|
152
|
+
name: string;
|
|
153
|
+
description?: string;
|
|
154
|
+
};
|
|
155
|
+
declare class TextCommandComponent extends BaseComponent<TextCommandOptions> {
|
|
318
156
|
}
|
|
319
|
-
declare const
|
|
157
|
+
declare const command: (options: TextCommandOptions) => MethodDecorator;
|
|
320
158
|
|
|
321
|
-
export {
|
|
159
|
+
export { ApplicationCommandComponent, BaseComponent, CommandClient, ComponentArgument, ComponentArgumentDecorator, ComponentHookStore, ConverterComponent, Extension, ListenerComponent, OwnerOnlyError, Registry, TextCommandComponent, applicationCommand, argConverter, command, createArgumentDecorator, createCheckDecorator, createComponentDecorator, createComponentHook, getComponent, getComponentArgumentStore, getComponentStore, getModuleHookStore, listener, moduleHook, option, ownerOnly };
|