ghostdevv / jellycommands

A command handler for Discord.js
https://jellycommands.dev
MIT License
21 stars 6 forks source link

JellyOptions type errors #184

Closed cainthebest closed 7 months ago

cainthebest commented 1 year ago

Describe the bug

When passing events, commands or buttons to jelly client directly you need to convert the type

For example to currently workaround

// ./events/ready.ts
import { event, type Event } from 'jellycommands';

export default event({
  name: 'ready',
  run: (_, client) => {
    console.log(client.user?.tag + ' is online.');
  },
}) as Event;
// ./index.ts
import { JellyCommands } from 'jellycommands';
import { IntentsBitField } from 'discord.js';

import ready from './events/ready';

const client = new JellyCommands({
  // commands,
  // buttons,
  events: [ready],
});

This is the same for commands and buttons

Reproduction

Import a command, button or event and pass it to jellycommands and you will be greeted with a type error.

Logs

No response

System Info

n/a
ghostdevv commented 1 year ago

Only seems to happen for commands and events, for different reasons both down to their generics

cainthebest commented 1 year ago

my mistake ide was out of sync with errors, but possible fix could be to change option types to

    // all command variations extend base command
    commands?: string | Array<string | Command | MessageCommand | UserCommand>;
    events?: string | Array<string | Event<keyof ClientEvents>>;
ghostdevv commented 1 year ago

That would work but it isn't ideal, it should work having BaseCommand there as they all inherit from it - Event<any> shouldn't need the any to work, need to take a look at why it's doing that