Clean up alert message, move notification to an embed

This commit is contained in:
Emily Doherty 2024-12-03 02:43:06 -08:00
parent 62e3fec496
commit 5a2e183ccd
2 changed files with 13 additions and 4 deletions

View File

@ -74,7 +74,8 @@ class Alert:
if self.alert_type == AlertType.SPECIFIC_PRICE:
raise NotImplementedError
else:
return f"\n|\tRegion: {self.region.value.upper()}\tFlavor: {self.flavor.name.lower()}\tAlert: {self.alert_type.name.lower()}\t|"
alert_type_str = ' '.join(self.alert_type.name.split("_"))
return f"\n|\tRegion: {self.region.value.upper()}\tFlavor: {self.flavor.name.lower()}\tAlert: {alert_type_str.title()}\t|"
async def _lazy_load(self, table: Table, consistent: bool = False) -> None:
if consistent or not self._loaded:

View File

@ -4,7 +4,7 @@ from typing import Type, Dict, List
import aiohttp
from interactions import Extension, SlashContext, component_callback, \
ComponentContext, StringSelectMenu, Message
ComponentContext, StringSelectMenu, Message, Embed
from interactions import Task, IntervalTrigger
from interactions import slash_command, listen
from interactions.api.events import Component
@ -58,11 +58,16 @@ class Tracker(Extension):
for alert in users_alerts[user]:
if alert.alert_type != AlertType.SPECIFIC_PRICE:
alert_message += f"{alert.to_human_string()}"
await discord_user.send(f"Hello, you requested to be sent an alert when the price of the World of Warcraft "
embed = Embed(
title="TokenBot Tracker Alert Triggered",
color=0xb10000,
description=f"Hello, you requested to be sent an alert when the price of the World of Warcraft "
f"token reaches a certain value.\n\n"
f"As a reminder, you can remove an alert via /remove-alert\n"
f"or you can remove all registrations via /remove-registration\n\n"
f"The following alerts have been triggered: {alert_message}")
f"The following alerts have been triggered: {alert_message}",
)
await discord_user.send(embed=embed)
###################################
@ -144,6 +149,9 @@ class Tracker(Extension):
@slash_command()
async def list_alerts(self, ctx: SlashContext):
alerts = await self._users.list_alerts(ctx.user.id)
alerts_str = str()
for alert in alerts:
alerts_str += f"{alert.to_human_string()}\n"
await ctx.send(str(alerts), ephemeral=True)
###################################