How to redirect after slug changed in 'page.update:after' hook?

I figured a way to handle slug automatic rename and redirect through this draft plugin that I made a post about. If anybody is ever interested to download the code and modify it to their needs, feel free to do it!

I think it would be possible to modify it to just handle the redirect if you need.