Spectator Mode

I want to make a datapack if I hold a warped stick and do right click so my game mode will be changed to spectator but in after few delay my gamemode should be changed to survival can u help me how to add delay in datapacks and how to show a timer above the hotbar

Continue to help post