How to achieve cooldown in datapack
So i am making a datapack where whenever i hold gem in my offhand (gems are each element like fire, wind, lighting, earth, water and so on) when i sneak and left click or right click it uses its ability
*
Continue to help postLeft Click
summons a fireball at player location which can be used by the player to shoot at any direction.
but the thing is if we dont add a cooldown to that mcfunction then the fire gem ability can be abused and it will be very powerful can we do something so whenever i sneak and left click it shoots if cooldown is over but if it is not over it sends in chat as tellraw
message in red color that "The ability of Firegem has cooldown". Can we do something like this in mc datapack? Please Help me!