Sends jacob's face into a Discord channel and then uses utils.kv to count how many times it has been sent
// authenticates you with the API standard library
// type `await lib.` to display API autocomplete
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
// Set the URL of Jacob's face.
let jacobImage = 'https://i.imgur.com/QJgkfKC.jpg';
// Grab the amount of times his face has been sent so far from KV
let face_counter = await lib.utils.kv['@0.1.16'].get({
key: `jacob_face_counter`,
defaultValue: `0`,
});
// Increment the count by 1
await lib.utils.kv['@0.1.16'].set({
key: `jacob_face_counter`,
value: face_counter + 1,
});
// Send Jacob's face to the channel. You know, the entire point of this.
return await lib.discord.channels['@0.2.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `Jacob says hi to <@${
context.params.event.author.id
}>! Jacob's face has been sent ${
face_counter + 1
} times so far! 🎉 ${jacobImage}`,
tts: true,
});