Skip to content

Commit

Permalink
Merge pull request #199 from ghostdevv/fix-command-event-type
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostdevv authored Apr 21, 2024
2 parents fb8b173 + dc3caf6 commit 3e7e26b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/clean-jobs-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"jellycommands": patch
---

fix: type error when manually adding command/event
5 changes: 3 additions & 2 deletions packages/jellycommands/src/commands/resolve.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { GuildCommands, GlobalCommands } from './types.d';
import { BaseCommand } from './types/BaseCommand';
import { JellyCommands } from '../JellyCommands';
import { AnyCommand } from './types/types';
import { read } from '../utils/files';

export const resolveCommands = async (
client: JellyCommands,
items: string | Array<string | BaseCommand>,
items: string | Array<string | AnyCommand>,
) => {
const commands = new Set<BaseCommand>();
const commands = new Set<AnyCommand>();

await read(items, (command) => {
if (!(command instanceof BaseCommand))
Expand Down
10 changes: 5 additions & 5 deletions packages/jellycommands/src/commands/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { BaseCommand } from './types/BaseCommand';
import { AnyCommand } from './types/types';

export type GlobalCommands = Set<BaseCommand>;
export type GuildCommands = Map<string, Set<BaseCommand>>;
export type GlobalCommands = Set<AnyCommand>;
export type GuildCommands = Map<string, Set<AnyCommand>>;

export type CommandIDMap = Map<string, BaseCommand>;
export type CommandIDMap = Map<string, AnyCommand>;

export interface ResolvedCommands {
guildCommands: GuildCommands;
globalCommands: GlobalCommands;
commands: Set<BaseCommand>;
commands: Set<AnyCommand>;
}
6 changes: 6 additions & 0 deletions packages/jellycommands/src/commands/types/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { MessageCommand } from './messageCommands/MessageCommand';
import type { UserCommand } from './userCommands/UserCommand';
import type { Command } from './commands/Command';
import type { BaseCommand } from './BaseCommand';

export type AnyCommand = BaseCommand | Command | UserCommand | MessageCommand;
5 changes: 3 additions & 2 deletions packages/jellycommands/src/options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ClientOptions, InteractionReplyOptions, MessagePayload } from 'discord.js';
import { BaseCommand } from './commands/types/BaseCommand.js';
import type { AnyCommand } from './commands/types/types';
import { snowflakeSchema } from './utils/zod.js';
import { Button } from './buttons/buttons';
import { Event } from './events/Event';
Expand Down Expand Up @@ -38,12 +39,12 @@ export interface JellyCommandsOptions {
/**
* Either an array of commands, or path(s) to commands
*/
commands?: string | Array<string | BaseCommand>;
commands?: string | Array<string | AnyCommand>;

/**
* Either an array of events, or path(s) to events
*/
events?: string | Array<string | Event>;
events?: string | Array<string | Event<any>>;

/**
* Either an array of buttons, or path(s) to buttons
Expand Down

0 comments on commit 3e7e26b

Please sign in to comment.