Electron-energy-loss spectroscopy (EELS) is a widely used experimental technique for characterization of nanoparticles, being an extension of a standard electron microscopy. In EELS a particle under study is exposed to an electron beam and the loss of electron kinetic energy is measured after the interaction, varying the transverse position of the beam. This technique is particularly suitable for plasmonic nanoparticles, which exhibit unique optical properties caused by localized surface plasmon resonances (LSPRs). EELS excites full set of LSPRs and allows mapping them with unprecedented spatial resolution of down to 1?nm. The discrete dipole approximation (DDA) is a numerically exact method for simulating interaction of electromagnetic waves with particles of arbitrary shape and internal structure. It is based on volume-integral equation (VIE) in the frequency domain. In this work we extend the DDA to simulate EELS. We base all theoretical derivations on the VIE, in particular, the electric field of a moving electron is given as a line integral of the Green's tensor. Although the final expressions agree with classical textbooks, our approach allows us to employ the energy-budget considerations in the frequency domain. First, this framework leads to an expression for energy losses of electron moving faster than the speed of light in non-absorbing homogeneous medium (Cherenkov radiation), that is in agreement with the classical result (Frank-Tamm formula). Second, it leads to rigorous and general expressions for additional losses in the presence of a scatterer. These expressions are given as integrals over the volume of the scatterer (very convenient for the DDA) and are valid not only for the case of vacuum, but for arbitrary (even absorbing) host medium. We are working on implementing them in the open-source software package ADDA.