Also, this isn't related to whatever problem you're having, but:
Code:
if (... and IsInGuild() ~= nil) then
You should omit the explicit check against nil. In WoD all 1/nil returns are being changed to proper true/false booleans, and nil evaluates to a boolean false anyway, so a simpler implicit boolean check will not only be more readable and more efficient, but also work in both API environments:
Code:
if ... and IsInGuild() then
I'd also suggest moving the IsInGuild check inside the event check, so that if the event fires when you're not in a guild, your code won't waste time checking all the other events. Better yet, don't register the event at all if the player isn't in a guild.