I haven't tried doing that, but Celeste's devs have actually shared their player controller code 2 years ago, it's on github. It's an XNA game and it's written in C#, so you'll need to convert some code, but the logic should stay the same. Looks like this part is what you're looking for.
The nested for loops are a bit confusing, but here's what I understand: the first for loop goes from i = 1 to DashCornerCorrection, which is 4. So they'll check at 4 different heights. The innerloop will run twice each time (unless a clear path is found), once with j = 1, and once with j = -1. So basically the 4 different heights will each be checked twice, one time positive, one time negative, for a total of 8 height checks (4 above the character, 4 below). The first height check which results in no collision will be selected. This code handles correcting from below, but if your char is hitting its head on a platform, it'll move it below the platform instead (unless the top of the platform is closer).
I've just noticed that this was specifically for the dash move. There is another corner correction check that doesn't handle collision correction from above.