You're addon is probably running the code before Bartender has initialised the bars. This usually happens at a specific event that fires during the game loading sequence.
It's also why it works when you're already in the game tesing in WowLua.
Try something like:
Lua Code:
function ParseSpellName(spellId)
local spellName, spellSubName, _ = GetSpellInfo(spellId);
if spellSubName then
return string.format("%s(%s)", spellName, spellSubName)
else
return spellName
end
end
local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:SetScript("OnEvent", function(self, event, ...)
self:UnregisterAllEvents() -- PLAYER_ENTERING_WORLD will fire every time you see a loading screen so, stop that happening
local button = BT4Button73
local slot = button:GetAttribute('action');
local actionType, actionId, _ = GetActionInfo(slot);
if (actionType == 'spell') then
local command = string.format("/use [@mouseover]%s", ParseSpellName(actionId))
print(command);
end
end)