This commit is contained in:
Skye 2023-03-10 22:12:02 +09:00
parent b572ed3111
commit 7adaebe7b5
Signed by: me
GPG key ID: 0104BC05F41B77B8

View file

@ -97,13 +97,22 @@ 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);
if (isAppropriate) {
try {
await message.reply({
await lastMessage.reply({
content: responseMessage.content,
allowedMentions: { parse: ["users"] },
});