This doesn’t solve the fundamental issue that the spam causes maintainers to have to spend brain cycles dealing with it. This “solution” still requires you to mark the PR as “invalid” manually. All it does is close the issue, add a comment, and delete the PR branch (if exists). If you’re already marking the branch as invalid, you’ve already wasted your time.