From 11b63663608e00a06a2d4b8af6f640df04c3c505 Mon Sep 17 00:00:00 2001 From: Phxntxm Date: Thu, 11 Jan 2018 10:56:11 -0600 Subject: [PATCH] Add a bash command --- cogs/owner.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cogs/owner.py b/cogs/owner.py index 212466c..f061906 100644 --- a/cogs/owner.py +++ b/cogs/owner.py @@ -11,6 +11,7 @@ import inspect import pendulum import textwrap import traceback +import subprocess from contextlib import redirect_stdout import io @@ -248,6 +249,17 @@ class Owner: except discord.HTTPException: await ctx.send("Content too large for me to print!") + @commands.command() + @commands.check(utils.is_owner) + async def bash(self, ctx, *, cmd: str): + """Runs a bash command""" + proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) + output, error = proc.communicate() + if output: + await ctx.send("STDOUT:\n```\n{}```".format(output.decode("utf-8", "ignore"))) + if error: + await ctx.send("STDERR:\n```\n{}```".format(error.decode("utf-8", "ignore"))) + @commands.command() @commands.check(utils.is_owner) async def shutdown(self, ctx):