diff --git a/bot.py b/bot.py index 62de82a..f124f81 100644 --- a/bot.py +++ b/bot.py @@ -12,9 +12,9 @@ import binascii from cryptography import x509 from cryptography.hazmat.backends import default_backend import datetime -from apscheduler.schedulers.asyncio import AsyncIOScheduler import chatai -from timeparser import parse_time, read_reminders, store_reminder, write_reminders +import tools +from tools import parse_time, read_reminders, store_reminder, write_reminders import asyncio from discord.ext import tasks, commands @@ -479,15 +479,8 @@ async def check_reminders(): reminder_time = datetime.datetime.strptime(reminder['time'], "%Y-%m-%d %H:%M:%S") if reminder_time <= now: user = await client.fetch_user(int(reminder['user_id'])) - embed = discord.Embed( - title='Reminder', - description=reminder['text'], - color=discord.Color.dark_purple() - ) - # Set a footer for the embed - embed.set_footer(text='Powered by Nathan.Woodburn/') - await user.send(embed=embed) + await user.send(embed=tools.embed("Reminder", reminder['text'])) print("Reminder sent for "+str(reminder), flush=True) reminders.remove(reminder) @@ -501,7 +494,6 @@ async def on_ready(): ADMINID = client.application.owner.id await tree.sync() updateStatus() - await checkForSSLExpiry() check_reminders.start() checkForSSLExpiry.start() diff --git a/timeparser.py b/tools.py similarity index 89% rename from timeparser.py rename to tools.py index fdd26ec..cacbe02 100644 --- a/timeparser.py +++ b/tools.py @@ -1,5 +1,6 @@ import datetime import re +import discord REMINDERS_FILE_PATH = '/mnt/reminders.txt' @@ -52,6 +53,17 @@ def store_reminder(user_id, reminder_time, reminder_text): }) write_reminders(reminders) +def embed(title, description): + embed = discord.Embed( + title=title, + description=description, + color=discord.Color.dark_purple() + ) + + # Set a footer for the embed + embed.set_footer(text='Powered by Nathan.Woodburn/') + return embed + if __name__ == '__main__': print(parse_time('1d 2h 3m 4s'))