🐛 fix(functionscalls.py): await the moderate function calls to properly handle asynchronous moderation checks

This commit is contained in:
2023-08-16 09:25:43 +02:00
parent 7c21934bc0
commit fa3eb3da0a

View File

@@ -342,11 +342,11 @@ async def call_function(message: discord.Message, function_call, api_key):
if name not in functions_matching: if name not in functions_matching:
raise FuntionCallError("Invalid function name") raise FuntionCallError("Invalid function name")
function = functions_matching[name] function = functions_matching[name]
if arguments.get("message", "") != "" and moderate( if arguments.get("message", "") != "" and await moderate(
api_key=api_key, text=arguments["message"] api_key=api_key, text=arguments["message"]
): ):
return "Message blocked by the moderation system. Please try again." return "Message blocked by the moderation system. Please try again."
if arguments.get("query", "") != "" and moderate( if arguments.get("query", "") != "" and await moderate(
api_key=api_key, text=arguments["query"] api_key=api_key, text=arguments["query"]
): ):
return "Query blocked by the moderation system. If the user asked for something edgy, please tell them in a funny way that you won't do it, but do not specify that it was blocked by the moderation system." return "Query blocked by the moderation system. If the user asked for something edgy, please tell them in a funny way that you won't do it, but do not specify that it was blocked by the moderation system."