diff --git a/bruhbot.py b/bruhbot.py index 4a60a25..d697b0a 100644 --- a/bruhbot.py +++ b/bruhbot.py @@ -1,5 +1,5 @@ import asyncio -from datetime import date +from datetime import date, datetime import json import os import random @@ -49,6 +49,22 @@ def plural(num: int): await asyncio.sleep(3600) +async def auto_backup(): + with open(f"{here}\\bruhbot\\data.json", "r+") as f: + data = json.load(f) + now = date.today() + print(now) + last = datetime.strptime(data["lastbackup"], "%Y-%m-%d") + rdelta = relativedelta(now, last) + if rdelta.months >= 1: + ResponseBackup.run() + data["lastbackup"] = now.strftime("%Y-%m-%d") + f.seek(0) + json.dump(data, f, indent=4) + else: + return + + async def send_dm(user: discord.User, content: discord.Embed): dm = await user.create_dm() await dm.send(embed=content) @@ -95,6 +111,7 @@ async def send_image(ctx, response: str): async def on_ready(): servers = list(bot.guilds) print(f"{bot.user.name}(ID:{bot.user.id}) connected to {str(len(servers))} servers") + await auto_backup() await check_age() @@ -951,6 +968,12 @@ async def time(ctx): @commands.is_owner() async def backup(ctx): ResponseBackup.run() + with open(f"{here}\\bruhbot\\data.json", "r+") as f: + data = json.load(f) + now = date.today() + data["lastbackup"] = now.strftime("%Y-%m-%d") + f.seek(0) + json.dump(data, f, indent=4) await ctx.send("Response list saved to backup.") diff --git a/bruhbot/cogs/Names/__pycache__/names.cpython-38.opt-1.pyc b/bruhbot/cogs/Names/__pycache__/names.cpython-38.opt-1.pyc index 6d02536..2ccb015 100644 Binary files a/bruhbot/cogs/Names/__pycache__/names.cpython-38.opt-1.pyc and b/bruhbot/cogs/Names/__pycache__/names.cpython-38.opt-1.pyc differ diff --git a/bruhbot/cogs/Names/names.json b/bruhbot/cogs/Names/names.json index 4ccb5f4..5c1bc9c 100644 --- a/bruhbot/cogs/Names/names.json +++ b/bruhbot/cogs/Names/names.json @@ -248,7 +248,8 @@ "Buckachino", "Penile", "Brumbpo", - "Cremrold" + "Cremrold", + "Chad" ], "lastnames": [ "McDichael", diff --git a/bruhbot/cogs/OPBR/__pycache__/OPBR.cpython-38.opt-1.pyc b/bruhbot/cogs/OPBR/__pycache__/OPBR.cpython-38.opt-1.pyc index e131a11..ba068bc 100644 Binary files a/bruhbot/cogs/OPBR/__pycache__/OPBR.cpython-38.opt-1.pyc and b/bruhbot/cogs/OPBR/__pycache__/OPBR.cpython-38.opt-1.pyc differ diff --git a/bruhbot/data.json b/bruhbot/data.json index ffbec75..b8fce90 100644 --- a/bruhbot/data.json +++ b/bruhbot/data.json @@ -1,26 +1,27 @@ { - "addr": { - "description": "```Syntax: $addr [phrase/image name]```\n**Add Responses.**\nAdds a new response to the list.\nImages support custom names." - }, - "delr": { - "description": "```Syntax: $delr```\n**Delete responses.**\nDisplays a menu that allows a user to delete a specific response." - }, - "rlist": { - "description": "```Syntax: $rlist```\n**Show response list.**\nDisplays the list of possible responses." - }, - "age": { - "description": "```Syntax: $age```\n**Check bot age.**\nReturns number of years/months/days since creation." - }, - "forza": { - "name": "Check Forza season", - "description": "```Syntax: $forza```\n**Check current Forza season**\nReturns the current season for both Horizon 4 and Horizon 5\n\n**__Subcommands__**\n**time** Displays the time until the next season" - }, - "response": { - "name": "__**Response**__", - "description": "**addr** Add a new response to the list.\n**delr** Remove a response from the list.\n**rlist** View the list of current responses." - }, - "extra": { - "name": "__**Extra Stuff**__", - "description": "**age** Returns the current age of the bot." - } + "lastbackup": "2024-01-19", + "addr": { + "description": "```Syntax: $addr [phrase/image name]```\n**Add Responses.**\nAdds a new response to the list.\nImages support custom names." + }, + "delr": { + "description": "```Syntax: $delr```\n**Delete responses.**\nDisplays a menu that allows a user to delete a specific response." + }, + "rlist": { + "description": "```Syntax: $rlist```\n**Show response list.**\nDisplays the list of possible responses." + }, + "age": { + "description": "```Syntax: $age```\n**Check bot age.**\nReturns number of years/months/days since creation." + }, + "forza": { + "name": "Check Forza season", + "description": "```Syntax: $forza```\n**Check current Forza season**\nReturns the current season for both Horizon 4 and Horizon 5\n\n**__Subcommands__**\n**time** Displays the time until the next season" + }, + "response": { + "name": "__**Response**__", + "description": "**addr** Add a new response to the list.\n**delr** Remove a response from the list.\n**rlist** View the list of current responses." + }, + "extra": { + "name": "__**Extra Stuff**__", + "description": "**age** Returns the current age of the bot." + } } \ No newline at end of file