Update sherlock command

This commit is contained in:
Nexus 2023-06-03 15:20:34 +01:00
parent 230e3e8378
commit c7a89dbe46
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -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):