So, i have the following code:
var jobs = [
'lawyer',
'hitman',
'gardener',
'cashier'
]
var thumbnails = [
"https://c.tenor.com/DP615vqUzeAAAAAC/ace-attorney-phoenix-wright.gif",
"https://i.ytimg.com/vi/6nzyIHz5bb0/hqdefault.jpg",
"https://c.tenor.com/vzSw7IoYMdYAAAAM/lifehack-hose.gif",
"https://c.tenor.com/eYUWlNN0Fw4AAAAM/thisisalecx-cashier.gif"
]
let job = jobs[Math.floor(Math.random() * jobs.length)]
This chooses a random option out of the "jobs" array. And i have the list with the embed thumbnails i want to use. Now if it sends a random job from the array, is there a way to send one of the gifs that is matching this job? Any help is appreciated!
CodePudding user response:
Use this:
var jobs = [
'lawyer',
'hitman',
'gardener',
'cashier'
]
var thumbnails = [
"https://c.tenor.com/DP615vqUzeAAAAAC/ace-attorney-phoenix-wright.gif",
"https://i.ytimg.com/vi/6nzyIHz5bb0/hqdefault.jpg",
"https://c.tenor.com/vzSw7IoYMdYAAAAM/lifehack-hose.gif",
"https://c.tenor.com/eYUWlNN0Fw4AAAAM/thisisalecx-cashier.gif"
]
let index = Math.floor(Math.random() * jobs.length)
let job = jobs[index]
let image = thumbnails[index]