#!/bin/bash

DIRECTORY="$(dirname "$(dirname "$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )")")"

function error {
  echo -e "\\e[91m$1\\e[39m"
  exit 1
}

version='1.3.0'

#remove electron-discord-webapp if it still exists
if command -v electron-discord-webapp >/dev/null ;then
  sudo apt purge electron-discord-webapp || error "failed to first uninstall electron-discord-webapp!"
fi

echo "Downloading Webcord..."

rm -f ~/webcord_${version}_armhf.deb
wget https://github.com/SpacingBat3/electron-discord-webapp/releases/download/v${version}/webcord_${version}_armhf.deb
sudo apt -fy install ~/webcord_${version}_armhf.deb || error "Failed to install webcord deb!"

rm -f ~/webcord_${version}_armhf.deb
