(interactions): Support callback extra check.

This commit is contained in:
2022-04-26 13:44:20 +03:00
parent 82e1141b2f
commit f5909e8414

View File

@@ -48,12 +48,12 @@ class AwaitableComponent:
return await client.wait_for('interaction_create', timeout=timeout, check=_check) return await client.wait_for('interaction_create', timeout=timeout, check=_check)
def add_callback(self, timeout=None, repeat=True, pass_args=(), pass_kwargs={}): def add_callback(self, timeout=None, repeat=True, check=None, pass_args=(), pass_kwargs={}):
def wrapper(func): def wrapper(func):
async def wrapped(): async def wrapped():
while True: while True:
try: try:
button_press = await self.wait_for(timeout=timeout) button_press = await self.wait_for(timeout=timeout, check=check)
except asyncio.TimeoutError: except asyncio.TimeoutError:
break break
asyncio.create_task(func(button_press, *pass_args, **pass_kwargs)) asyncio.create_task(func(button_press, *pass_args, **pass_kwargs))