Weakaura Custom Trigger Written During Legion, Erroneous in BFA

Hello, I’ve tried to figure out what in the below custom weakaura trigger/untrigger is causing ingame errors to occur. The weakaura was created in Legion and functioned. It is currently broken in the current version of BFA. I’ve had help on the forum here, but I’m still unable to get the result I’m after (for the weakaura to function without errors). Thank you for your time and help.

Custom Trigger:

function()

local PtWTarget = (UnitGUID("target") or "")
if  not (PtWTarget == "") and 
(PtWTarget == (aura_env.PtWTarget or "")) and
UnitCanAttack("player", "target") and 
not UnitIsDead("target") and
not (UnitDebuff("target", "Purge the Wicked", "PLAYER")) then
    aura_env.PtWTarget = PtWTarget
    return true 
else
    aura_env.PtWTarget = PtWTarget
    return false
end

end

Custom Untrigger:

function()

return true

end

This is the string for the weakaura if anyone is inclined to take a closer look.

!9QvBVTnos4)lb4aCU72SwYYojlUSa2jo9sHJD2i3RBXURSPLOT5ffrbjQK4(b9B)MHKswV5xAr6Hu4OqnC4W5n(8qxhdNPo2Xo2MNzyCwhh7NDS9W)bJUG4(Kxep8AUppcgySH8FMYp7i)0YzC7Z66iaH5rE0Ob6P4ypWN91VsI8sNpLZ9fmyO3MSCzmv4C7pDHXLwT7CENln62TxpZEol)jREz64UauOXggzd4Si7PHEROo2J5bWNKa318Oh4Say1VE44PdFmtmB2xPGcY14rTbIDj(4SCSPVfsc8OE46kIyRwrJIvZEA(a4JE0fjlxoDtiyn)7HJE42pncEV8pjjretqNHuF)78WzJRqYc6l0aHnml2Bo2ZUUV90z2t7)iOSKagisOpzdO8CrFiIkf1(HHJaLlhdwmkXxS2XoG8mvPBbQGTMMqnueDfJhOmWvr8eigaElAuaX))a7j4Dk3mjraUYjHcyKmBL6Vu7Bhmz60j3pA4TGvYGCJhsIwrtNlwdF8zM7tGJccgSNj40LztcsKq6RKRCGmC5bEeuGzQbJPU8aWXa6)zcl44LEjlGfV(OLhNre4MG4grqKHxvIZT4OkxJ91poC44SKfDs64Uo2GswYwPCij4w307Z2M9jxCZRqU1M805ETBBDrBZo96zDUPXLxIPZNlN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TSrwKNwH)yeWhq(cPvABVMaZd0ipY7xGzJTMZCpAzguLpAbkO7ar((yMUvXJ7EXLnrOxhwRs2iUGq99FLSjUMYQJAN47VBW2nGtUXcRJd1DvWr)FhY9b4oKHeFxyfFFXEFKF9ghfs8Mqt)DGAUre97cv(rI0Vgs8DY5OzK4LWvny)4QYp7u)741rSGN(X9vV9nVEzFnAJUmGEtRrlg(44VFocfkuU9cR29o34YoTTSmTU0eXQ2Tdw8C7fgMwgwT722Y88EGe63uUGkd6f0LYLPkRBxJFWruywNJrvC378i4M4C0etJfLHOBA1ThCsCVlG95fgAi6AQis2e50woexJgjnjjC8W0pNo3AlDJM68uc5)oOwCaMDnrSyWU(Mml89xU9B1uuLm4rHee8n4)Ff(xxvexg9TqMkjEkdpguHcZU3UrOnOiAmjqQmuvvqWDCFfCfr7nc)Ep3X3n5E((bVNeJ3HAJWev3IRg3jIVBRiLb)TFSSg7ZNHg9VEmUUVny1D(onLRUk3wEhbANvJQUV9d1HqoLxGNTmX)05)9d

https://wow.gamepedia.com/API_UnitDebuff
no longer accepts names as input.

I tried to figure it out as well and apart from overthinking the conditions way too much I think it would boil down to something like (as Elvenbane an others have pointed out, UnitDebuff has changed):

function()
	local PtWTarget = UnitGUID("target") or ""
	if PtWTarget == aura_env.PtWTarget and UnitCanAttack("player", "target") then
		for i=1, 40 do
			local _,_,_,_,_,_,id = UnitDebuff("target", i, "PLAYER")
			if not id then break end
			if id == 204197 then --"Purge the Wicked"
				return true
			end
		end
	end
	aura_env.PtWTarget = PtWTarget 
end

As previously indicated, UnitDebuff has the wrong arguments

Don’t use UnitDebuff
Use AuraUtil.FindAuraByName
like this,
and not (AuraUtil.FindAuraByName(“Purge the Wicked”,“target”)) then

Thank you all for responding. I will work on replacing UnitDebuff with AuraUtil.FindAurabyName and or also test out the custom function Fizzlemizz worked out.

To potentially clarify and or confirm what the error initially was, this is the error string i found in the addon “bug sac” 's log.:

62x [string “–[[ Error in ‘.noptw 5 2 3 2 3’ ]] return …”]:8: Usage: UnitDebuff(“unit”, [index][, “filter”])
[string “–[[ Error in ‘.noptw 5 2 3 2 3’ ]] return …”]:8: in function <[string “–[[ Error in ‘.noptw 5 2 3 2 3’ ]] return …”]:1>
[C]: in function xpcall' WeakAuras\GenericTrigger.lua:555: in function <WeakAuras\GenericTrigger.lua:520> WeakAuras\GenericTrigger.lua:646: in functionScanEventsInternal’
WeakAuras\GenericTrigger.lua:633: in function `ScanEvents’
WeakAuras\GenericTrigger.lua:1073: in function <WeakAuras\GenericTrigger.lua:1071>