-3

I have a bot in Python which contains a dice roller, which is difficult to do in JavaScript. As soon as I start the bot, I would like the bot in discord.py to work as well. Is it possible with child_process? If so, what code should I use?

I want to start the bot in Python with JS.

Lauren Yim
  • 12,700
  • 2
  • 32
  • 59
Kiogra
  • 1
  • 2
  • It's not hard, just do it in JS. And if you really want to do it in Python, why not make the rest of the bot in Python too? – stijndcl Nov 07 '22 at 14:10
  • "Rolling a diece is hard" but working with child processes not? I dont know, but getting a random number between 1 & 6 should be much easier than IPC... – Marc Nov 12 '22 at 10:58

1 Answers1

2

My recommendation would be to rewrite the dice logic in JS. "rolling dice" is a pretty common beginner task in programming so finding a tutorial won't be difficult.

If you are deadset on attempting this, use the child_process module as detailed here. https://stackoverflow.com/a/20643568/7960407

However, I would recommend against it as the performance of your app will likely be unusable. Additionally debugging should something go wrong will also be a nightmare.

therealdakotal
  • 244
  • 1
  • 11
  • 5
    100% agree, using multiple processes here is absolute overkill. And someone who considers a dice roll "difficult to do in js" is absolutely not ready for interprocess communication. Rewriting the python logic in Javascript is the correct solution to the problem at this level – Sebastian Gudiño Nov 07 '22 at 12:36