#commandName is not definedd

1 messages · Page 1 of 1 (latest)

sand sentinel
#

Well, the issue is that commandName is not a function it seems

limber hazel
#

Correct, it is indeed not a function

sand sentinel
#

Well, not even variable it seems so it doesn't exist under Interaction object

limber hazel
#

It does though, assuming its a command interaction

#

Hadn't you posted code?

#

Can you please share your code and the error from the console?

sand sentinel
#
  public listen(): Promise<string> {
    this.client.on(Events.InteractionCreate, (interaction) => {
      switch (interaction.type) {
        case InteractionType.ModalSubmit:
          this.interactionResponder.handle(interaction);
          break;
        case InteractionType.ApplicationCommand:
          this.commandResponder.handle(interaction.commandName);
          break;
      }
    });

    return this.client.login(this.token);
  }
#

Not on the computer rn, I'll quickly get on in a moment to send you the error but basically it doesn't see commandName as part of Interaction object

#
  public listen(): Promise<string> {
    this.client.on(Events.InteractionCreate, (interaction) => {
      console.log(interaction.commandName)
    });

    return this.client.login(this.token);
  }
  Property 'commandName' does not exist on type 'StringSelectMenuInteraction<CacheType>'.ts(2339)
limber hazel
#

Well that error is correct, you havent got any typeguarding on the second example

#

If you want to typeguard use the interaction.isModalSubmit() methods

limber tendonBOT