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:
parent
cddc49bbfe
commit
5db4e76de8
@ -66,7 +66,10 @@ class Tracker(Extension):
|
|||||||
for alert in users_alerts[user]:
|
for alert in users_alerts[user]:
|
||||||
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"
|
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"
|
"Please note: \n"
|
||||||
"* You can only be registered with one region at a time \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")
|
"* 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)
|
await ctx.send(text, components=REGION_MENU, ephemeral=True)
|
||||||
|
|
||||||
@slash_command()
|
@slash_command()
|
||||||
async def remove_registration(self, ctx: SlashContext):
|
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)
|
await ctx.send("All alert subscriptions and user registration deleted", ephemeral=True)
|
||||||
|
|
||||||
@slash_command()
|
@slash_command()
|
||||||
async def delete(self, ctx: SlashContext):
|
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)
|
await ctx.send("Deletion Successful", ephemeral=True)
|
||||||
|
|
||||||
@slash_command()
|
@slash_command()
|
||||||
async def exists(self, ctx: SlashContext):
|
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()
|
@slash_command()
|
||||||
async def add_alert(self, ctx: SlashContext):
|
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"
|
await ctx.send("You are not registered with any region\n"
|
||||||
"Please register with /register before adding alerts",
|
"Please register with /register before adding alerts",
|
||||||
ephemeral=True)
|
ephemeral=True)
|
||||||
return
|
return
|
||||||
user = await self._users.get(ctx.member.id)
|
user = await self._users.get(ctx.user.id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
flavor = await self.flavor_select_menu(ctx)
|
flavor = await self.flavor_select_menu(ctx)
|
||||||
@ -151,7 +154,8 @@ class Tracker(Extension):
|
|||||||
|
|
||||||
@slash_command()
|
@slash_command()
|
||||||
async def list_alerts(self, ctx: SlashContext):
|
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 #
|
# Callbacks Commands #
|
||||||
@ -173,7 +177,7 @@ class Tracker(Extension):
|
|||||||
|
|
||||||
@component_callback('region_menu')
|
@component_callback('region_menu')
|
||||||
async def region_menu(self, ctx: ComponentContext):
|
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 self._users.add(user)
|
||||||
await ctx.send(f"Successfully registered with the {ctx.values[0]} region", ephemeral=True)
|
await ctx.send(f"Successfully registered with the {ctx.values[0]} region", ephemeral=True)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user