You realise a Discourse Discord Bot framework already exists here that you can fork, modify and extend? Discord Bot Construction Kit 🤖. It does 99% of the housekeeping so you can focus on the functional side (it evens runs on your Discourse server so no additional infrastructure is required). The existing features act as a guide to whatever you want to add.
I would also accept PRs if you came up with anything useful to other communities.