Limiting items in inventory
I have buttons that give you items on my map and I am trying to make it so that the datapack detects when you have more than a certain amount of that item and clears the items out of your inventory an am not sure what command to do to achieve this and not sure if you can do it with items like the shield.