This bot summarizes upto last 100 messages in a channel so you don't need to read all of them!
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let messageCount = parseInt(context.params.event.content.split(' ')[1]);
if (!messageCount || messageCount < 1 || messageCount > 100) {
return await lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `You must provide a number between 1 and 100 for the number of messages to archive.`,
});
}
let messages = await lib.discord.channels['@0.2.0'].messages.list({
channel_id: `${context.params.event.channel_id}`,
limit: messageCount,
});
let msgs = messages
.reverse()
.map((message) => {
let displayText = [`${message.author.username}: ${message.content}`];
return displayText.join('\n');
})
.join('\n');
let result = await lib.openai.playground['@0.0.4'].completions.create({
model: `text-davinci-003`,
prompt: [
`Convert my short hand into a first-hand account of the conversation:\n${msgs}`,
],
max_tokens: 1000,
top_p: 1,
best_of: 1,
});
await lib.discord.channels['@0.3.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: '',
tts: false,
embeds: [
{
type: 'rich',
title: `Here is the Summary of last ${messageCount} messages`,
description: result.choices[0].text,
color: 0x00ffff,
},
],
});