Documentation for this module may be created at Module:Server subbox autocat/doc

-- Simple module for use on {{Server subbox}}
-- Automatically adds page to [[Category:Banned <server> users]], [[Category:Former <server> users]], or [[Category:<server> users]] depending on arguments and whether such categories exist.

local p = {}
local yesno = require("Module:Yesno")

function p.main(frame)
    -- Parameters |server= |status= |nocat=
    local server = mw.text.trim(frame.args.server)

    if server == "" or yesno(frame.args.nocat) then
        return ""
    end

    local status = mw.ustring.lower(frame.args.status)

    if mw.ustring.find(status, "banned") ~= nil then
        local title = mw.title.new("Category:Banned " .. server .. " users")

        if title.exists then
            return "[[Category:Banned " .. server .. " users]]"
        else
            return "[[Category:" .. server .. " users]]"
        end

    elseif mw.ustring.find(status, "left") ~= nil or mw.ustring.find(status, "no longer in") ~= nil then
        local title = mw.title.new("Category:Former " .. server .. " users")
        
        if title.exists then
            return "[[Category:Former " .. server .. " users]]"
        else
            return "[[Category:" .. server .. " users]]"
        end

    else
        return "[[Category:" .. server .. " users]]"
    end

end

return p