Wednesday, July 15, 2026 2:53:23 AM
> project show esm_bot
A sophisticated Discord bot that bridges Arma 3 Exile servers with Discord communities. Built in Ruby with secure TCP communication, it delivers territory management, real-time notifications, and comprehensive server administration right in your Discord channels.
Details
> origin.rb
# frozen_string_literal: true

module ESM
  module Website
    module Command
      ##
      # Website adapter for {ESM::Command::Origin}. Holds the user and community resolved
      # from a website-initiated RPC and forwards replies through the caller-supplied sink
      # so the lifecycle's reply path becomes the RPC's response body.
      #
      # {#current_channel} is always nil because the website has no channel context.
      #
      class Origin < ESM::Command::Origin
        attr_reader :current_user, :current_community, :current_channel

        def initialize(user:, reply_sink:, community: nil)
          @current_user = user
          @current_community = community
          @current_channel = nil
          @reply_sink = reply_sink
        end

        def reply(content)
          @reply_sink.call(serialize(content))
        end

        def log_context
          {
            author: "#{@current_user&.distinct} (steam #{@current_user&.steam_uid})",
            channel: "website"
          }
        end

        private

        def serialize(content)
          case content
          when ESM::Embed then content.to_h
          when String then {description: content}
          else content
          end
        end
      end
    end
  end
end
All opinions represented herein are my own
- © 2024 - 2026 itsthedevman
- build 43aa0d7