Skip to content

Commit

Permalink
moved whole reaction handling to async tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
ranshaa05 committed Feb 2, 2024
1 parent 0f57fcc commit dd02420
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ async def save_send_screenshot(self, session_id):

self.original_message = await self.original_message.fetch()

await self.remove_reaction()
asyncio.create_task(self.remove_reaction())
if self.view:
await self.view.wait()
await self.add_reaction()
asyncio.create_task(self.add_reaction())

async def remove_reaction(self):
"""Removes all reactions from the original message."""
if (
isinstance(self.original_message.channel, nextcord.abc.GuildChannel)
and not self.original_message.flags.ephemeral
): # check if message is reactable in the first place
asyncio.create_task(self.original_message.clear_reactions())
await self.original_message.clear_reactions()

async def add_reaction(self):
"""Adds a reaction to the original message based on the button pressed in the view."""
Expand All @@ -94,10 +94,10 @@ async def add_reaction(self):
self.view.current_label[i : i + 3]
for i in range(0, len(self.view.current_label), 3)
]:
asyncio.create_task(self.original_message.add_reaction(emoji))
await self.original_message.add_reaction(emoji)
else:
asyncio.create_task(self.original_message.add_reaction(self.view.current_label))
asyncio.create_task(self.original_message.add_reaction("⏳"))
await self.original_message.add_reaction(self.view.current_label)
await self.original_message.add_reaction("⏳")

async def get_screenshot_info_by_stage(self, stage, session_id):
"""Returns the selector, crop, and view based on the stage of the grid, as well as the base64 image if on the last stage."""
Expand Down

0 comments on commit dd02420

Please sign in to comment.