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:5:94

O you who have believed, Allah will surely test you through something of the game that your hands and spears ˹can˺ reach, that Allah may make evident those who fear Him unseen. And whoever transgresses after that - for him is a painful punishment.  

O you who believe, God will surely try you, He will surely test you, with some game, which He releases to you, the smaller of, which will be caught by your hands and, the larger of which by, your lances: this was in ˹the plain of˺ al-Hudaybiyya; while they were in ˹the state of˺ pilgrimage inviolability, beasts and birds would flock to their caravans; so that God may know, through knowledge outwardly manifested, who fears Him in the Unseen (bi’l-ghayb is a circumstantial qualifier), in other words, while He is absent ˹to the eyes˺, one who does not see Him but nonetheless avoids hunting game. Whoever transgresses thereafter, after that prohibition against it, and hunts, his shall be a painful chastisement.
القرآن:٥:٩٤

يَا أَيُّهَا الَّذِينَ آمَنُوا لَيَبْلُوَنَّكُمُ اللَّهُ بِشَيْءٍ مِنَ الصَّيْدِ تَنَالُهُ أَيْدِيكُمْ وَرِمَاحُكُمْ لِيَعْلَمَ اللَّهُ مَنْ يَخَافُهُ بِالْغَيْبِ ۚ فَمَنِ اعْتَدَىٰ بَعْدَ ذَٰلِكَ فَلَهُ عَذَابٌ أَلِيمٌ  

{يا أيها الذين آمنوا لَيبلونَّكم} ليختبرنكم {الله بشيء} يرسله لكم {من الصيد تناله} أي الصغار منه {أيديكم ورماحكم} الكبار منه، وكان ذلك بالحديبية وهم مُحرمون فكانت الوحش والطير تغشاهم في حالهم {ليعلم الله} علم ظهور {من يخافه بالغيب} حال أي غائبا لم يره فيجتنب الصيد {فمن اعتدى بعد ذلك} النهي عنه فاصطاده {فله عذاب أليم}.