This autocorrects your message if it has any major mistakes, ignores it if it has minor mistakes
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
try {
let completion = await lib.openai.playground['@0.0.2'].completions.create({
model: `text-davinci-003`,
prompt: [
`Correct this to standard English: ${context.params.event.content}. Ignore if it contains minor mistakes`,
],
max_tokens: 1000,
temperature: 0,
top_p: 1.0,
frequency_penalty: 0.0,
presence_penalty: 0.0,
});
let response_edited = completion.choices[0].text
.toLowerCase()
.replace(/[^a-zA-Z ]/g, '')
.replace(/\s/g, '');
let txt_edited = context.params.event.content
.toLowerCase()
.replace(/[^a-zA-Z ]/g, '')
.replace(/\s/g, '');
if (response_edited == txt_edited) {
return;
}
await lib.discord.channels['@0.3.1'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `${completion.choices[0].text}`,
message_reference: {
message_id: context.params.event.id,
channel_id: context.params.event.channel_id,
guild_id: context.params.event.guild_id,
},
});
} catch (e) {}