wow-token-app-bot

An interactions.py Discord bot for getting and alerting on the WoW Token Price
git clone https://git.emily.sh/wowtoken-app/wow-token-app-bot.git
Log | Files | Refs | README | LICENSE

commit 5a2e183ccdad2d6d125f02f35681e0e0fc4b56fa
parent 62e3fec496f421bcb5fa8e812cab232aec011a77
Author: Emily Doherty <git@emily.sh>
Date:   Tue,  3 Dec 2024 02:43:06 -0800

Clean up alert message, move notification to an embed

Diffstat:
Mtoken_bot/persistant_database/alert_schema.py | 3++-
Mtoken_bot/tracker.py | 14+++++++++++---
2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/token_bot/persistant_database/alert_schema.py b/token_bot/persistant_database/alert_schema.py @@ -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: diff --git a/token_bot/tracker.py b/token_bot/tracker.py @@ -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) ###################################