Substance in question could be legal (like alcohol) or illegal. Obviously I can't comment on illegal substance use online.
After experimenting with multiple options, here is what I currently consider a good solution given my personal constraints
Use timelock.dev to generate a passcode.
Make sure it is too long to remember. Set time atleast 6-12 hours depending on the substance you are consuming.
Change the passcode of your device to this passcode. If on iphone, click the button that ensures the old passcode is not preserved for 72 hours more.
Save the encrypted file in a protonmail account whose password you remember, and which does not use device 2FA. Gmail and ios accounts use 2FA implicitly. (Remember, all your devices are locked.)
Forget the passcode.
Ask another person for help with logistics such as booking a cab back home.
Don't do this entire plan if no such trusted person exists.
Don't do this entire plan if you have responsibilities that require you staying sober. For instance any work-related engagements, or driving other people, or checking in on their safety.
Solutions I found inadequate
Applock that blocks some apps but not others. Apps that you leave unblocked can still be used for contacting people you don't want to contact.
Timelock that can be break out of, using ios recovery options. Non-sober you is still intelligent enough to break out of them.
Subscribe
Enter email or phone number to subscribe. You will receive atmost one update per month