Auto Cast Party Buff Skills

== Description ==
Run at specific times, this script will buff your party n number of times with your desired party buff. This script is deliberately designed not to check if you have enough mana first, so it will error if it does not meet the buffing criteria.
== Installation ==
* Go to script.google.com. If this is your first script, this will automatically create a new Google script for you and open an editor for it. Otherwise, edit an existing project by clicking the pencil icon next to it, or create another.
* Paste the code snippet below into the editor
** Replace the spaces marked #HabiticaUserID# and #HabiticaAPIToken# with Habitica User ID and API Token (leave the quotes). These can be found under the API tab in your Habitica settings.
** Change the ntimes to the number of buffs you wish to do each run. Currently set to 3.
** Change the skillid to skill you wish to cast based on what is described in the comments in options. Below is currently set to Earthquake with skillId = "earth"
 function schedulePartyBuff() {
 
 var habId = "#HabiticaUserID#";
 var habToken = "#HabiticaAPIToken#";
 var ntimes = 3
 var skillId = "earth"
 /*
 Below is a list of options of the party buff skills. Replace the value in skillId above for the skill you desire. Ensure you copy the quotes.
 See http://habitica.fandom.com/wiki/Skills for more information on skills.
 Options for skills:
 Warrior Valorous Presence (STR): "valorousPresence" 
 Warrior Intimidating Gaze (CON): "intimidate" 
 Rogue Tools of Trade (PER): "toolsOfTrade"
 Healer Protective Aura (CON): "protectAura"
 Healer Blessing (HP): "healAll"
 Mage Ethereal Surge (mana): "mpheal"
 Mage EarthQuake (INT): "earth"
 */
 var url = "https://habitica.com/api/v3/user/class/cast/" + skillId 
 var sleepTime = 30000
 
 //set paramaters
 var paramsTemplate = {
 "method" : "post",
 "headers" : {
 "x-api-user" : habId, 
 "x-api-key" : habToken
 }
 }
 var params = paramsTemplate;
 
 for (var i = 0; i < ntimes; i++) { 
 UrlFetchApp.fetch(url, params)
 Utilities.sleep(sleepTime);// pause in the loop for 30000 milliseconds (30 seconds); this is to avoid the servers being overloaded
 }
 }
* Under Edit, select Current project's triggers. Then add a trigger that runs schedulePartyBuff Time-driven on a Day Timer with the parameter of which time is best.
* Click notifications, change the second parameter from daily to immediate (this will alert you if you failed to cast the number of party buffs).
* Save and you're done!
If you wish this to run immediately instead of waiting on a trigger, from the edit window of the project, menu choose Run → Run function → schedulePartyBuff.
Category:Extensions, Add-Ons, and Customizations