Skip to content

Commit

Permalink
update github actions + centralise types
Browse files Browse the repository at this point in the history
  • Loading branch information
notunderctrl committed Dec 14, 2024
1 parent e2a01f3 commit c78f2a4
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 147 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dev-commandkit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: (CommandKit) Publish Dev Build
on:
push:
branches:
- master
- main
paths:
- 'packages/commandkit/**'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dev-create-commandkit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: (Create CommandKit) Publish Dev Build
on:
push:
branches:
- master
- main
paths:
- 'packages/create-commandkit/**'

Expand Down
10 changes: 2 additions & 8 deletions packages/commandkit/src/CommandKit.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import type {
CommandKitData,
CommandKitOptions,
ReloadOptions,
} from './typings';
import type { CommandKitData, CommandKitOptions, ReloadOptions } from './types';
import type { CommandObject } from './types';

import { CommandHandler, EventHandler, ValidationHandler } from './handlers';

import colors from './utils/colors';

export class CommandKit {
Expand All @@ -17,7 +11,7 @@ export class CommandKit {
* Create a new command and event handler with CommandKit.
*
* @param options - The default CommandKit configuration.
* @see {@link https://commandkit.js.org/docs/commandkit-setup}
* @see {@link https://commandkit.js.org/guide/commandkit-setup}
*/
constructor(options: CommandKitOptions) {
if (!options.client) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
CommandHandlerOptions,
CommandKitInteraction,
} from './typings';
import type { CommandFileObject, ReloadOptions } from '../../typings';
import type { CommandFileObject, ReloadOptions } from '../../types';

import { toFileURL } from '../../utils/resolve-file-url';
import { getFilePaths } from '../../utils/get-paths';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ApplicationCommandDataResolvable, Client } from 'discord.js';
import type { CommandFileObject, ReloadOptions } from '../../../typings';
import type { CommandFileObject, ReloadOptions } from '../../../types';

import colors from '../../../utils/colors';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
GuildApplicationCommandManager,
ApplicationCommandDataResolvable,
} from 'discord.js';
import type { CommandFileObject, ReloadOptions } from '../../../typings';
import type { CommandFileObject, ReloadOptions } from '../../../types';

import areSlashCommandsDifferent from '../utils/areSlashCommandsDifferent';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
ContextMenuCommandInteraction,
} from 'discord.js';
import type { CommandKit } from '../../CommandKit';
import type { CommandFileObject } from '../../typings';
import type { CommandFileObject } from '../../types';
import type { ValidationHandler } from '../validation-handler/ValidationHandler';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,129 @@
import type {
RESTPostAPIApplicationCommandsJSONBody,
MessageContextMenuCommandInteraction,
UserContextMenuCommandInteraction,
ContextMenuCommandInteraction,
ChatInputCommandInteraction,
AutocompleteInteraction,
PermissionsString,
CacheType,
ChatInputCommandInteraction,
Client,
ContextMenuCommandInteraction,
Interaction,
MessageContextMenuCommandInteraction,
PermissionsString,
RESTPostAPIApplicationCommandsJSONBody,
UserContextMenuCommandInteraction,
} from 'discord.js';
import type { CommandKit } from '../CommandKit';

import type { CommandKit } from './CommandKit';
import { CommandHandler, EventHandler, ValidationHandler } from './handlers';

/**
* Options for instantiating a CommandKit handler.
*/
export interface CommandKitOptions {
/**
* The Discord.js client object to use with CommandKit.
*/
client: Client;

/**
* The path to your commands directory.
*/
commandsPath?: string;

/**
* The path to your events directory.
*/
eventsPath?: string;

/**
* The path to the validations directory.
*/
validationsPath?: string;

/**
* List of development guild IDs to restrict devOnly commands to.
*/
devGuildIds?: string[];

/**
* List of developer user IDs to restrict devOnly commands to.
*/
devUserIds?: string[];

/**
* List of developer role IDs to restrict devOnly commands to.
*/
devRoleIds?: string[];

/**
* Skip CommandKit's built-in validations (for devOnly commands).
*/
skipBuiltInValidations?: boolean;

/**
* Bulk register application commands instead of one-by-one.
*/
bulkRegister?: boolean;
/**
* Options for experimental features.
*/
experimental?: {
/**
* Enable hooks. This allows you to utilize hooks such as `useInteraction()` to access the interaction object anywhere inside the command.
*/
hooks?: boolean;
};
}

/**
* Private data for the CommandKit class.
*/
export interface CommandKitData extends CommandKitOptions {
commandHandler?: CommandHandler;
eventHandler?: EventHandler;
validationHandler?: ValidationHandler;
}

/**
* Represents a command context.
*/
export interface CommandContext<
T extends Interaction,
Cached extends CacheType,
> {
/**
* The interaction that triggered this command.
*/
interaction: Interaction<CacheType>;
/**
* The client that instantiated this command.
*/
client: Client;
/**
* The command data.
*/
handler: CommandKit;
}

/**
* Represents a command file.
*/
export interface CommandFileObject {
data: CommandData;
options?: CommandOptions;
run: <Cached extends CacheType = CacheType>(
ctx: CommandContext<Interaction, Cached>,
) => Awaited<void>;
autocomplete?: <Cached extends CacheType = CacheType>(
ctx: CommandContext<Interaction, Cached>,
) => Awaited<void>;
filePath: string;
category: string | null;
[key: string]: any;
}

/**
* A reload type for commands.
*/
export type ReloadOptions = 'dev' | 'global' | ReloadType;

/**
* Props for command run functions.
Expand Down
126 changes: 0 additions & 126 deletions packages/commandkit/src/typings.ts

This file was deleted.

0 comments on commit c78f2a4

Please sign in to comment.