Module: ESM::Command::Territory::Add::V1

Defined in:
lib/esm/command/territory/add.rb

Instance Method Summary collapse

Instance Method Details

#on_request_acceptedObject



74
75
76
77
78
79
80
81
82
# File 'lib/esm/command/territory/add.rb', line 74

def on_request_accepted
  # Request the arma server to add the user
  deliver!(
    function_name: "addPlayerToTerritory",
    territory_id: arguments.territory_id,
    target_uid: target_user.steam_uid,
    uid: current_user.steam_uid
  )
end

#on_responseObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/esm/command/territory/add.rb', line 84

def on_response
  # Send the success message to the requestee (which can be the requestor)
  embed = ESM::Embed.build(
    :success,
    description: I18n.t(
      "commands.add.requestee_success",
      user: target_user.mention,
      territory_id: arguments.territory_id
    )
  )

  ESM.bot.deliver(embed, to: target_user)

  # Don't send essentially the same message twice
  return if same_user?

  # Send a message to the requestor (if they aren't the requestee as well)
  embed = ESM::Embed.build(
    :success,
    description: I18n.t(
      "commands.add.requestor_success",
      current_user: current_user.mention,
      target_user: target_user.distinct,
      territory_id: arguments.territory_id,
      server_id: target_server.server_id
    )
  )

  reply(embed)
end