Planning observation: determine dates where moon is within 30 degrees of my object?
I would use JPL Horizons to calculate the position of the Moon and save the results to a text file. Then use a spreadsheet to calculate the separation between the Moon and your object. $$\cos \theta = \sin \delta_1 \sin \delta_2 + \cos \delta_1 \cos \delta_2 \cos (\alpha_1 - \alpha_2)$$ where $\theta$ is the separation, $\delta$ is the declination, and $\alpha$ is the right ascension.

Since the Moon moves about 1 degree in 2 hours, you can use that to determine what time interval to use in the output, depending on how accurately you want to find the 30 degree separation.