feat: Add embeds as a function
All checks were successful
Build Docker / Build Docker (push) Successful in 17s

This commit is contained in:
Nathan Woodburn 2023-11-14 14:01:29 +11:00
parent 078403eaf7
commit 4a7f80e64f
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
2 changed files with 15 additions and 11 deletions

14
bot.py
View File

@ -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()

View File

@ -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'))