When I realized there was no duck command snippet, I knew I had to add one. It randomly fetches a great duck image/gif and tells you the URL in case you want to keep it. It will also log the duck request somewhere in case they want to find the URL.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let duck = await lib.http.request['@1.1.6'].get({
url: `https://random-d.uk/api/v2/random`,
});
console.log(duck.data.url);
try {
console.log(`No error logged`);
await lib.discord.channels['@0.3.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `<@${
context.params.event.author.id
}> was feeling sad and wanted a duck. This duck was requested at `,
tts: false,
embeds: [
{
type: 'rich',
title: `Duck has been found`,
description: `I found a nice little duck right here`,
color: 0xffa600,
image: {
url: duck.data.url,
height: 0,
width: 0,
},
footer: {
text: `This duck's url is ${duck.data.url}. If you would like to see this duck again, make sure to save this url.`,
},
},
],
});
} catch (e) {
console.log(e);
await lib.discord.channels['@0.3.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: '',
tts: false,
embeds: [
{
type: 'rich',
title: `Whoopsies`,
description: `There was an error retrieving a duck. Make sure everything is in order.\n\nError: ${e}`,
color: 0xffa600,
footer: {
text: `Having trouble? Ping DuckFat#3207 in the Autocode Support Server.`,
},
},
],
});
return;
}
await lib.discord.channels['@0.3.1'].messages.create({
channel_id: `${process.env.DUCK_SAVES}`,
content: `<@${
context.params.event.author.id
}> has requested a duck and got one here: ${
duck.data.url
}. if you would like to save this duck, make sure you keep this URL somewhere safe. This duck was requested at .`,
});