Ok. Well I've also made a macro in the game: feedpet
/run local c=CastSpellByName;if GetPetHappiness()~=nil and GetPetHappiness()~=3 then c("Feed Pet");PickupContainerItem(0,1) end
Clicking this macro works and feeds the pet.
When I use
RunMacroText("/cast feedpet");
This also doesn't work. Am I doing something wrong or does this method also not work in Vanilla?