Clean up alert message, move notification to an embed
This commit is contained in:
parent
62e3fec496
commit
5a2e183ccd
@ -74,7 +74,8 @@ class Alert:
|
|||||||
if self.alert_type == AlertType.SPECIFIC_PRICE:
|
if self.alert_type == AlertType.SPECIFIC_PRICE:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
else:
|
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:
|
async def _lazy_load(self, table: Table, consistent: bool = False) -> None:
|
||||||
if consistent or not self._loaded:
|
if consistent or not self._loaded:
|
||||||
|
@ -4,7 +4,7 @@ from typing import Type, Dict, List
|
|||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from interactions import Extension, SlashContext, component_callback, \
|
from interactions import Extension, SlashContext, component_callback, \
|
||||||
ComponentContext, StringSelectMenu, Message
|
ComponentContext, StringSelectMenu, Message, Embed
|
||||||
from interactions import Task, IntervalTrigger
|
from interactions import Task, IntervalTrigger
|
||||||
from interactions import slash_command, listen
|
from interactions import slash_command, listen
|
||||||
from interactions.api.events import Component
|
from interactions.api.events import Component
|
||||||
@ -58,11 +58,16 @@ class Tracker(Extension):
|
|||||||
for alert in users_alerts[user]:
|
for alert in users_alerts[user]:
|
||||||
if alert.alert_type != AlertType.SPECIFIC_PRICE:
|
if alert.alert_type != AlertType.SPECIFIC_PRICE:
|
||||||
alert_message += f"{alert.to_human_string()}"
|
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"token reaches a certain value.\n\n"
|
||||||
f"As a reminder, you can remove an alert via /remove-alert\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"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()
|
@slash_command()
|
||||||
async def list_alerts(self, ctx: SlashContext):
|
async def list_alerts(self, ctx: SlashContext):
|
||||||
alerts = await self._users.list_alerts(ctx.user.id)
|
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)
|
await ctx.send(str(alerts), ephemeral=True)
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
|
Loading…
Reference in New Issue
Block a user