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:4:147

What would Allah do with your punishment if you are grateful and believe? And ever is Allah Appreciative and Knowing.  

Why would God chastise you if you are thankful, of His favours, and believe, in Him? (the interrogative is meant as a denial, in other words: He would not punish you). God is ever Thankful, of the deeds of believers, rewarding them, Knowing, of His creation.
القرآن:٤:١٤٧

مَا يَفْعَلُ اللَّهُ بِعَذَابِكُمْ إِنْ شَكَرْتُمْ وَآمَنْتُمْ ۚ وَكَانَ اللَّهُ شَاكِرًا عَلِيمًا  

{ما يفعل الله بعذابكم إن شكرتم} نعمه {وآمنتم} به والاستفهام بمعنى النفي أي لا يعذبكم {وكان الله شاكرا} لأعمال المؤمنين بالإثابة {عليما} بخلقه.