#[14.14.1] Check if awaitMessageComponent hit timeout or some other code failed

1 messages · Page 1 of 1 (latest)

tropic quail

Would it be possible to detect whether awaitMessageComponent failed because of the timeout, or some other error occurred in the code?

For example:

try {
  const res = await interaction.editReply({ embeds: [embed], components: [row], files: [file] });
  const confirmation = await res.awaitMessageComponent<ComponentType.Button>({ filter: (i) => i.user.id === userID, time: 60000 });
  throw new Error('test');
} catch (e) {
  if (e instanceof ...) {
    console.log('No response after 60 seconds');
  } else {
    console.log(e);
  }
}

I'm not sure how to detect/where to get the error class from tho.
I already tried: DiscordjsErrorCodes.InteractionCollectorError (as it's rejected with new DiscordjsError(ErrorCodes.InteractionCollectorError, reason)), however, I got the following error:
"The right-hand side of an 'instanceof' expression must be either of type 'any', a class, function, or other type assignable to the 'Function' interface type, or an object type with a 'Symbol.hasInstance' method."
I guess this is this case since ErrorCodes.InteractionCollectorError isn't a class, but rather just an error code? Not sure about this tho.

Thanks in advance