I haven't tried it out yet, but I know I generally request buffs from buffbots even when I already have turns of the effect running. Maybe you could add a variable that can be used in the while loop
And a small advice: on top on being able to control verbosity, vprint() was also designed to save typing in a situation when you want to return a boolean value and print a message, so you could replace
original_num_turns = have_effect(e);
while(have_effect(e) == original_num_turns)
vprint("Unable to acquire " + e.to_string(), "red", 2);
(notice the 2 became negative, to return false, so the string will be printed in red).
return vprint("Unable to acquire " + e.to_string(), -2);