'Is it possible to pass Bash commands from a Discord bot into a server's bash input?
I am an amateur Python scripter and Linux user, so please bare with me. I have made simple Discord bots in the past.
I have a personal project where I want to simulate a Unix-like terminal in a discord channel, i.e. if I type 'ls', the discord bot will respond with the typical terminal output, a list of files. The intent is to use this bot for a realtime RPG game I am planning, and I think Discord would be a great prop. I intend to write the bot in Python, as I do not know javascript.
Can anyone comment on if this is possible, and if there would be any major pitfalls I should be aware of?
Follow-up question, should this be run in a Docker container to avoid destroying my AWS server?
Solution 1:[1]
You could try os.system()
Start by importing the os module:
import os
and you could try:
bot.command()
async def run(ctx, arg1)
ctx.send(os.system(arg1))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Trent112232 |
