how to use command blocks to enchant items code example
Example: how to give enchanted items
1.13+
/give @p diamond_sword{Enchantments:[{id:sharpness,lvl:5},{id:knockback,lvl:2},
{id:fire_aspect,lvl:2},{id:looting,lvl:3},{id:sweeping,lvl:3},
{id:unbreaking,lvl:3},{id:mending,lvl:1}]} 1
1.9+
/give @p diamond_sword 1 0 {ench:[{id:16,lvl:5},{id:19,lvl:2},{id:20,lvl:2},
{id:21,lvl:3},{id:34,lvl:3},{id:70,lvl:1}]}
pre 1.9
/give @p diamond_sword 1 0 {ench:[{id:16,lvl:5},{id:19,lvl:2},{id:20,lvl:2},
{id:21,lvl:3},{id:34,lvl:3}]}