request for member '' in '', which is of non-class type ''

So I’ve been making a sort of one way Bluetooth pager and theres this one error i keep getting. The error ive been getting says error: request for member ‘substring’ in ‘msg’, which is of non-class type ‘int’ and the line with the error is [String line1 = msg.substring(16,31);. This line is supposed to allow me to use both lines of the lcd im using and i have no idea what the problem is. plz help me

here is the code

#include <LiquidCrystal.h>
const int speaker = 9;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int msg = Serial.available();

void setup() {
  //setting things up for speaker, messaging system and screen 
  pinMode(speaker, OUTPUT);
  Serial.begin(9600);
  lcd.begin(16, 2);
}

void loop() {
  if(Serial.available()){
    ////notifications
    //notification on screen
    lcd.clear();
    lcd.setCursor(3, 0);
    lcd.print("new message");
    //notification chime
    tone(speaker, 800);
    delay(70);
    noTone(speaker);
    delay(70);
    tone(speaker, 800);
    delay(70);
    noTone(speaker);
    delay(290);
    ////actual messaging
    //splitting serial data to use both lines on lcd
    String line1 = msg.substring(16,31); 
    //top line printing
    lcd.clear();
    lcd.setCursor(0, 0);
    while(Serial.available() > 0){
      lcd.write(Serial.available());
      //bottom line printing
      lcd.setCursor(0,1);
      lcd.print(line1);
    }
  }
}

btw im just starting programming so forgive me if the code is trash

msg is of type 'int'. Therefore, it does not have a method named 'substring()'. In fact, it's a simple data type not a class. It has not methods at all.

What is this supposed to accomplish?

int msg = Serial.available();

Regards,
Ray L.

I think you want to put "String msg = Serial.readString();" in loop() to actually read a message from the serial port.