diff --git a/Music-Bot.py b/Music-Bot.py index ca91844..5b67bec 100644 --- a/Music-Bot.py +++ b/Music-Bot.py @@ -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