How can I automatically embed a Bandcamp player on my site?

You mean in your site that isn’t discourse?

You can look in the discourse source and search for “onebox” or maybe “one_box”

Or maybe see https://get.bandcamp.help/hc/en-us/articles/360013561254-How-do-I-create-a-Bandcamp-embedded-player-#:~:text=To%20create%20an%20embedded%20player,your%20merchandise%2C%20and%20so%20on. And use that to develop code for your site.