Scripts Troubleshooting

This is a collection of questions and concerns previously shared regarding unexpected behavior encountered while setting up or using scripts.
To navigate this page, first identify the script type of the script you have a concern with (e.g. time-driven script, event-driven (webhook) script, etc.) then look through the questions/concerns listed for that script type. There's also a section named "All Script Types" for questions and concerns that can apply to any of the script types.
If your question or concern is not found on this list, please check the page of the script you are using if it has a list of known issues. If it is not found there as well, please contact the author of the script.
=All Script Types=
==The script is consistently running slower than it did before.==
Starting July 20, 2020, Habitica introduced "rate limiting", which limits how often third-party tools can communicate with Habitica servers. When the rate limit is reached, the succeeding actions the script does will fail. The rate limit resets after one minute.
You may try to request the author to optimize their script to speed it up (i.e. minimize Habitica server accesses), but note that some kinds of scripts can be very hard or impossible to speed up due to rate limiting.
==The script now sometimes fails. Part of what it does happens, but it doesn't complete all of its expected actions.==
See explanation regarding rate limiting on a similar concern above.
You can simply slow down how fast you use the script to prevent failures. Or, you may try to request the author to implement retries or error message reporting.
=Time-Driven Scripts=
==The script runs too early/too late within the hour that it was set to run daily.==
On time-driven triggers, "time may be slightly randomized ". The good news is that after the script chooses a time at random within the hour, it "keeps that timing consistent from day to day".
To force the script to choose another random time within the hour, perform the following steps:
#Go to https://script.google.com/home/triggers
#Hover your mouse cursor over the row of the script, then click the pencil icon on the right
#No need to change anything, simply scroll down then click "Save"
==I get an email titled, "Summary of failures for Google Apps Script: ..."==
At the moment, these have only been observed to come from scripts that are configured to have a time-driven trigger. The error messages encountered so far include:
*"We're sorry, a server error occurred. Please wait a bit and try again."
*"Exception: Request failed for https://habitica.com returned code 502..."
*"Exception: Address unavailable: ..."
*"We're sorry, a server error occurred while reading from storage. Error code INTERNAL."
They all seem to be random errors either in the Google Apps Script platform itself, or the Internet connection in general. There doesn't seem to be a way for us to prevent such errors, but thankfully these errors only happen very rarely.
If it's critical that the script's actions occur on a certain timeframe, we can deploy the script twice so that in case we got unlucky and the first instance fails, the second instance will still give a high chance that the actions will go through on this second try.
=Event-Driven (Webhook) Scripts=
==The script completely stopped working suddenly.==
The webhook might have been disabled.
To reenable the webhook, perform the following steps:
#Go to https://habitica.com/user/settings/api
#On the right side of the screen, under "Webhooks", make sure that all checkboxes under "Enabled" are checked
==The script does things twice (e.g. sends notifications twice, etc.).==
The webhook might have been created twice.
To make sure the duplicate webhook is removed, perform the following steps:
#Perform steps under Part 1. Delete Items Created by doOneTimeSetup
#Perform steps under Part 3. Recreate Items Created by doOneTimeSetup
==I accidentally deleted/changed a reward button created by the script and want to revert it back to normal.==
To revert all of the script's reward buttons to their initial state, perform the following steps:
#Perform steps under Part 1. Delete Items Created by doOneTimeSetup
#Perform steps under Part 3. Recreate Items Created by doOneTimeSetup
You will also need to do any actions you did before to change these buttons from their initial state (e.g. change costume/appearance names, talk to the NPC to select a Subclass, etc.)
Category:Extensions, Add-Ons, and Customizations
zh:脚本故障排除