How do I bind a command to an item?

I am trying to create a few modified weapons/items in Minecraft, so that when you hit something (left click) with the specific item, it executes a command. I have already found a few answers that make it so that if you use a specific item it executes a command, but that applies for every single one of that item; for example, if a blaze rod gives you strength, every blaze rod in the game will give you strength. Is there a way to do this with only one item?


Easy.

Give yourself a blaze rod that has a very special tag and then iterate through the players to see if they are holding the the speical blaze rod.

say give @s blaze_rod{Unbreakable:3b} 1 gives you a blaze rod with unbreakable 3b tag.

run this in a tick function now execute as @a[nbt={SelectedItem:{id:minecraft:blaze_rod,Count:1,tag:{Unbreakable:3b}}}] run effect give @s strength 2 255 true

This would give effect strength level 255 to anyone who is holding the rod.

Hope this helps.