Module: ESM::Command::Territory::SetId::V1

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

Instance Method Summary collapse

Instance Method Details

#check_for_failure!Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/esm/command/territory/set_id.rb', line 65

def check_for_failure!
  return if @response.success

  # Don't set a cooldown if we errored.
  skip_action(:cooldown)

  # DLL Reason. This is a weird one since I can't localize the message
  if @response.reason
    raise_error! do
      ESM::Embed.build(:error, description: "I'm sorry #{current_user.mention}, #{@response.reason}")
    end
  end

  raise_error!(:access_denied, user: current_user.mention)
end

#on_executeObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/esm/command/territory/set_id.rb', line 45

def on_execute
  # Require at least 3 characters and a max of 20
  check_for_minimum_characters!
  check_for_maximum_characters!

  # Set the request
  deliver!(
    command_name: "setterritoryid",
    query: "set_custom_territory_id",
    player_uid: current_user.steam_uid,
    old_territory_id: arguments.old_territory_id,
    new_territory_id: arguments.new_territory_id
  )
end

#on_responseObject



60
61
62
63
# File 'lib/esm/command/territory/set_id.rb', line 60

def on_response
  check_for_failure!
  reply(success_message)
end