Update to use discord user id instead of member id

This is so interactions will work in a DM with the bot as well as in servers where the bot is located
This commit is contained in:
Emily Doherty 2024-11-30 04:45:36 -08:00
parent cddc49bbfe
commit 5db4e76de8

View File

@ -66,7 +66,10 @@ class Tracker(Extension):
for alert in users_alerts[user]:
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"
f"token reaches a certain value. The following alerts have been triggered: {alert_message}")
f"token reaches a certain value.\n\n"
f"As a reminder, you can always 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}")
###################################
@ -94,31 +97,31 @@ class Tracker(Extension):
"Please note: \n"
"* You can only be registered with one region at a time \n"
"* Changing your region will remove all previous alerts you have signed up for")
await self._users.add(ctx.member.id)
await self._users.add(ctx.user.id)
await ctx.send(text, components=REGION_MENU, ephemeral=True)
@slash_command()
async def remove_registration(self, ctx: SlashContext):
await self._users.delete(ctx.member.id)
await self._users.delete(ctx.user.id)
await ctx.send("All alert subscriptions and user registration deleted", ephemeral=True)
@slash_command()
async def delete(self, ctx: SlashContext):
await self._users.delete(ctx.member.id)
await self._users.delete(ctx.user.id)
await ctx.send("Deletion Successful", ephemeral=True)
@slash_command()
async def exists(self, ctx: SlashContext):
await ctx.send(str(await self._users.exists(ctx.member.id)), ephemeral=True)
await ctx.send(str(await self._users.exists(ctx.user.id)), ephemeral=True)
@slash_command()
async def add_alert(self, ctx: SlashContext):
if not await self._users.exists(ctx.member.id):
if not await self._users.exists(ctx.user.id):
await ctx.send("You are not registered with any region\n"
"Please register with /register before adding alerts",
ephemeral=True)
return
user = await self._users.get(ctx.member.id)
user = await self._users.get(ctx.user.id)
try:
flavor = await self.flavor_select_menu(ctx)
@ -151,7 +154,8 @@ class Tracker(Extension):
@slash_command()
async def list_alerts(self, ctx: SlashContext):
await ctx.send(str(await self._users.list_alerts(ctx.member.id)), ephemeral=True)
alerts = await self._users.list_alerts(ctx.user.id)
await ctx.send(str(alerts), ephemeral=True)
###################################
# Callbacks Commands #
@ -173,7 +177,7 @@ class Tracker(Extension):
@component_callback('region_menu')
async def region_menu(self, ctx: ComponentContext):
user = User(ctx.member.id, Region(ctx.values[0].lower()), subscribed_alerts=[])
user = User(ctx.user.id, Region(ctx.values[0].lower()), subscribed_alerts=[])
await self._users.add(user)
await ctx.send(f"Successfully registered with the {ctx.values[0]} region", ephemeral=True)