diff --git a/src/modules/profiles/ui/twitchlink.py b/src/modules/profiles/ui/twitchlink.py index 0138acc..1188437 100644 --- a/src/modules/profiles/ui/twitchlink.py +++ b/src/modules/profiles/ui/twitchlink.py @@ -71,7 +71,8 @@ class TwitchLinkStatic(LeoUI): def embed(self, value): self._embed = value - @button(label="Link", custom_id="BTN-LINK-TWITCH", style=ButtonStyle.green, emoji='🔗') + @button(label="Connect", custom_id="BTN-LINK-TWITCH", style=ButtonStyle.green, emoji='🔗') + @log_wrap(action="link-twitch-btn") async def button_linker(self, interaction: discord.Interaction, btn: Button): # Here we just reply to the interaction with the AuthFlow UI # TODO @@ -116,7 +117,9 @@ class TwitchLinkFlow(MessageUI): # This can happen if starting the flow failed await self.close() + @log_wrap(action="start-twitch-flow-ui") async def _start_flow(self): + logger.info(f"Starting twitch authentication flow for {self.user}") try: self.flow = await self.bot.get_cog('TwitchAuthCog').start_auth() except aiohttp.ClientError: @@ -130,6 +133,7 @@ class TwitchLinkFlow(MessageUI): self._stage = FlowState.WAITING self._auth_task = asyncio.create_task(self._auth_flow()) + @log_wrap(action="run-twitch-flow-ui") async def _auth_flow(self): """ Run the flow and wait for a timeout, cancellation, or callback. @@ -138,12 +142,12 @@ class TwitchLinkFlow(MessageUI): assert self.flow is not None try: # TODO: Cancel this in cleanup - authrow = await asyncio.wait_for(self.flow.run(), timeout=180) + authrow = await asyncio.wait_for(self.flow.run(), timeout=60) except asyncio.TimeoutError: self._stage = FlowState.TIMEOUT # Link Timed Out! self._info = ( - "We didn't receive a response for three minutes so we closed the uplink " + "We didn't receive a response so we closed the uplink " "to keep your account safe! If you still want to connect, please try again!" ) await self.refresh() @@ -161,6 +165,8 @@ class TwitchLinkFlow(MessageUI): self._stage = FlowState.CANCELLED await self.refresh() await self.close() + except Exception: + logger.exception("Something unexpected went wrong while running the flow!") else: self._stage = FlowState.WORKING self._info = ( @@ -265,7 +271,7 @@ class TwitchLinkFlow(MessageUI): if self._stage is FlowState.WAITING: # Message should be the initial request page - dur = discord.utils.format_dt(utc_now() + timedelta(seconds=179), style='R') + dur = discord.utils.format_dt(utc_now() + timedelta(seconds=60), style='R') title = "Press the button to login!" desc = (