ChannelKeys = AceLibrary("AceAddon-2.0"):new("AceDB-2.0","AceConsole-2.0") ChannelKeys:RegisterDB("ChannelKeysDB", "ChannelKeysDBPerChar") ChannelKeys:RegisterChatCommand({ "/channelkeys", "/ck" }, { type = 'group', name = "Channels", desc = "Set channels.", args = { chan = { type = 'group', name = "Channel One", desc = "Set Channels", args = { one = { type = 'text', name = "Channel One", desc = "Set Channel One", usage = "", get = function() return ChannelKeys.db.profile.ChanOne end, set = function(ChanOne) ChannelKeys.db.profile.ChanOne = ChanOne end, }, two = { type = 'text', name = "Channel Two", desc = "Set Channel Two.", usage = "", get = function() return ChannelKeys.db.profile.ChanTwo end, set = function(ChanTwo) ChannelKeys.db.profile.ChanOne = ChanTwo end, }, three = { type = 'text', name = "Channel Three", desc = "Set Channel Three.", usage = "", get = function() return ChannelKeys.db.profile.ChanThree end, set = function(ChanThree) ChannelKeys.db.profile.ChanThree = ChanThree end, }, four = { type = 'text', name = "Channel Four", desc = "Set Channel Four.", usage = "", get = function() return ChannelKeys.db.profile.ChanFour end, set = function(ChanFour) ChannelKeys.db.profile.ChanFour = ChanFour end, }, five = { type = 'text', name = "Channel Five", desc = "Set Channel Five.", usage = "", get = function() return ChannelKeys.db.profile.ChanFive end, set = function(ChanFive) ChannelKeys.db.profile.ChanFive = ChanFive end, }, } } } }) function ChannelKeys:SendToChat(prefix) if (not ChatFrameEditBox:IsVisible()) then ChatFrame_OpenChat(prefix) else ChatFrameEditBox:SetText(prefix) end; ChatEdit_ParseText(ChatFrame1.editBox,0) end function ChannelKeys:GetChan(Chan) local ChanName = self:CheckChan(Chan); if (ChanName > 0) then self:SendToChat("/"..ChanName.." ") else --ace:print("Channel does not exist.") end; end function ChannelKeys:CheckChan(Chan) local i,ChanID,ChanName; for i = 1,10,1 do ChanID,ChanName = GetChannelName(i) ace:print(Chan) if (ChanID ~= 0 and ChanName ~= nil) then if (string.find(ChanName,Chan,1,true) ~= nil) then return i end end; end; return 0; end function ChannelKeys:Doit(Chan) local chan = self.db.profile[Chan] self:GetChan(chan) end