Fix overflow of the reply of 2000 character
now it will send more than one message if it gets overflown fixes #6
This commit is contained in:
parent
a0cad7a348
commit
c7b36885a3
1 changed files with 17 additions and 2 deletions
|
@ -110,6 +110,8 @@ function requestReply(
|
||||||
else {
|
else {
|
||||||
if (!request.deferred)
|
if (!request.deferred)
|
||||||
return request.reply(Object.assign(message, interactionOptions));
|
return request.reply(Object.assign(message, interactionOptions));
|
||||||
|
else if (request.replied)
|
||||||
|
return request.followUp(Object.assign(message, interactionOptions));
|
||||||
else
|
else
|
||||||
return request.editReply(Object.assign(message, interactionOptions));
|
return request.editReply(Object.assign(message, interactionOptions));
|
||||||
}
|
}
|
||||||
|
@ -277,9 +279,22 @@ async function executeFromQueue(channel: string) {
|
||||||
if (message instanceof DiscordApi.Message) message.react("😶").catch(/*it's okay*/);
|
if (message instanceof DiscordApi.Message) message.react("😶").catch(/*it's okay*/);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const response = requestReply(message, {content: answerContent}, {allowedMentions: { repliedUser: false }});
|
const answerMessagesContent :string[] = [""];
|
||||||
|
for (const i in answerContent.split(/\n\n/)) {
|
||||||
|
if (answerMessagesContent[answerMessagesContent.length-1].length + i.length < 2000) {
|
||||||
|
answerMessagesContent[answerMessagesContent.length-1] += "\n\n" + i;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
answerMessagesContent.push(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
response.then(rval => Moderation.checkMessage(rval));
|
for (const i in answerMessagesContent) {
|
||||||
|
const response = requestReply(message, {content: i}, {allowedMentions: { repliedUser: false }});
|
||||||
|
|
||||||
|
response.then(rval => Moderation.checkMessage(rval));
|
||||||
|
await response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`Error ocurred while handling chat completion request (${(e as object).constructor.name}):`);
|
console.error(`Error ocurred while handling chat completion request (${(e as object).constructor.name}):`);
|
||||||
|
|
Loading…
Reference in a new issue