diff --git a/src/moderation.ts b/src/moderation.ts index 293753e..a7ce63c 100644 --- a/src/moderation.ts +++ b/src/moderation.ts @@ -17,15 +17,21 @@ export default class Moderation { this.cache.set(message.id, true); return true; } + + try{ + const answer = await openai.createModeration({ + input: formatMessage(message), + }); - const answer = await openai.createModeration({ - input: formatMessage(message), - }); + const flagged = answer.data.results[0].flagged; + this.cache.set(message.id, flagged); + if (flagged) message.react("⚠"); - const flagged = answer.data.results[0].flagged; - this.cache.set(message.id, flagged); - if (flagged) message.react("⚠"); - - return flagged; + return flagged; + } + catch (e) { + console.log(e); + return false; + } } }