When you play in D minor, the scale -- that is your "palette" of notes -- is: D, E, F, G, A, B♭, and C
You'll find it's not possible to play a D major chord using those notes. D major contains an F♯.
The simplest way to find the chord you want is to identify its root note, then play a triad starting on that note, using only the notes in the scale.
- if the accompanying bass note in your head is D, play D, F, A -- that's a D minor.
- if the accompanying bass note in your head is C, play C, E, G -- that's a C major.
If you've been writing music with no background in theory, it's possible you've broken this rule, and it still sounds good. That's fine. They're not "rules", they're conventions, and they're conventions that are broken from time to time. So if the "maths" says you should play a minor, but a major sounds right to you, by all means stick with the major.
Footnote: That's a the "natural minor" scale. There is also the "harmonic minor" in which the 7th is sharpened - so C♯ here - and the "melodic minor" in which the 7th is sometimes sharpened, and sometimes not, largely at the composer's whim. And there are other scales which are considered minor because the 3rd is 3 semitones from the root, but are less common in Western music. But understand how things work with the "natural" scale before worrying about these. The important thing is that generally a scale is restricted to 7 notes from the 12 available, and if you play triads from that palette of 7, you'll find that a mixture of major and minor chords "automatically" happen.