The function only processes buffs because it only includes code to process buffs. If you do not pass a filter, UnitAura defaults to looking at buffs. If you want to look at both buffs and debuffs you need to do two loops -- one for buffs, one for debuffs.
Code:
-- Buffs:
for i = 1, 40 do
local name, _, icon, _, dtype, duration, _, _, _, _, id, _, isBossDebuff = UnitAura(unit, i)
if not name then break end -- no more buffs on this unit
local priority = list.raidAuras and list.raidAuras[name]
if priority and priority > bestPriority then
bestPriority = priority
bestIcon, bestType = icon, dtype
end
end
-- Debuffs:
for i = 1, 40 do
local name, _, icon, _, dtype, duration, _, _, _, _, id, _, isBossDebuff = UnitAura(unit, i, "HARMFUL")
if not name then break end -- no more debuffs on this unit
local priority = (list.dispel and list.dispel[dtype]) and 5 or (list.raidAuras and list.raidAuras[name])
if priority and priority > bestPriority then
bestPriority = priority
bestIcon, bestType = icon, dtype
end
end
(Also, I never saw your question, because you just edited your post, and that doesn't flag the thread as unread. Generally if it's been more than 5-10 minutes and your original post didn't including anything that requires a reply, you should just add another post.)