From 86d0d8f15fad9a24aee2864780bbd1fd794dea0e Mon Sep 17 00:00:00 2001 From: Exoridus Date: Fri, 5 May 2023 07:45:04 +0200 Subject: [PATCH] fix(commands): fixed issues that caused an error when fetching player data --- Modules/SlashCommands.lua | 16 +++++++++------- Modules/Utils.lua | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Modules/SlashCommands.lua b/Modules/SlashCommands.lua index 518714f..fb3ff74 100644 --- a/Modules/SlashCommands.lua +++ b/Modules/SlashCommands.lua @@ -1,4 +1,4 @@ -local Addon = select(2, ...); +local AddonName, Addon = ...; local SlashCommands = Addon:NewModule("SlashCommands", "AceConsole-3.0"); local Blocklist = Addon:GetModule("Blocklist"); local Checklist = Addon:GetModule("Checklist"); @@ -28,14 +28,16 @@ function SlashCommands:OnChatCommand(input) end end -function SlashCommands:PrintInfo(text, ...) +function SlashCommands:PrintInfo(message, ...) local chatFrame = SELECTED_CHAT_FRAME or DEFAULT_CHAT_FRAME; + local chatPrefix = WrapTextInColorCode(AddonName, "FF33FF99"); + local chatMessage = tostring(message); if select('#', ...) > 0 then - self:Printf(chatFrame, text, ...); - else - self:Print(chatFrame, text); + chatMessage = chatMessage:format(...); end + + chatFrame:AddMessage(("%s: %s"):format(chatPrefix, chatMessage)); end function SlashCommands:PrintHelp() @@ -147,7 +149,7 @@ function SlashCommands:DumpBlocklistCommand() tinsert(lines, Utils:FormatReportByCase(index, Blocklist.GetItemByName(name))) end; - Utils:OpenTextInEditWindow(table.concat(lines, "\n")); + Utils:OpenTextInEditWindow(tconcat(lines, "\n")); end function SlashCommands:DumpChecklistCommand() @@ -158,5 +160,5 @@ function SlashCommands:DumpChecklistCommand() tinsert(lines, Utils:FormatReportByCase(index, Checklist.GetItemByName(name))) end; - Utils:OpenTextInEditWindow(table.concat(lines, "\n")); + Utils:OpenTextInEditWindow(tconcat(lines, "\n")); end \ No newline at end of file diff --git a/Modules/Utils.lua b/Modules/Utils.lua index 476d296..d2c988b 100644 --- a/Modules/Utils.lua +++ b/Modules/Utils.lua @@ -35,7 +35,7 @@ function Module:PrepareFriendInfo(info) local faction = RACE_TO_FACTION[race]; local factionName = FACTION_LABELS_FROM_STRING[faction]; local realm = server ~= "" and server or GetRealmName(); - local level = info.level and info.level > 0 or 0; + local level = type(info.level) == "number" and info.level or 0; if info.notes == FRIENDLIST_NOTE then C_FriendList.RemoveFriend(name);