1
0
Fork 0
mirror of synced 2024-05-18 19:42:28 +12:00

Add a bash command

This commit is contained in:
Phxntxm 2018-01-11 10:56:11 -06:00
parent 5fe0e65cb3
commit 11b6366360

View file

@ -11,6 +11,7 @@ import inspect
import pendulum import pendulum
import textwrap import textwrap
import traceback import traceback
import subprocess
from contextlib import redirect_stdout from contextlib import redirect_stdout
import io import io
@ -248,6 +249,17 @@ class Owner:
except discord.HTTPException: except discord.HTTPException:
await ctx.send("Content too large for me to print!") 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.command()
@commands.check(utils.is_owner) @commands.check(utils.is_owner)
async def shutdown(self, ctx): async def shutdown(self, ctx):