Skip to content

Commit 1115be7

Browse files
committed
update type names + remove duplicates
1 parent bb99226 commit 1115be7

File tree

7 files changed

+26
-21
lines changed

7 files changed

+26
-21
lines changed

packages/commandkit/src/CommandKit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { CommandHandler, EventHandler, ValidationHandler } from './handlers';
22
import { CommandKitData, CommandKitOptions } from './typings';
3-
import { CommandFileObject } from './types';
3+
import { CommandObject } from './types';
44
import colors from 'colors/safe';
55

66
export class CommandKit {
@@ -68,7 +68,7 @@ export class CommandKit {
6868
*
6969
* @returns An array of command objects
7070
*/
71-
get commands(): CommandFileObject[] {
71+
get commands(): CommandObject[] {
7272
const commands = this.#data.commands.map((cmd) => {
7373
const { run, ...command } = cmd;
7474
return command;

packages/commandkit/src/handlers/command-handler/typings.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ChatInputCommandInteraction, Client, ContextMenuCommandInteraction } from 'discord.js';
2-
import { ContextCommandObject, SlashCommandObject } from '../../typings';
32
import { CommandKit } from '../../CommandKit';
3+
import { CommandFileObject } from '../../typings';
44

55
export interface CommandHandlerOptions {
66
client: Client;
@@ -14,12 +14,12 @@ export interface CommandHandlerOptions {
1414
}
1515

1616
export interface CommandHandlerData extends CommandHandlerOptions {
17-
commands: Array<SlashCommandObject | ContextCommandObject>;
17+
commands: CommandFileObject[];
1818
builtInValidations: Array<BuiltInValidation>;
1919
}
2020

2121
export interface BuiltInValidationParams {
22-
targetCommand: SlashCommandObject | ContextCommandObject;
22+
targetCommand: CommandFileObject;
2323
interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction;
2424
handlerData: CommandHandlerData;
2525
}

packages/commandkit/src/types/index.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type {
88
APIApplicationCommandSubcommandGroupOption,
99
} from 'discord.js';
1010
import type { CommandKit } from '../CommandKit';
11-
import type { ContextCommandObject, SlashCommandObject } from '../typings';
11+
import type { CommandFileObject } from '../typings';
1212

1313
export interface CommandProps {
1414
interaction: CommandInteraction;
@@ -31,7 +31,7 @@ export interface ContextMenuCommandProps {
3131
export interface ValidationFunctionProps {
3232
interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction;
3333
client: Client<true>;
34-
commandObj: SlashCommandObject | ContextCommandObject;
34+
commandObj: CommandObject;
3535
handler: CommandKit;
3636
}
3737

@@ -97,7 +97,4 @@ export type CommandData = {
9797
>;
9898
};
9999

100-
export interface CommandFileObject {
101-
data: CommandData;
102-
options?: CommandOptions;
103-
}
100+
export type CommandObject = Omit<CommandFileObject, 'run'>;

packages/commandkit/src/typings.d.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,10 @@ export interface CommandKitOptions {
1313
}
1414

1515
export interface CommandKitData extends CommandKitOptions {
16-
commands: Array<SlashCommandObject | ContextCommandObject>;
16+
commands: CommandFileObject[];
1717
}
1818

19-
export interface SlashCommandObject {
20-
data: CommandData;
21-
options?: CommandOptions;
22-
run: ({}: { interaction: Interaction; client: Client; handler: CommandKit }) => void;
23-
}
24-
25-
export interface ContextCommandObject {
19+
export interface CommandFileObject {
2620
data: CommandData;
2721
options?: CommandOptions;
2822
run: ({}: { interaction: Interaction; client: Client; handler: CommandKit }) => void;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { Client } from 'discord.js';
2+
import type { CommandKit } from '../../../src';
3+
4+
export default function (c: Client<true>, client, handler: CommandKit) {
5+
console.log(`${c.user.username} is online.`);
6+
}

packages/commandkit/tests/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const client = new Client({
88
intents: ['Guilds', 'GuildMembers', 'GuildMessages', 'MessageContent'],
99
});
1010

11-
client.on('ready', (c) => console.log(`${c.user.username} is online`));
12-
1311
new CommandKit({
1412
client,
1513
commandsPath: `${__dirname}/commands`,
14+
eventsPath: `${__dirname}/events`,
15+
validationsPath: `${__dirname}/validations`,
1616
});
1717

1818
client.login(process.env.TOKEN);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { ValidationFunctionProps } from '../../src';
2+
3+
export default function ({ interaction, commandObj, handler }: ValidationFunctionProps) {
4+
console.log(commandObj);
5+
console.log(handler.commands);
6+
7+
return true;
8+
}

0 commit comments

Comments
 (0)