@ezzi/base 1.0.3 → 1.1.0
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/creators/setup.d.ts +2 -2
- package/dist/creators/setup.js +8 -39
- package/package.json +1 -1
package/dist/creators/setup.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApplicationCommandType, InteractionContextType, type CacheType, type ClientEvents, type PermissionResolvable } from "discord.js";
|
|
2
2
|
import { type BaseCommandsConfig, type BaseEventsConfig, type BaseRespondersConfig } from "../app.js";
|
|
3
|
-
import { type AppCommandData, type CommandType } from "./commands/command.js";
|
|
3
|
+
import { Command, type AppCommandData, type CommandType } from "./commands/command.js";
|
|
4
4
|
import { type EventData } from "./events/event.js";
|
|
5
5
|
import { Responder, type ResponderData, type ResponderType } from "./responders/responder.js";
|
|
6
6
|
export interface SetupCreatorsOptions {
|
|
@@ -19,7 +19,7 @@ export interface SetupCreatorsOptions {
|
|
|
19
19
|
* functions used to create each type of component.
|
|
20
20
|
*/
|
|
21
21
|
export declare function setupCreators(options?: SetupCreatorsOptions): {
|
|
22
|
-
createCommand<T extends CommandType = ApplicationCommandType.ChatInput,
|
|
22
|
+
createCommand<T extends CommandType = ApplicationCommandType.ChatInput, const C extends readonly InteractionContextType[] = [InteractionContextType.Guild], R = void>(data: AppCommandData<T, C, R>): Command<T, C, R>;
|
|
23
23
|
createEvent<EventName extends keyof ClientEvents>(data: EventData<EventName>): void;
|
|
24
24
|
createResponder<Path extends string, const Types extends readonly ResponderType[], Schema, Cache extends CacheType = CacheType>(data: ResponderData<Path, Types, Schema, Cache>): Responder<string, readonly ResponderType[], unknown, CacheType>;
|
|
25
25
|
};
|
package/dist/creators/setup.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// src/creators/setup.ts
|
|
2
|
-
import {
|
|
3
|
-
ApplicationCommandOptionType,
|
|
4
|
-
ApplicationCommandType
|
|
5
|
-
} from "discord.js";
|
|
6
2
|
import {
|
|
7
3
|
EzziApp
|
|
8
4
|
} from "../app.js";
|
|
5
|
+
import {
|
|
6
|
+
Command
|
|
7
|
+
} from "./commands/command.js";
|
|
9
8
|
import { Event } from "./events/event.js";
|
|
10
9
|
import {
|
|
11
10
|
Responder
|
|
@@ -24,46 +23,16 @@ function setupCreators(options = {}) {
|
|
|
24
23
|
return {
|
|
25
24
|
createCommand(data) {
|
|
26
25
|
const currentApp = EzziApp.getInstance();
|
|
27
|
-
if (defaultMemberPerms)
|
|
26
|
+
if (defaultMemberPerms)
|
|
28
27
|
data.defaultMemberPermissions ??= defaultMemberPerms;
|
|
29
|
-
|
|
30
|
-
if (defaultBotPerms && !data.botPermissions?.length) {
|
|
28
|
+
if (defaultBotPerms && !data.botPermissions?.length)
|
|
31
29
|
data.botPermissions = defaultBotPerms;
|
|
32
|
-
|
|
33
|
-
const resolved = currentApp.commands.set(data);
|
|
30
|
+
const command = new Command(data);
|
|
31
|
+
const resolved = currentApp.commands.set(command.data);
|
|
34
32
|
if (typeof currentApp.commands.addLog === "function") {
|
|
35
33
|
currentApp.commands.addLog(resolved);
|
|
36
34
|
}
|
|
37
|
-
|
|
38
|
-
return resolved;
|
|
39
|
-
}
|
|
40
|
-
const commandName = resolved.name;
|
|
41
|
-
const createSubcommand = (group) => (subData) => {
|
|
42
|
-
const subApp = EzziApp.getInstance();
|
|
43
|
-
if (defaultBotPerms && !subData.botPermissions?.length) {
|
|
44
|
-
subData = { ...subData, botPermissions: defaultBotPerms };
|
|
45
|
-
}
|
|
46
|
-
subApp.commands.addModule(commandName, {
|
|
47
|
-
...subData,
|
|
48
|
-
group,
|
|
49
|
-
type: ApplicationCommandOptionType.Subcommand
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
return Object.assign(data, {
|
|
53
|
-
...resolved,
|
|
54
|
-
group(groupData) {
|
|
55
|
-
const groupApp = EzziApp.getInstance();
|
|
56
|
-
if (defaultBotPerms && !groupData.botPermissions?.length) {
|
|
57
|
-
groupData = { ...groupData, botPermissions: defaultBotPerms };
|
|
58
|
-
}
|
|
59
|
-
groupApp.commands.addModule(commandName, {
|
|
60
|
-
...groupData,
|
|
61
|
-
type: ApplicationCommandOptionType.SubcommandGroup
|
|
62
|
-
});
|
|
63
|
-
return { subcommand: createSubcommand(groupData.name) };
|
|
64
|
-
},
|
|
65
|
-
subcommand: createSubcommand()
|
|
66
|
-
});
|
|
35
|
+
return command;
|
|
67
36
|
},
|
|
68
37
|
createEvent(data) {
|
|
69
38
|
const currentApp = EzziApp.getInstance();
|