Remove GPTie: pre-prompt for /g, show the prompt after /g is run

Kaveen Kumarasinghe 1 year ago
parent d0487926da
commit 3b1f8424f3

@ -61,6 +61,10 @@ Both the OpenAI API key and the Discord bot token needed to be loaded into a .en
You also need to add a DEBUG_GUILD id and a DEBUG_CHANNEL id, the debug guild id is a server id, and the debug channel id is a text-channel id in Discord. Your final .env file should look like the following:
You also need to add the allowed guilds that the bot can operate on, this is the `ALLOWED_GUILDS` field, to get a guild ID, right click a server and click "Copy ID".
You also need to add the roles that can use the bot, this is the `ALLOWED_ROLES` field, enter role names here, separated by commas. Currently, there is no way to give everybody access to the bot, and you have to use roles, but it will be done soon.
```
OPENAI_TOKEN="<openai_api_token>"
DISCORD_TOKEN="<discord_bot_token>"

@ -502,7 +502,8 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
async def encapsulated_send(
self, user_id, prompt, ctx, response_message=None, from_g_command=False
):
new_prompt = prompt + "\nGPTie: "
new_prompt = prompt + "\nGPTie: " if not from_g_command else prompt
from_context = isinstance(ctx, discord.ApplicationContext)
try:
@ -556,6 +557,11 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
response_text = response_text.replace("GPTie: ", "")
response_text = response_text.replace("<|endofstatement|>", "")
if from_g_command:
# Append the prompt to the beginning of the response, in italics, then a new line
response_text = response_text.strip()
response_text = f"***{prompt}***\n\n{response_text}"
# If GPT3 tries to ping somebody, don't let it happen
if re.search(r"<@!?\d+>|<@&\d+>|<#\d+>", str(response_text)):
message = "I'm sorry, I can't mention users, roles, or channels."

Loading…
Cancel
Save