#Ignoring Precondition Failures

1 messages · Page 1 of 1 (latest)

violet moss
#

I'm working on a precondition that I wanna ignore on the ChatInputCommandDenied listener. The documentation suggests to a add information on the context in the Precondition

export class MyDummyPreconditions extends Precondition {
  chatInputRun(
    interaction: ChatInputCommandInteraction,
    command: ChatInputCommand,
    context: Precondition.Context
  ): Precondition.Result {
    return this.error({ message: 'Ignored message', context: { silent: true } });
  }
}

and check for it in ChatInputCommandDenied.

export class ChatInputCommandDeniedListener extends Listener<typeof Events.ChatInputCommandDenied> {
  public async run({ context, message: content }: UserError, { interaction }: ChatInputCommandDeniedPayload) {
    if (Reflect.get(Object(context), 'silent')) return;

    if (interaction.deferred || interaction.replied) {
      return interaction.editReply({
        content,
        allowedMentions: { users: [interaction.user.id], roles: [] }
      });
    }

    return interaction.reply({
      content,
      allowedMentions: { users: [interaction.user.id], roles: [] },
      ephemeral: true
    });
  }
}

That works but I realized that the interaction response will be:

The application did not respond

Is that expected or did I miss something?

real muskBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

rich trout
tulip talon
#

no

#

interactions NEED to send something

#

Only button ones can update a message with the same content and be fine

rich trout
#

I suppose the least you can send then is a single zero width space but probably to just reply something then, but reply ephemeral so it's only visible to the user

violet moss
#

Thanks that is what I’m doing just wanna check if the docs miss something

real muskBOT
#

Thank you for marking this question as solved!

Question Message ID

1106247858472099930

Solution Message ID

1106258432559960194

rich trout
#

don't suppose you can make a PR to adjust that bit of text in the guide @violet moss ? Would save me doing it haha