Minecraft – way to give an enchanted book with a random enchatment level?

minecraft-commandsminecraft-java-edition

So the backstory about this is that we are trying to give a reward out with of an enchanted book with a random level. Aka Protection I-V randomly. I know the command /give @p enchanted_book 1 0 {StoredEnchantments:[{id:34,lvl:X}]}, with X being the enchantment level, but is there a way to change that to a random number? Like random of the vanilla enchantments of course. Or do I need to explore scripts for that kind of stuff? Full story, Crazy Crates reward, of a random enchanted book, of a random level. Have the first two down easy, just the random level part…. Thank you ahead of time yall!

Best Answer

Well i don't think you can, the closest thing to that would be different command blocks and changing them up every so often that way it randomizes, that or have them step on a pressure plate and the redstone signal going random directions, where the redstone sgnal would hit at different times, and when hitting one it ends up blocking the rest that way they don't get more than one, or use a dispenser....