Can i take these 3 bunches of code below

ok so i've been looking at this all wrong. the serial print is doing nothing for mqtt. i need to put all the line i need to change is

uint16_t packetIdPub1 = mqttClient.publish(MQTT_PUB_TEMP, 1, true, String(temp).c_str());

i just need to figure out how to combine the 3 lines the auther created into one. thank you for helping me in the right direction.