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.
ahmad-zuhd:1296ʿAbdullāh b. ʿUmar Mashkad

[Machine] The ants multiplied and harmed the crops, so the Prophet ordered for a chair to be placed over their hole. Then he praised and thanked Allah and said, "Since you have harmed us, stop doing so, otherwise we will harm you." The ants stopped harming and they went away.  

الزهد لأحمد:١٢٩٦حَدَّثَنَا عَبْدُ اللَّهِ بْنُ عُمَرَ مَشْكَدٌ أَنَّهُ قَالَ حَدَّثَنِي حُسَيْنٌ الْجُعْفِيُّ عَنْ زَائِدَةَ عَنْ هِشَامٍ عَنِ الْحَسَنِ قَالَ

كَثُرَ النَّمْلُ فَآذَيْنَ الْأَحْنَفَ فَأَمَرَ بِكُرْسِيٍّ فَوُضِعَ عَلَى جُحْرِهِنَّ ثُمَّ حَمِدَ اللَّهَ وَأَثْنَى عَلَيْهِ وَقَالَ إِنَّكُنَّ آذَيْتُمُونَا فَاكْفِفْنَ وَإِلَّا آذَيْنَاكُنَّ قَالَ فَكَفَفْنَ وَذَهَبْنَ