Module: ESM::Command::Server::Info::V1

Defined in:
lib/esm/command/server/info.rb

Instance Method Summary collapse

Instance Method Details

#on_executeObject



114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/esm/command/server/info.rb', line 114

def on_execute
  # Ensure we were given a target or territory ID
  check_for_no_target!

  # Territory ID takes priority since both arguments are optional, and both can be provided
  # Reasoning: Given the weird scenario, user gives a mention plus a territory ID thinking that it will do some filter...
  if arguments.territory_id.present?
    deliver!(query: "territory_info", territory_id: arguments.territory_id)
  else
    deliver!(query: "player_info", uid: target_user.steam_uid)
  end
end

#on_responseObject



127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/esm/command/server/info.rb', line 127

def on_response
  # I'm not quite sure if this is needed, but just in case...
  check_for_response!

  # The fact that it has an ID indicates it was a territory...
  if @response.id
    territory = ESM::Exile::Territory.new(server: target_server, territory: @response)
    reply(territory.to_embed)
  else
    player = ESM::Exile::Player.new(server: target_server, player: @response)
    reply(player.to_embed)
  end
end