That should give you enough access to edit your role via the admin and reset everything back the way it should be.
Now, here’s the important bit. After you add that code to your theme’s functions.php file, you need to visit the WP admin on your site for it to execute. Once that’s done, remove that code from your theme’s functions.php file. Otherwise, it’ll run on every page load in the admin, which is not something you want.