----------------------------------------------------------------------------------------
--	Auto decline duel
----------------------------------------------------------------------------------------
local T, C, L, _ = unpack(select(2, ...))
if C.Module.Automation.decline_duel ~= true then return end

local frame = CreateFrame("Frame")
frame:RegisterEvent("DUEL_REQUESTED")
frame:RegisterEvent("PET_BATTLE_PVP_DUEL_REQUESTED")
frame:SetScript("OnEvent", function(self, event, name)
	if event == "DUEL_REQUESTED" then
		CancelDuel()
		RaidNotice_AddMessage(RaidWarningFrame, L.AUTO_DECLINE_DUEL_INFO..name, {r = 0.41, g = 0.8, b = 0.94}, 3)
		print(format("|cffffff00"..L.AUTO_DECLINE_DUEL_INFO..name.."."))
		StaticPopup_Hide("DUEL_REQUESTED")
	elseif event == "PET_BATTLE_PVP_DUEL_REQUESTED" then
		C_PetBattles.CancelPVPDuel()
		RaidNotice_AddMessage(RaidWarningFrame, L.AUTO_DECLINE_DUEL_PET_INFO..name, {r = 0.41, g = 0.8, b = 0.94}, 3)
		print(format("|cffffff00"..L.AUTO_DECLINE_DUEL_PET_INFO..name.."."))
		StaticPopup_Hide("PET_BATTLE_PVP_DUEL_REQUESTED")
	end
end)