mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 18:16:34 +01:00
Update sherlock command
This commit is contained in:
parent
230e3e8378
commit
c7a89dbe46
1 changed files with 69 additions and 66 deletions
|
@ -3,6 +3,7 @@ import glob
|
|||
import io
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import random
|
||||
import re
|
||||
|
@ -1561,7 +1562,8 @@ class OtherCog(commands.Cog):
|
|||
|
||||
await ctx.defer()
|
||||
# output results to a temporary directory
|
||||
with tempfile.TemporaryDirectory() as tempdir:
|
||||
tempdir = Path("./tmp/sherlock").resolve()
|
||||
tempdir.mkdir(parents=True, exist_ok=True)
|
||||
command = [
|
||||
"docker",
|
||||
"run",
|
||||
|
@ -1601,6 +1603,7 @@ class OtherCog(commands.Cog):
|
|||
pass
|
||||
# If it errored, send the error
|
||||
if result.returncode != 0:
|
||||
shutil.rmtree(tempdir, ignore_errors=True)
|
||||
return await ctx.edit(
|
||||
embed=discord.Embed(
|
||||
title="Error",
|
||||
|
@ -1619,7 +1622,6 @@ class OtherCog(commands.Cog):
|
|||
else:
|
||||
desc = f"```ansi\n{stdout}```"
|
||||
title = "Results"
|
||||
print(glob.glob(f"{tempdir}/*"))
|
||||
files = list(map(discord.File, glob.glob(f"{tempdir}/*")))
|
||||
await ctx.edit(
|
||||
files=files,
|
||||
|
@ -1629,6 +1631,7 @@ class OtherCog(commands.Cog):
|
|||
colour=discord.Colour.green(),
|
||||
),
|
||||
)
|
||||
shutil.rmtree(tempdir, ignore_errors=True)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
|
|
Loading…
Reference in a new issue