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:29:18

And if you ˹people˺ deny ˹the message˺ - already nations before you have denied. And there is not upon the Messenger except ˹the duty of˺ clear notification.  

But if you deny, that is, if you deny me, O people of Mecca, then ˹many˺ communities have denied before you, that is, before my time; and the messenger’s duty is only to communicate ˹the Message˺ clearly’. Both stories are meant to comfort the Prophet (s). And regarding his people, God, exalted be He, says:
القرآن:٢٩:١٨

وَإِنْ تُكَذِّبُوا فَقَدْ كَذَّبَ أُمَمٌ مِنْ قَبْلِكُمْ ۖ وَمَا عَلَى الرَّسُولِ إِلَّا الْبَلَاغُ الْمُبِينُ  

{إنما تعبدون من دون الله} أي غيره {أوثانا وتخلقون إفكا} تقولون كذبا إن الأوثان شركاء الله {إن الذين تعبدون من دون الله لا يملكون لكم رزقا} لا يقدرون أن يرزقوكم {فابتغوا عند الله الرزق} اطلبوه منه {واعبدوه واشكروا له إليه ترجعون}.