Those timers won't work that way. If 20 people get an achievement, 20 messages will still go out but 10 seconds later.
Try this:
Code:
local autograts=CreateFrame('frame')
autograts:RegisterEvent('CHAT_MSG_GUILD_ACHIEVEMENT')
autograts:SetScript('OnEvent',function()
autograts.trigger=true
C_Timer.After(5,function()
if autograts.trigger then
autograts.trigger=false
SendChatMessage('oh wow grats','GUILD')
end
end)
end)
This code will wait 5 seconds after the first event, then send only one message for any events that happened in that 5 seconds. This isn't perfect, there could be times where an event happens immediately after the message, causing any timers that were triggered earlier to push out a second message, but this way, you don't spam guild chat with 20 instant messages.