From f51ce68b2ee73b5d3cd2b538ef38189a0088ac64 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Thu, 12 Dec 2024 15:10:19 +0100 Subject: [PATCH] Add more error checks and logs to whoer --- Whoer.lua | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Whoer.lua b/Whoer.lua index d440438..9d5abee 100644 --- a/Whoer.lua +++ b/Whoer.lua @@ -2,6 +2,11 @@ local _, data = ... ---@cast data HeimdallData if not data.config.who.enabled then return end +if not Heimdall_Data.who then Heimdall_Data.who = {} end +if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end +print(Heimdall_Data) +print(Heimdall_Data.who) +print(Heimdall_Data.who.data) ---@type table local players = {} @@ -126,6 +131,8 @@ local lastQuery = nil ---@return string? local function Notify(player) if not player then return string.format("Cannot notify for nil player %s", tostring(player)) end + if not data.config.who.zoneNotifyFor[player.zone] then return string.format("Not notifying for zone %s", tostring(player.zone)) end + local text = player:NotifyMessage() ---@type Message local msg = { @@ -189,6 +196,9 @@ end ---@param player Player ---@return string? local function NotifyGone(player) + if not player then return string.format("Cannot notify for nil player %s", tostring(player)) end + if not data.config.who.zoneNotifyFor[player.zone] then return string.format("Not notifying for zone %s", tostring(player.zone)) end + local text = string.format("%s of class %s and guild %s left %s", player.name, player.class, @@ -244,6 +254,8 @@ frame:SetScript("OnEvent", function(self, event, ...) local player = players[name] if not player then player = Player.new(name, guild, race, class, zone) + if not Heimdall_Data.who then Heimdall_Data.who = {} end + if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end local existing = Heimdall_Data.who.data[name] if existing then @@ -282,10 +294,15 @@ frame:SetScript("OnEvent", function(self, event, ...) player.zone = zone player.lastSeen = timestamp players[name] = player + if not Heimdall_Data.who then Heimdall_Data.who = {} end + if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end + Heimdall_Data.who.data[name] = player end + print("Done?") -- Turns out WA cannot do this ( -- aura_env.UpdateMacro() _G["FriendsFrameCloseButton"]:Click() + queryPending = false end) if not data.who.updateTicker then @@ -315,7 +332,8 @@ if not data.who.whoTicker then whoQueryIdx = 1 end lastQuery = query - print("Running who query: " .. tostring(query.query)) + print(string.format("Running who query: %s", tostring(query.query))) + SetWhoToUI(1) SendWho(query.query) end) end