Due to popular demand, I added another parameter to the PlayerHasBuffCondition to only return true when a buff has a specified amount of time left. I didn't test the code change, so let me know if you run into issues with it.
For an example if you wanted to maintain your mana buff flask in slot 1, the below pseudo code would use it if the duration is below 500ms (0.5s)
[D] PlayerHasBuffCondition("mana buff", 500, inverted)
----[A] UseFlask(1);