diff --git a/src/ChatProcess.py b/src/ChatProcess.py index 5aeafcb..e3ac3d8 100644 --- a/src/ChatProcess.py +++ b/src/ChatProcess.py @@ -189,8 +189,17 @@ class Chat: return if await self.postExitCriteria(): return - await self.message.channel.trigger_typing() - await self.formatContext() - await self.createThePrompt() - await self.getResponse() - await self.processResponse() + try: + await self.message.channel.trigger_typing() + await self.formatContext() + await self.createThePrompt() + await self.getResponse() + await self.processResponse() + except Exception as e: + await self.message.channel.send( + f"""An error occured while processing your message. Please check your settings and try again. If the issue persists, please join uor discord server here: https://discord.gg/pB6hXtUeDv and send the following logs: +``` +{e} +```""" + ) + raise e diff --git a/src/cogs/channelSetup.py b/src/cogs/channelSetup.py index 9080694..05b10f4 100644 --- a/src/cogs/channelSetup.py +++ b/src/cogs/channelSetup.py @@ -233,7 +233,9 @@ class ChannelSetup(commands.Cog): await ctx.respond(f"Set API key for {api} to `secret`.", ephemeral=True) @setup.command(name="premium", description="Set the guild to premium.") - async def premium(self, ctx: discord.ApplicationContext, guild_id: str = None, days: int = 180): + async def premium( + self, ctx: discord.ApplicationContext, guild_id: str = None, days: int = 180 + ): guild = Guild(guild_id or str(ctx.guild.id)) guild.load() if await self.bot.is_owner(ctx.author): diff --git a/src/makeprompt.py b/src/makeprompt.py index 149f34c..3ca24bd 100644 --- a/src/makeprompt.py +++ b/src/makeprompt.py @@ -43,9 +43,9 @@ async def fetch_messages_history(channel: discord.TextChannel, limit, original_m async for msg in channel.history(limit=100, before=original_message): if not is_ignorable(msg.content): messages.append(msg) - if len(messages) == limit-1: + if len(messages) == limit - 1: break - + messages.append(original_message) messages.reverse() return messages diff --git a/src/utils/openaicaller.py b/src/utils/openaicaller.py index 416fdb0..11fd9cb 100644 --- a/src/utils/openaicaller.py +++ b/src/utils/openaicaller.py @@ -92,11 +92,11 @@ class openai_caller: error_call = nothing if error_call == None: - - async def nothing(x): - return x - - error_call = nothing + + async def nothing(x): + return x + + error_call = nothing if kwargs.get("model", "") in chat_models: return await self.chat_generate(error_call, **kwargs) elif kwargs.get("engine", "") in text_models: