It is soundly narrated in the authentic Sunnah that donkeys bray when they see a devil.
It was narrated from Abu Hurayrah (may Allah be pleased with him) that the Prophet (blessings and peace of Allah be upon him) said: “When you hear the crowing of a rooster, ask Allah of His Bounty, for it has seen an angel. But when you hear the braying of a donkey, then seek refuge with Allah from the Shaytan, for it has seen a devil.” Narrated by al-Bukhari (3303) and Muslim (2729).
And it is soundly narrated that the devils are shackled in Ramadan, as has been discussed previously in the answer to question no. 221162.
But does this shackling necessarily mean that their impact and behaviour, because of which one should seek refuge with Allah from them, comes to a stop, as we are instructed to seek refuge with Allah from the Shaytan when we hear the braying of a donkey, because when it brays, it is seeing a devil? The answer to this question is that the only thing the hadith states is that they will be shackled, which means that they are chained up, and the context of the hadith appears to indicate that by means of this shackling, their evil will be reduced, but it does not say that they will not have any ability to move and cause harm. It does not say that they will be tied up in a place that they will be unable to leave. And shackling does not necessarily mean that they stop moving, for a man may have shackles and chains placed on his hands and feet, yet he is able to move in his prison or when being transported from one place to another.
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
It is proven by the religious texts that the fasting person is not allowed to eat, drink or have intercourse, and it is soundly narrated from the Prophet (blessings and peace of Allah be upon him) that “The Shaytan flows through a person like blood.” Undoubtedly blood is generated from food and drink, and when a person eats or drinks, the channels through which the devils move are widened... Hence the Prophet (blessings and peace of Allah be upon him) said: “When the month of Ramadan comes, the gates of Paradise are opened and the gates of Hell are closed, and the devils are shackled.” The channels through which the devils move, namely the blood vessels, become narrow, and when they become narrow, a person feels more inclined to do righteous deeds because of which the gates of Paradise are opened, and to refrain from doing evil deeds, because of which the gates of Hell are opened. The devils are shackled and thus become weaker and less active due to being shackled, so they cannot have the same impact in Ramadan as they have in other months. The Prophet did not say that they are killed or that they die; rather he said that they are shackled, and the devil who is shackled could still cause harm, but his harm will be less and weaker than it is in months other than Ramadan…
End quote from Majmu` al-Fatawa, 25/246.
For more information, please see the answer to question no. 222629.
Conclusion:
The braying of a donkey is connected to its seeing a devil; if it sees a devil when the devil is shackled, then it is true that it has seen a devil, and as soon as it sees a devil it brays. That has nothing to do with the efforts of the Shaytan to mislead people or do anything else, and it has nothing to do with whether the devil is shackled or not. Therefore, there is no contradiction between the two hadiths. Whatever the case, this is one of the matters of the unseen that is to be understood on the basis of the religious texts, and no one can understand its true nature on the basis of rational thinking alone. What is required regarding such matters is for the Muslim to believe in it, without asking too many questions and trying to find out the details thereof.
For more information, please see the answer to question no. 39736.
And Allah knows best.