How to delete a ghost bot user with admin privileges?

Beware that using the Rails console is an extraordinary action, and if you remove the wrong AI bot, you can break some functionality. Check this:

I think you can also remove admin privileges before deleting users from the GUI.

  1. Entering into the Rails console (you want to backup just in case):
cd /var/discourse/
./launcher enter app
rails c
  1. Removing the privileges:
u = User.find_by(username: "BOT_USERNAME")
u.revoke_admin!