even less racy

master
Skye 2 years ago
parent 97b74ec81f
commit a2213e8321
Signed by: me
GPG Key ID: 0104BC05F41B77B8

@ -100,6 +100,8 @@ client.on("messageCreate", async (message) => {
msgs.set(nextMessage.id, nextMessage);
}
const lastMessage = nextMessage ?? message;
const context = [
...msgs
.filter((msg) => {
@ -135,17 +137,6 @@ client.on("messageCreate", async (message) => {
const responseMessage = response.data.choices[0].message;
if (!responseMessage) return;
const lastMessage =
msgs
.filter((msg) => {
if (msg.webhookId && !msg.content.startsWith("\\")) return true;
if (msg.author.bot && msg.author !== msg.author.client.user)
return false;
if (msg.content.startsWith("\\")) return false;
return true;
})
.first() ?? message;
const isAppropriate = await openai
.createModeration({ input: responseMessage.content })
.then(({ data }) => !data.results[0].flagged);

Loading…
Cancel
Save