This snippet is a fun command which uses api that gives result based on stored data. Usage: !gage <your first name>
/* Import Modules */
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const axios = require('axios');
/* extract content from event and split it then slice its 1st value so that */
/* we get main content without command name */
const content = context.params.event.content.split(' ').slice(1);
/* Send request to API */
const age = await axios(`https://api.agify.io/?name=${content[0]}`).then(
(res) => res.data.age
);
return lib.discord.channels['@0.3.0'].messages.create({
content: `I am guessing ${content[0]} age is ${age}?`,
channel_id: context.params.event.channel_id,
});