Sayyiduna Ibn Abbas (may Allah be pleased with them both), explaining this verse: "It is not fitting for a prophet that he should have captives" [Surah al-Anfal: 67], recited until he reached: "a great punishment" [Surah al-Anfal: 68] - that is, the spoils of Badr, before Allah made them lawful for them. He said: "Were it not that I do not punish anyone until I have warned him beforehand," then "a great punishment would have touched you for what you took" [Surah al-Anfal: 68].
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 11349