Prat_StickyChannels = Prat:NewModule('stickychannels')

function Prat_StickyChannels:OnInitialize()
    local db = Prat.db.profile

    if not db.StickyChannels then
        db.StickyChannels = {
            on = true
        }
    end

    Prat.Options.args.stickychannels = {
        name = 'StickyChannels',
        desc = 'StickyChannels',
        type = 'group',
        args = {
            toggle = {
                name = 'Toggle',
                desc = 'Toggle the module on and off',
                type = 'toggle',
                get = function() return db.StickyChannels.on end,
                set = function(v)
                    if v then
                        self:OnEnable()
                    else
                        self:OnDisable()
                    end
                    db.StickyChannels.on = v
                end
            }
        }
    }
end

function Prat_StickyChannels:OnEnable()
    ChatTypeInfo['SAY'].sticky = 1
    ChatTypeInfo['EMOTE'].sticky = 1
    ChatTypeInfo['YELL'].sticky = 1
    ChatTypeInfo['PARTY'].sticky = 1
    ChatTypeInfo['GUILD'].sticky = 1
    ChatTypeInfo['OFFICER'].sticky = 1
    ChatTypeInfo['RAID'].sticky = 1
    ChatTypeInfo['RAID_WARNING'].sticky = 1
    ChatTypeInfo['BATTLEGROUND'].sticky = 1
    ChatTypeInfo['WHISPER'].sticky = 1
    ChatTypeInfo['CHANNEL'].sticky = 1
end

function Prat_StickyChannels:OnDisable()
    ChatTypeInfo['SAY'].sticky = 0
    ChatTypeInfo['EMOTE'].sticky = 0
    ChatTypeInfo['YELL'].sticky = 0
    ChatTypeInfo['PARTY'].sticky = 0
    ChatTypeInfo['GUILD'].sticky = 0
    ChatTypeInfo['OFFICER'].sticky = 0
    ChatTypeInfo['RAID'].sticky = 0
    ChatTypeInfo['RAID_WARNING'].sticky = 0
    ChatTypeInfo['BATTLEGROUND'].sticky = 0
    ChatTypeInfo['WHISPER'].sticky = 0
    ChatTypeInfo['CHANNEL'].sticky = 0
end

