I couldn't find anything on the internet, but this should work:
Open your game and select "Mystery Gift" from the Title Screen.
Open the record book of all the mystery Gifts you have recieved.
Select the Mystery Gift card of Diancie.
Delete the card.
Theoretically, once you delete the Diance card, the game has no proof that you already gave a code, therefore you can put in a new one. If this answer is considered incomplete or doesn't have enough proof, I can hide it or convert it to a comment.