• Studio

  • Studio API

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • Globals

    UserBan

    Represents a banned user record with ban details. Returned by Moderation.GetBannedUsers() for moderation management.

    Available on: Server scripts only

    Properties

    bannedBy

    ServerOnly
    ReadOnly

    The User object of the moderator who issued the ban. Contains Name, Id, IsSubscriber, and IsAgeVerifiedAbove18.

    print("Banned by: " .. ban.bannedBy.name)
    

    createdAt

    number
    ServerOnly
    ReadOnly

    Unix timestamp (seconds since epoch) when the ban was created. Use with os.date() to format as human-readable date.

    local banDate = os.date("%Y-%m-%d %H:%M:%S", ban.createdAt)
    print("Banned on: " .. banDate)
    
    -- Calculate how long ago the ban was issued
    local timeSinceBan = os.time() - ban.createdAt
    print("Banned " .. timeSinceBan .. " seconds ago")
    

    expiresAt

    number
    ServerOnly
    ReadOnly

    Unix timestamp (seconds since epoch) when the ban will expire. Will be infinity (math.huge) for permanent bans.

    if ban.expiresAt == math.huge then
        print("Permanent ban")
    else
        local expireDate = os.date("%Y-%m-%d %H:%M:%S", ban.expiresAt)
        print("Expires on: " .. expireDate)
        
        -- Calculate remaining time
        local timeRemaining = ban.expiresAt - os.time()
        if timeRemaining > 0 then
            print("Time remaining: " .. timeRemaining .. " seconds")
        else
            print("Ban has expired")
        end
    end
    

    message

    string
    ServerOnly
    ReadOnly

    The reason message provided when the ban was issued. May be empty if no reason was specified.

    if ban.message ~= "" then
        print("Ban reason: " .. ban.message)
    else
        print("No reason provided")
    end
    

    user

    ServerOnly
    ReadOnly

    The User object of the banned player. Contains Name, Id, IsSubscriber, and IsAgeVerifiedAbove18.

    local bannedUser = ban.user
    print("Banned user: " .. bannedUser.name)
    print("User ID: " .. bannedUser.id)
    

    Updated 13 days ago

    PocketWorlds Icon

    © 2025 Pocket Worlds. All rights reserved.