Thursday, June 04, 2026 3:08:00 AM
> server.rb
# frozen_string_literal: true

module ESM
  class Server < ApplicationRecord
    # =============================================================================
    # INITIALIZE
    # =============================================================================

    # =============================================================================
    # DATA STRUCTURE
    # =============================================================================

    public_attributes(
      :server_id, :server_name,
      id: ->(server) { server.public_id }
    )

    # =============================================================================
    # ASSOCIATIONS
    # =============================================================================

    # =============================================================================
    # VALIDATIONS
    # =============================================================================

    # =============================================================================
    # CALLBACKS
    # =============================================================================

    # =============================================================================
    # SCOPES
    # =============================================================================

    # =============================================================================
    # CLASS METHODS
    # =============================================================================

    # =============================================================================
    # INSTANCE METHODS
    # =============================================================================

    def recently_created?(time: 30.seconds.ago)
      created_at.between?(time, Time.current)
    end

    def connected?
      Rails.cache.fetch("server:#{id}:connected", expires_in: 10.seconds) do
        ESM.bot.server_connected?(id)
      end
    end

    def ui_v2?
      @ui_v2 ||= Semantic::Version.new(ui_version || "2.0.0") >= Semantic::Version.new("2.0.0")
    end
  end
end
All opinions represented herein are my own
- © 2024 - 2026 itsthedevman
- build 4294fb2