The chord util has no notion of what key you are in. If you ask for a C major chord, it will give you C major. If you ask for a D major chord, it will give you a D major chord. You must always specify the chord type when asking for a chord, so there’s never ambiguity anyway. I.e., there’s no way to ask for a “D” chord, you have to ask for a “D diminished 7” chord, so even if it did somehow know you were in a C major context, you still asked for Ddim7 so it’ll give you a Ddim7
I think if you write out the precise code you were attempting and post it here, and point out where you were unsure, that’d be a lot more concrete and possible to answer. Because as it is, given the inputs to the function, I’m not clear how it could work the way you’re asking about. Apologies I’m not able to understand!