diff --git a/src/execution.ts b/src/execution.ts index 9573796..fec4160 100644 --- a/src/execution.ts +++ b/src/execution.ts @@ -267,6 +267,7 @@ async function executeFromQueue(channel: string) { messages.forEach(m => { Moderation.checkMessageNoReturn(m); }); + const questionMessageId: string = message instanceof DiscordApi.Message ? message.id : ''; if (message instanceof DiscordApi.Message) { channelQueue.startTyping(); } @@ -274,7 +275,11 @@ async function executeFromQueue(channel: string) { await message.deferReply(); } - messages.sort((a, b) => b.createdTimestamp - a.createdTimestamp); + messages.sort((a, b) => { + if (a.id === questionMessageId) return -1; + if (b.id === questionMessageId) return 1; + return b.createdTimestamp - a.createdTimestamp; + }); OpenAImessages = toOpenAIMessages(messages.values()); let generatedMessage: ChatCompletionResponseMessage | undefined = undefined;