Auto-kick

Leandro Silva [09-24-18 - 23:26]
Auto-kick
Filename
LeoGuildManager.lua
LeoGuildManager.txt
diff --git a/LeoGuildManager.lua b/LeoGuildManager.lua
index e1aec01..4cbe2aa 100644
--- a/LeoGuildManager.lua
+++ b/LeoGuildManager.lua
@@ -2,7 +2,7 @@
 LeoGM = {}
 LeoGM.name = "LeoGuildManager"
 LeoGM.displayName = "Leo's Guild Manager"
-LeoGM.version = "0.9.8"
+LeoGM.version = "0.9.9"
 LeoGM.chatPrefix = "|c39B027" .. LeoGM.name .. "|r: "
 LeoGM.panelList = { "Rules", "Purge" }
 LeoGM.members = {}
@@ -427,8 +427,7 @@ function LeoGM.Initialize()
     end
 end

-function LeoGM:OnUpdate()
-
+function LeoGM.AutoKick(kick)
     for _, guildName in pairs(LeoGM.guilds) do
         local guildId = LeoGM.GetGuilds(guildName)
         if DoesPlayerHaveGuildPermission(guildId, GUILD_PERMISSION_REMOVE) and LeoGM.savedVariables.rules[guildName].blacklist ~= nil then
@@ -437,9 +436,13 @@ function LeoGM:OnUpdate()
                 for guildMemberIndex = 1, numGuildMembers do
                     local displayName = GetGuildMemberInfo(guildId, guildMemberIndex)
                     if string.lower(displayName) == string.lower(userId) then
-                        d("Found " .. userId .." on " .. guildName)
-                        --d("Found " .. userId .." on " .. guildName .. ". Kicking ...")
-                        --GuildRemove(guildId, userId)
+                        if kick == true then
+                            d("Found " .. userId .." on " .. guildName .. ". Kicking ...")
+                            GuildRemove(guildId, userId)
+                            d("Bye bye!")
+                        else
+                            d("Found " .. userId .." on " .. guildName)
+                        end
                         break
                     end
                 end
@@ -448,6 +451,10 @@ function LeoGM:OnUpdate()
     end
 end

+function LeoGM:OnUpdate()
+    LeoGM.AutoKick(true)
+end
+
 function LeoGM.OnAddOnLoaded(event, addonName)
     if addonName == LeoGM.name then
         EVENT_MANAGER:UnregisterForEvent(LeoGM.Name, EVENT_ADD_ON_LOADED)
diff --git a/LeoGuildManager.txt b/LeoGuildManager.txt
index 9206703..e147c49 100644
--- a/LeoGuildManager.txt
+++ b/LeoGuildManager.txt
@@ -1,6 +1,6 @@
 ## Title: Leo's Guild Manager
 ## APIVersion: 100024
-## Version: 0.9.8
+## Version: 0.9.9
 ## Author: |c39B027@LeandroSilva|r
 ## SavedVariables: LeoGMSavedVariables
 ## DependsOn: LibStub LibFeedback MasterMerchant