Add a bash command
This commit is contained in:
parent
5fe0e65cb3
commit
11b6366360
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue