From 0e8b3ce9e704f8cac2e4a31baee315db2fa311fd Mon Sep 17 00:00:00 2001 From: Choco Date: Sun, 24 Aug 2025 21:31:03 +0800 Subject: [PATCH] Improve message handling in send function Enhances the send function to handle different Discord message response types more robustly by normalizing the returned message object. This ensures compatibility with InteractionCallbackResponse, WebhookMessage, and InteractionMessage types. --- function.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/function.py b/function.py index d7b3010..b94a173 100644 --- a/function.py +++ b/function.py @@ -238,7 +238,15 @@ async def send( send_kwargs["view"] = view # Send the message or embed - return await send_func(**send_kwargs) + message = await send_func(**send_kwargs) + + if isinstance(message, discord.InteractionCallbackResponse): + message = message.resource + + if isinstance(message, (discord.WebhookMessage, discord.InteractionMessage)): + message = await message.fetch() + + return message async def update_db(db: AsyncIOMotorCollection, tempStore: dict, filter: dict, data: dict) -> bool: for mode, action in data.items():