Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:17:58

And there is no city but that We will destroy it before the Day of Resurrection or punish it with a severe punishment. That has ever been in the Register inscribed.  

There is not a town — its inhabitants are the ones meant — but We shall destroy it before the Day of Resurrection, through death, or chastise it with terrible chastisement, by killing ˹its inhabitants˺ or otherwise. That has been inscribed in the Book, the Preserved Tablet (al-lawh al-mahfūz).
القرآن:١٧:٥٨

وَإِنْ مِنْ قَرْيَةٍ إِلَّا نَحْنُ مُهْلِكُوهَا قَبْلَ يَوْمِ الْقِيَامَةِ أَوْ مُعَذِّبُوهَا عَذَابًا شَدِيدًا ۚ كَانَ ذَٰلِكَ فِي الْكِتَابِ مَسْطُورًا  

{وإن} ما {من قرية} أريد أهلها {إلا نحن مهلكوها قبل يوم القيامة} بالموت {أو معذبوها عذابا شديدا} بالقتل وغيره {كان ذلك في الكتاب} اللوح المحفوظ {مسطورا} مكتوبا.