SPOzMaster
Posts: 2
Joined: Thu Apr 18, 2019 4:54 pm

Trying to make that my server can be started from Discord

Thu Apr 18, 2019 5:03 pm

Hi,
I was wondering is there a way to make that my server can be started from the Discord chat.
I have the Minecraft server hosted on my raspberry pi, and I have my discord server. So I want to make that my server can be started by typing the command. I know if it is possible, it will need the discord bot on my raspberry pi. I made that discord bot and currently I am hosting it. But I want that when user type the command, for example

Code: Select all

!start
, the bot send the command to the Raspberry Pi terminal.
I hope you can help me!

Andyroo
Posts: 2845
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Trying to make that my server can be started from Discord

Thu Apr 18, 2019 8:27 pm

No idea how you have set your server up but this site https://www.gngrninja.com/code/2017/3/2 ... spberry-pi has an example that uses Python to create an ‘add’ command to the system based on:

Code: Select all

async def add(left : int, right : int):
    """Adds two numbers together."""
    await bot.say(left + right)
You should be able to use this to create a hook to call the start routine for Minecraft using the Python OS module.

I do not have a Pi with Discord or Minecraft on to help anymore though :lol:
Need Pi spray - these things are breeding in my house...

SPOzMaster
Posts: 2
Joined: Thu Apr 18, 2019 4:54 pm

Re: Trying to make that my server can be started from Discord

Tue Apr 30, 2019 5:47 pm

I know that, but i don't know how to execute the terminal commands on Raspberry PI via Discord bot

Andyroo
Posts: 2845
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Trying to make that my server can be started from Discord

Tue Apr 30, 2019 5:57 pm

The link above gives you examples of creating the commands in Python.

There are plenty of YouTube examples that walk through the OS module but you will have to work out the commands that have to be called to kick off the server. If that’s a pain, you could use the subprocess commands to call the command line https://www.pythonforbeginners.com/os/s ... nistrators
Need Pi spray - these things are breeding in my house...

Return to “General programming discussion”