MV randomized Yanfly's attach augment?

Is it possible to give the player an equip that comes with an attachment? if it's possible can you randomize it?

I imagine you can use the functions the plugin uses to make new equips when the player uses an attachment from the menu but this seems to be beyond my ability.
This is a script that I used. It's not 100% perfect and may need some tuning, but it can be a good starting point for you. This script will take the weapon called "Blaster" and attach the augment "Glyph of the Voltage" on it if the Party has both items.

Code:
let weapon = $gameParty.allItems().find(item => item.name == "Blaster");
let augment = $gameParty.allItems().find(item => item.name == "Glyph of the Voltage");

if (weapon && item)
    ItemManager.applyAugmentEffects(weapon, augment, 0, 1);
The 0 represents the slotId and 1 represents "gain", but I forgot what exactly "gain" means.
oh so you just add the equip and the item and then use the item on the new equip.
that seems so obvious now XD
thank you!
got the randomized version working 😀

Code:
$gameParty.gainItem($dataWeapons[$gameVariables.value(1)], 1, false);
$gameParty.gainItem($dataItems[$gameVariables.value(2)], 1);

weapon = $gameParty.allItems().find(item => item.name == $dataWeapons[$gameVariables.value(1)].name);
augment = $gameParty.allItems().find(item => item.name == $dataItems[$gameVariables.value(2)].name);

ItemManager.applyAugmentEffects(weapon, augment, 0, 1);

Original thread: https://forums.rpgmakerweb.com/threads/randomized-yanflys-attach-augment.136220/