Added Shutdown-Command with cleanup
This commit is contained in:
@@ -18,6 +18,7 @@ version = "0.1"
|
|||||||
success = "**Success ✅**\n"
|
success = "**Success ✅**\n"
|
||||||
warning = "**Warning ℹ️**\n"
|
warning = "**Warning ℹ️**\n"
|
||||||
error = "**Error ❗️**\n"
|
error = "**Error ❗️**\n"
|
||||||
|
cache_dir = "cache"
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("-t", "--token", help="Bot TOKEN")
|
parser.add_argument("-t", "--token", help="Bot TOKEN")
|
||||||
@@ -34,7 +35,7 @@ else:
|
|||||||
|
|
||||||
ytdl_format_options = {
|
ytdl_format_options = {
|
||||||
"format": "bestaudio/mp3",
|
"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,
|
"restrictfilenames": True,
|
||||||
"noplaylist": True,
|
"noplaylist": True,
|
||||||
"nocheckcertificate": True,
|
"nocheckcertificate": True,
|
||||||
@@ -103,8 +104,10 @@ else:
|
|||||||
|
|
||||||
@bot.command(name="Shutdown")
|
@bot.command(name="Shutdown")
|
||||||
async def _shutdown(ctx):
|
async def _shutdown(ctx):
|
||||||
os.system("rm -r cache/*")
|
files = os.listdir(cache_dir)
|
||||||
await ctx.send(f"{success}Shutting down...")
|
for file in files:
|
||||||
|
os.remove(f"{cache_dir}/{file}")
|
||||||
|
await ctx.send(f"{success}Cleaned up {len(files)}...\nShutting down...")
|
||||||
#await bot.close
|
#await bot.close
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user