This is for the games hug pat pass and rate the food. Just set your channel ids and it will run daily automatically, unless there is an error, in which case you can just change it from scheduler to https command and run it.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let newArray = ['cat', 'dog', 'panda', 'redpanda', 'fox', 'bird', 'koala'];
let pick = Math.floor(Math.random() * newArray.length);
let animal_ = newArray[pick];
let data = await lib.http.request['@1.1.7']({
method: 'GET',
url: `https://some-random-api.ml/img/${animal_}`,
});
let image = JSON.parse(data.body.toString());
let hppChannel = `YOUR CHANNEL ID HERE`; //put your hug pat pass channel ID here
let rtfChannel = `YOUR CHANNEL ID HERE`; //put your rate the food channel ID here
console.log(image.link);
let animal_message = await lib.discord.channels['@0.3.0'].messages.create({
content: `Would you hug, pat, or pass by this animal?`,
channel_id: `${hppChannel}`,
embeds: [
{
type: 'rich',
title: '',
description: '',
color: 0x00ffff,
image: {
url: image.link,
height: 0,
width: 0,
},
},
],
});
await lib.discord.channels['@0.1.2'].messages.reactions.create({
emoji: `๐ค`,
message_id: animal_message.id,
channel_id: `${hppChannel}`,
});
await lib.discord.channels['@0.1.2'].messages.reactions.create({
emoji: `๐`,
message_id: animal_message.id,
channel_id: `${hppChannel}`,
});
await lib.discord.channels['@0.1.2'].messages.reactions.create({
emoji: `๐ถ`,
message_id: animal_message.id,
channel_id: `${hppChannel}`,
});
// Food messages
res = await lib.http.request['@1.1.6']({
method: 'POST',
url: `https://www.themealdb.com/api/json/v1/1/random.php`,
statusCode: 200,
headers: {
'Content-Type': 'application/json',
},
});
let food = JSON.parse(res.body.toString());
let image_link = food.meals[0].strMealThumb;
let food_message = await lib.discord.channels['@0.3.0'].messages.create({
content: `Rate this dish on a scale from one to five!`,
channel_id: `${rtfChannel}`,
embeds: [
{
type: 'rich',
title: '',
description: '',
color: 0x00ffff,
image: {
url: image_link,
height: 0,
width: 0,
},
},
],
});
await lib.discord.channels['@0.1.2'].messages.reactions.create({
emoji: `1๏ธโฃ`,
message_id: food_message.id,
channel_id: `${rtfChannel}`,
});
await lib.discord.channels['@0.1.2'].messages.reactions.create({
emoji: `2๏ธโฃ`,
message_id: food_message.id,
channel_id: `${rtfChannel}`,
});
await lib.discord.channels['@0.1.2'].messages.reactions.create({
emoji: `3๏ธโฃ`,
message_id: food_message.id,
channel_id: `${rtfChannel}`,
});
await lib.discord.channels['@0.1.2'].messages.reactions.create({
emoji: `4๏ธโฃ`,
message_id: food_message.id,
channel_id: `${rtfChannel}`,
});
await lib.discord.channels['@0.1.2'].messages.reactions.create({
emoji: `5๏ธโฃ`,
message_id: food_message.id,
channel_id: `${rtfChannel}`,
});