diff --git a/src/functionscalls.py b/src/functionscalls.py index bb25c53..aefa360 100644 --- a/src/functionscalls.py +++ b/src/functionscalls.py @@ -316,13 +316,14 @@ async def send_ascii_art_image( async def evaluate_math( - message_in_channel_in_wich_to_send: discord.Message, arguments: dict + message_in_channel_in_wich_to_send: discord.Message, arguments: dict, timeout=10 ): evaluable = arguments.get("string", "") if evaluable == "": raise FuntionCallError("No string provided") + loop = asyncio.get_event_loop() try: - result = simple_eval(evaluable) + result = await asyncio.wait_for(loop.run_in_executor(None, simple_eval, evaluable), timeout=timeout) except Exception as e: result = f"Error: {e}" return f"Result to math eval of {evaluable}: ```\n{str(result)}```"