Create a new Trello card every time someone sends a /suggest command
// authenticates you with the API standard library
// type `await lib.` to display API autocomplete
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let title = context.params.event.data.options[0].value;
let description = [
`**COMMUNITY SUGGESTION**`,
`${context.params.event.data.options[1].value}`,
``,
``,
`**Submitted by:** ${context.params.event.member.user.username}`
].join('\n');
try {
let trelloCard = await lib.trello.cards['@0.0.4'].create({
boardNameOrId: `${process.env.TRELLO_BOARD_NAME}`,
listNameOrId: `${process.env.TRELLO_LIST_NAME}`,
name: `${title}`,
desc: `${description}`,
});
await lib.discord.channels['@0.1.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `<@!${context.params.event.member.user.id}> suggestion sent! Thank you.`,
});
} catch (e) {
console.log(e);
await lib.discord.channels['@0.1.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `<@!${context.params.event.member.user.id}> failed to send suggestion. Try again.`,
});
}