#Building slash command in module differently

14 messages · Page 1 of 1 (latest)

earnest coral
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

umbral brook
#

It's possible in TS, but you should make your own type for the command files (referencing DJS' ApplicationCommandData interface is a good place to start

#

If you're having a specific error in TS that you're not sure how to get around, feel free to share that too

lofty blaze
#

U mean the thing about attaching .commands to the client ?
If so, it would look something like that ?

export interface IDiscordClient {
  commands: Collection<string, ApplicationCommandData>;
}

export default class DiscordClient extends Client implements IDiscordClient {
  public commands: Collection<string, ApplicationCommandData>;

  constructor(options: ClientOptions) {
    super(options);
    this.commands = new Collection();
  }
}
#

Wait no, making a new class impementing the ApplicationCommandData seems like more appropriate

shadow hareBOT
umbral brook
#

In your command files, the best way to enforce your custom command type would be const command: YourInterfaceHere = {...} and then export default command;

mystic halo
umbral brook
#

Ah smart, I haven't looked too much into satisfies yet

mystic halo
#

satisfies is the perfect fit in this scenario

lofty blaze
#

I've never used satisfies, nor even seen it, i'm not sure how to make it work

lofty blaze
#

I tried creating an interface like this :

export interface ICommands extends ApplicationCommandData{
  category: string;
  permissions: bigint[];
  usage: string;
  examples: string[];
} 

But VSCode throws this
An interface can only extend an object type or intersection of object types with statically known members.ts(2312)

mystic halo