Xur is an NPC in Bungie's MMO shooter Destiny2
which is a space magic infused descendant of Halo.
Xur visits only for a few days a week, landing on Fridays and
selling different exotic weapons and armor from a random location.
This script Post Xur's location and inventory to a Discord webhook, and is designed to be run from cron or as a cloud function.
- Thanks to @nev for exposing the magical API that shares Xur's location as JSON.
- Thanks to the kind folks on the Destiny API Discussion Discord for helping me wrap my head around the new D2 API.
- Python3
- Discord server with an activated webhook integration
- Bungie API key
- Create a separate user named 'xur'
sudo adduser xur
- Change to the 'xur' user
sudo su - xur
- Clone the repo
git clone https://github.com/alchemydc/destiny2-xur-discord.git
- Create and activate a python virtual environment (recommended to keep deps separate from system python)
python3 -m virtualenv . && source bin/activate
- Install python dependencies (requests for making the https API calls, python-dotenv for keeping secrets out of the source)
python -m pip install -r requirements.txt
- Copy the environment template
cp .env-template .env
- Populate the .env file with your Bungie API key and Discord webhook URL
python3 xur.py
Xur comes on Fridays after the daily reset, so it's convenient to have this script run right after that. If Xur has something you don't, then go see him!
- Make xur wrapper bash script and python script executable
chmod u+x xur.sh xur.py
- Install crontab to run script automatically
/usr/bin/crontab xur.crontab
If things aren't working as expected, ensure that your Bungie API key and Discord webhook are set correctly.
If the script works when run directly, but fails when run by cron, check to ensure your home directory is correct in xur.sh, and that env vars are being properly imported by python-dotenv.