Skip to content

Commit f7624f0

Browse files
committed
Guild MOTD: protect the check by combat restriction
1 parent 0d4e7de commit f7624f0

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

ElvUI/Game/Shared/Modules/Chat/Chat.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ local GetBNPlayerCommunityLink = GetBNPlayerCommunityLink
2121
local GetChannelName = GetChannelName
2222
local GetChatWindowInfo = GetChatWindowInfo
2323
local GetCursorPosition = GetCursorPosition
24-
local GetGuildRosterMOTD = GetGuildRosterMOTD
2524
local GetInstanceInfo = GetInstanceInfo
2625
local GetNumGroupMembers = GetNumGroupMembers
2726
local GetPlayerCommunityLink = GetPlayerCommunityLink
@@ -68,6 +67,7 @@ local GetGroupQueues = E.Retail and C_SocialQueue.GetGroupQueues
6867
local GetCVar = C_CVar.GetCVar
6968
local GetCVarBool = C_CVar.GetCVarBool
7069

70+
local GetGuildRosterMOTD = C_GuildInfo.GetMOTD or GetGuildRosterMOTD
7171
local C_ClassColor_GetClassColor = C_ClassColor and C_ClassColor.GetClassColor
7272
local IsTimerunningPlayer = C_ChatInfo.IsTimerunningPlayer
7373
local IsChatLineCensored = C_ChatInfo.IsChatLineCensored
@@ -2961,11 +2961,14 @@ end
29612961
tremove(_G.ChatTypeGroup.GUILD, 2)
29622962
function CH:DelayGuildMOTD()
29632963
local delay, checks, delayFrame = 0, 0, CreateFrame('Frame')
2964+
29642965
tinsert(_G.ChatTypeGroup.GUILD, 2, 'GUILD_MOTD')
2966+
29652967
delayFrame:SetScript('OnUpdate', function(df, elapsed)
29662968
delay = delay + elapsed
2969+
29672970
if delay < 5 then return end
2968-
local msg = GetGuildRosterMOTD()
2971+
local msg = not InCombatLockdown() and GetGuildRosterMOTD()
29692972
if msg and strlen(msg) > 0 then
29702973
for _, frameName in ipairs(_G.CHAT_FRAMES) do
29712974
local chat = _G[frameName]
@@ -2974,9 +2977,11 @@ function CH:DelayGuildMOTD()
29742977
chat:RegisterEvent('GUILD_MOTD')
29752978
end
29762979
end
2980+
29772981
df:SetScript('OnUpdate', nil)
29782982
else -- 5 seconds can be too fast for the API response. let's try once every 5 seconds (max 5 checks).
29792983
delay, checks = 0, checks + 1
2984+
29802985
if checks >= 5 then
29812986
df:SetScript('OnUpdate', nil)
29822987
end

ElvUI/Game/Shared/Modules/DataTexts/Guild.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ local format, strfind, strjoin, strsplit, strmatch = format, strfind, strjoin, s
77

88
local GetGuildInfo = GetGuildInfo
99
local GetGuildRosterInfo = GetGuildRosterInfo
10-
local GetGuildRosterMOTD = GetGuildRosterMOTD
11-
local MouseIsOver = MouseIsOver
1210
local GetNumGuildMembers = GetNumGuildMembers
1311
local GetQuestDifficultyColor = GetQuestDifficultyColor
12+
local InCombatLockdown = InCombatLockdown
13+
local IsAltKeyDown = IsAltKeyDown
1414
local IsInGuild = IsInGuild
1515
local IsShiftKeyDown = IsShiftKeyDown
16+
local MouseIsOver = MouseIsOver
1617
local ToggleGuildFrame = ToggleGuildFrame
1718
local UnitInParty = UnitInParty
1819
local UnitInRaid = UnitInRaid
19-
local IsAltKeyDown = IsAltKeyDown
2020

2121
local LoadAddOn = C_AddOns.LoadAddOn
2222

@@ -25,6 +25,7 @@ local REMOTE_CHAT = REMOTE_CHAT
2525
local GUILD_MOTD = GUILD_MOTD
2626
local GUILD = GUILD
2727

28+
local GetGuildRosterMOTD = C_GuildInfo.GetMOTD or GetGuildRosterMOTD
2829
local C_GuildInfo_GuildRoster = C_GuildInfo.GuildRoster
2930
local GetGuildFactionData = C_Reputation.GetGuildFactionData
3031
local GetMemberIdsSortedByName = CommunitiesUtil.GetMemberIdsSortedByName
@@ -158,7 +159,7 @@ local function BuildGuildTable()
158159
end
159160

160161
local function UpdateGuildMessage()
161-
guildMotD = GetGuildRosterMOTD()
162+
guildMotD = not InCombatLockdown() and GetGuildRosterMOTD() or ''
162163
end
163164

164165
local FRIEND_ONLINE = select(2, strsplit(' ', _G.ERR_FRIEND_ONLINE_SS, 2))
@@ -188,6 +189,7 @@ local eventHandlers = {
188189
else
189190
BuildGuildTable()
190191
UpdateGuildMessage()
192+
191193
if MouseIsOver(frame) then
192194
frame:GetScript('OnEnter')(frame, nil, true)
193195
end

0 commit comments

Comments
 (0)