Added Shutdown-Command with cleanup

This commit is contained in:
Lukas Blacha
2023-02-07 23:10:05 +01:00
parent 6b8a8a0dfc
commit 837686c71d

View File

@@ -18,6 +18,7 @@ version = "0.1"
success = "**Success ✅**\n"
warning = "**Warning **\n"
error = "**Error ❗️**\n"
cache_dir = "cache"
logging.basicConfig(level=logging.INFO)
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--token", help="Bot TOKEN")
@@ -34,7 +35,7 @@ else:
ytdl_format_options = {
"format": "bestaudio/mp3",
"outtmpl": "cache/%(extractor)s-%(id)s-%(title)s.mp3",
"outtmpl": f"{cache_dir}/%(extractor)s-%(id)s-%(title)s.mp3",
"restrictfilenames": True,
"noplaylist": True,
"nocheckcertificate": True,
@@ -103,8 +104,10 @@ else:
@bot.command(name="Shutdown")
async def _shutdown(ctx):
os.system("rm -r cache/*")
await ctx.send(f"{success}Shutting down...")
files = os.listdir(cache_dir)
for file in files:
os.remove(f"{cache_dir}/{file}")
await ctx.send(f"{success}Cleaned up {len(files)}...\nShutting down...")
#await bot.close