Skip to content

Commit

Permalink
Remove close, users can create task and cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMaster3558 committed Oct 9, 2022
1 parent 7f5a9cd commit f539b66
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions aiointeractions/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
__all__ = ('InteractionsApp',)


MISSING = discord.utils.MISSING
PONG: Dict[str, int] = {'type': 1} # pong response


Expand Down Expand Up @@ -67,16 +66,14 @@ def __init__(
self, client: discord.Client, *, app: Optional[web.Application] = None, route: str = '/interactions'
) -> None:
self.client = client
self.verify_key: VerifyKey = MISSING
self.verify_key: VerifyKey = discord.utils.MISSING

if app is None:
app = web.Application()

app.add_routes([web.post(route, self.interactions_handler)])
self.app: web.Application = app

self._runner_task: Optional[asyncio.Task[None]] = None

def _verify_request(self, headers: Mapping[str, Any], body: str) -> bool:
signature = headers.get('X-Signature-Ed25519')
timestamp = headers.get('X-Signature-Timestamp')
Expand Down Expand Up @@ -125,12 +122,4 @@ async def start(self, token: str, **kwargs: Any) -> None:
assert self.client.application is not None

self.verify_key = VerifyKey(bytes.fromhex(self.client.application.verify_key))
self._runner_task = self.client.loop.create_task(web._run_app(self.app, **kwargs))
await self._runner_task

def close(self) -> None:
"""
Close the app. If the app is not running then nothing will happen.
"""
if self._runner_task is not None:
self._runner_task.cancel()
await web._run_app(self.app, **kwargs)

0 comments on commit f539b66

Please sign in to comment.