Skip to content

Commit 459398a

Browse files
committed
fix: /auto-enter checks preauth status even when already opted in
Previously, running /auto-enter enabled:true when already opted in would short-circuit with 'Already Opted In' without checking if the preauth was still active. After revoking a preauth, re-running /auto-enter now detects the missing preauth and requests a new one.
1 parent f274bd3 commit 459398a

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

luckypot/discord/commands.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,16 @@ async def invoke(self, ctx: lightbulb.Context) -> None:
171171
conn = db.get_connection()
172172
try:
173173
current = db.get_auto_enter_status(conn, discord_id, guild_id)
174-
if current == self.enabled:
175-
container = ui.build_auto_enter_already_in_state(self.enabled)
176-
await ctx.respond(
177-
components=[container], flags=hikari.MessageFlag.EPHEMERAL
178-
)
179-
return
180-
db.set_auto_enter(conn, discord_id, guild_id, self.enabled)
174+
already_opted_in = current == self.enabled
175+
if not already_opted_in:
176+
db.set_auto_enter(conn, discord_id, guild_id, self.enabled)
181177
finally:
182178
conn.close()
183179

184180
if self.enabled:
185-
# Check/request preauth for seamless auto-enter
181+
# Check/request preauth for seamless auto-enter.
182+
# Always check preauth status even if already opted in,
183+
# because the user may have revoked their preauth since.
186184
from luckypot import stk as stk_mod
187185
stk_user = await stk_mod.get_user_by_discord_id(discord_id)
188186
if stk_user:
@@ -206,6 +204,8 @@ async def invoke(self, ctx: lightbulb.Context) -> None:
206204
container = ui.build_auto_enter_opted_in()
207205
else:
208206
container = ui.build_auto_enter_opted_in()
207+
elif already_opted_in:
208+
container = ui.build_auto_enter_already_in_state(False)
209209
else:
210210
container = ui.build_auto_enter_opted_out()
211211
await ctx.respond(

0 commit comments

Comments
 (0)