From f30c9f07e3bb1db76d384dabc552f58057d27ab4 Mon Sep 17 00:00:00 2001 From: Karl <58265182+KarlKennerley@users.noreply.github.com> Date: Sun, 1 Jan 2023 21:46:21 +0000 Subject: [PATCH] Changed welcome message to query GPT3 for new msg Welcome messages are now generated by GPT3 or default to one stored in env variable if GPT3 in unavailable. --- cogs/gpt_3_commands_and_converser.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cogs/gpt_3_commands_and_converser.py b/cogs/gpt_3_commands_and_converser.py index 2620a85..600e9a2 100644 --- a/cogs/gpt_3_commands_and_converser.py +++ b/cogs/gpt_3_commands_and_converser.py @@ -16,7 +16,6 @@ from collections import defaultdict original_message = {} ALLOWED_GUILDS = EnvService.get_allowed_guilds() -WELCOME_MESSAGE = EnvService.get_welcome_message() class GPT3ComCon(commands.Cog, name="GPT3ComCon"): @@ -92,9 +91,14 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"): @commands.Cog.listener() async def on_member_join(self, member): - welcome_embed = discord.Embed(title=f"Welcome, {member.name}!", description=WELCOME_MESSAGE) - welcome_embed.add_field(name="Just so you know...", value="> My commands are invoked with a forward slash ("/")\n> Use /help to see my help messages.") - await member.send(content=None, embed=welcome_embded) + if self.welcome_message_enabled(): + query = f"Please generate a welcome message for {member.name} who has just joined the server." + welcome_message = self.send_request(query, tokens=self.usage_service.count_tokens(query)) + if not welcome_message: + welcome_message = EnvService.get_welcome_message() + welcome_embed = discord.Embed(title=f"Welcome, {member.name}!", description=welcome_message) + welcome_embed.add_field(name="Just so you know...", value="> My commands are invoked with a forward slash ("/")\n> Use /help to see my help message(s).") + await member.send(content=None, embed=welcome_embded) @commands.Cog.listener() async def on_member_remove(self, member):