Skip to content

Commit

Permalink
add truth or dare
Browse files Browse the repository at this point in the history
  • Loading branch information
thoriqazzikraa committed Sep 15, 2023
1 parent e392f5c commit 947ed23
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const scrape = require("scrape-websitee")
otakuDesuSearch, // (query)
},
random: {
truthOrDare, // (language) default: "id", or you can find support languages in here https://psycatgames.com/app/truth-or-dare/
getCerpen,
getCerpenHorror,
},
Expand Down
47 changes: 47 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,52 @@ const pickRandom = async (ext) => {
return ext[Math.floor(Math.random() * ext.length)];
};

async function truthOrDare(language) {
const lang = language ? language : "id";
try {
const dareFunc = async () => {
const { data } = await axios(`https://psycatgames.com/api/tod-v2/`, {
method: "post",
data: {
id: "truth-or-dare",
language: lang,
category: "mixed",
type: "dare",
},
headers: {
Referer: "https://psycatgames.com",
},
});
const randomResult = Math.floor(Math.random() * data.results.length);
return data.results[randomResult];
};
const dare = await dareFunc(lang);
const { data } = await axios(`https://psycatgames.com/api/tod-v2/`, {
method: "post",
data: {
id: "truth-or-dare",
language: lang,
category: "mixed",
type: "truth",
},
headers: {
Referer: "https://psycatgames.com",
},
});
const randomResult = Math.floor(Math.random() * data.results.length);
const result = {
status: true,
dare: dare,
truth: data.results[randomResult],
};
return result;
} catch (err) {
console.log(err);
const res = { status: false, message: "Unknown error occurred." };
return res;
}
}

async function similarSongs(songs) {
try {
const getFirstSong = async () => {
Expand Down Expand Up @@ -828,6 +874,7 @@ module.exports = {
otakuDesuSearch,
},
random: {
truthOrDare,
getCerpen,
getCerpenHorror,
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scrape-websitee",
"version": "1.0.35",
"version": "1.0.36",
"description": "Website Scraping",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 947ed23

Please sign in to comment.