From 0969e9065ae5420b3025b5284fbd693cd3cd3275 Mon Sep 17 00:00:00 2001 From: Atridad Lahiji <88056492+atridadl@users.noreply.github.com> Date: Fri, 14 Jul 2023 21:52:24 -0600 Subject: [PATCH] Better error for ask --- src/commands/ask.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/commands/ask.ts b/src/commands/ask.ts index 46ff6c5..f3ce29d 100644 --- a/src/commands/ask.ts +++ b/src/commands/ask.ts @@ -54,11 +54,23 @@ export class UserCommand extends Command { const content = blockQuote(`> ${prompt}\n${codeBlock(`${chatCompletion.data.choices[0].message?.content}`)}`); if (interactionOrMessage instanceof Message) { - return askMessage.edit({ content: content.length <= 2000 ? content : 'Sorry... AI no work good...' }); + return askMessage.edit({ + content: + content.length < 2000 + ? content + : `Oops! Discord only allows messages with 2000 characters or less. The prompt used ${ + prompt.length + } characters and the response took ${content.length - prompt.length}` + }); } return interactionOrMessage.editReply({ - content: content.length <= 2000 ? content : 'Sorry... AI no work good...' + content: + content.length < 2000 + ? content + : `Oops! Discord only allows messages with 2000 characters or less. The prompt used ${ + prompt.length + } characters and the response took ${content.length - prompt.length}` }); } }