Best practice re: sending commands to discord bot from other services like a backend server processing a gamestate #6770
-
Is there a best practice regarding sending commands to a running discord bot from external services? For example, as a proof of concept I have my main.js which logs in to the bot at the end of the code and then after that I make a simple 'http' server and start listening further at the end of the bot main.js. I was able to send commands to the bot from my discord test channel, as well as use postman to post an http request to the bot and it successfully did the code which was just sending a message to a hardcoded ID. I'm wondering if there is any reason not to use this naive solution. And further, if I were to get into sharding and understanding that, how would this interact in that case? Alternatively, is it better to have a separate application running somewhere which has a server that can log into a discord client and send message when it gets an api call, and keep 1 other server up which just handles commands that come from discord channels themselves? This is what I have now that worked, but I want to know if this will have some performance or other issues, or if there is maybe a different best practice for when functionality like this is needed.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
What you're describing is building an API for your application, and yes, this is generally what I'd recommend as best practice. You'd likely want to secure those endpoints with client_credential / JWT authentication too however. |
Beta Was this translation helpful? Give feedback.
What you're describing is building an API for your application, and yes, this is generally what I'd recommend as best practice. You'd likely want to secure those endpoints with client_credential / JWT authentication too however.