A Dad-joke command that has a customizable database set up. You will need to set up a slash command. Simply make a copy of my sheet and link it. https://docs.google.com/spreadsheets/d/1Di6fOatf9S3ermdN3lO4FVTUPURfGdccWifxSgILiC4/edit?usp=sharing Thanks to the community heroes and contributers helping me with this, it'd be impossible to learn without a helping hand.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let result= await lib.googlesheets.query['@0.3.0'].select({
range: `Sheet1!A:B`,
bounds: 'FIRST_EMPTY_ROW',
where: [{}],
limit: {
'count': 0,
'offset': 0
}
});
let dadjokes = result.rows.map((row) => {
return row.fields.Dadjokes
})
let random = Math.floor(Math.random() * dadjokes.length);
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: '',
embeds: [
{
type: 'rich',
title: 'Dad Joke!',
description: `${dadjokes[random]}`,
color: 015479 //<-- This is Dark Blue but you can change it to any color you want.
}
]
});
// for the google-sheets DO NOT change the name of the Dadjokes column.