We report on DFT-TDDFT studies of the structural, electronic and vibrational properties of B24N24 nanocapsules and the effect of encapsulation of homonuclear diatomic halogens (Cl2, Br2 and I2) and chalcogens (S2 and Se2) on the interaction of the B24N24 nanocapsules with the divalent magnesium cation. In particular, to foretell whether these BN nanostructures could be proper negative electrodes for magnesium-ion batteries, the structural, vibrational and electronic properties, as well as the interaction energy and the cell voltage, which is important for applications, have been computed for each system, highlighting their differences and similarities. The encapsulation of halogen and chalcogen diatomic molecules increases the cell voltage, with an effect enhanced down groups 16 and 17 of the periodic table, leading to better performing anodes and fulfilling a remarkable cell voltage of 3.61 V for the iodine-encapsulated system.