Merge pull request #61 from Kav-K/gpt-end

Gpt end
Kaveen Kumarasinghe 2 years ago committed by GitHub
commit a82acbec11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -58,7 +58,7 @@ These commands are grouped, so each group has a prefix but you can easily tab co
- Note that the above options for `/gpt converse` can be combined (you can combine minimal, private, and opener!) - Note that the above options for `/gpt converse` can be combined (you can combine minimal, private, and opener!)
`/gpt end-chat` - End a conversation with the bot. `/gpt end` - End a conversation with the bot.
`/dalle draw <prompt>` - Have DALL-E generate images based on a prompt `/dalle draw <prompt>` - Have DALL-E generate images based on a prompt

@ -227,9 +227,12 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"):
normalized_user_id = opener_user_id if opener_user_id else message.author.id normalized_user_id = opener_user_id if opener_user_id else message.author.id
self.conversating_users.pop(normalized_user_id) self.conversating_users.pop(normalized_user_id)
await message.reply( if isinstance(message, discord.ApplicationContext):
"You have ended the conversation with GPT3. Start a conversation with !g converse" await message.respond("Your conversation has ended!", ephemeral=True, delete_after=10)
) else:
await message.reply(
"You have ended the conversation with GPT3. Start a conversation with /gpt converse"
)
# Close all conversation threads for the user # Close all conversation threads for the user
channel = self.bot.get_channel(self.conversation_threads[normalized_user_id]) channel = self.bot.get_channel(self.conversation_threads[normalized_user_id])
@ -260,7 +263,7 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"):
name="/gpt converse", value="Start a conversation with GPT3", inline=False name="/gpt converse", value="Start a conversation with GPT3", inline=False
) )
embed.add_field( embed.add_field(
name="/gpt end-chat", name="/gpt end",
value="End a conversation with GPT3. You can also type `end` in the conversation.", value="End a conversation with GPT3. You can also type `end` in the conversation.",
inline=False, inline=False,
) )
@ -701,6 +704,8 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"):
await ctx.send_followup(e) await ctx.send_followup(e)
else: else:
await ctx.reply(e) await ctx.reply(e)
if ctx.user.id in self.awaiting_responses:
self.awaiting_responses.remove(ctx.user.id)
# General catch case for everything # General catch case for everything
except Exception: except Exception:
@ -850,16 +855,23 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"):
@add_to_group("gpt") @add_to_group("gpt")
@discord.slash_command( @discord.slash_command(
name="end-chat", name="end",
description="End a conversation with GPT3", description="End a conversation with GPT3",
guild_ids=ALLOWED_GUILDS, guild_ids=ALLOWED_GUILDS,
) )
@discord.guild_only() @discord.guild_only()
async def end_chat(self, ctx: discord.ApplicationContext): async def end_chat(self, ctx: discord.ApplicationContext):
await ctx.defer() await ctx.defer(ephemeral=True)
await ctx.respond( user_id = ctx.user.id
"This has not been implemented yet. Please type `end` in your conversation thread to end the chat." if user_id in self.conversating_users:
) try:
await self.end_conversation(ctx)
except Exception as e:
print(e)
traceback.print_exc()
pass
else:
await ctx.respond("You're not in any conversations", ephemeral=True, delete_after=10)
@discord.slash_command( @discord.slash_command(
name="help", description="Get help for GPT3Discord", guild_ids=ALLOWED_GUILDS name="help", description="Get help for GPT3Discord", guild_ids=ALLOWED_GUILDS

Loading…
Cancel
Save