This Snippet Returns The Link Of Zoro.to Anime Website And The Top Result!
// For Slash Command Structure See This Image - https://media.discordapp.net/attachments/928234875503398962/1012378144923189309/20220825_200819.jpg
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const axios = require('axios');
let search = context.params.event.data.options[0].value;
// You Can Make This Prefix Command Replace The Above Code With Below Code!
// let search = context.params.event.content.split(' ').slice(1).join(' ');
let parsedkeyword = search.replace(/ /g, '%20');
let link = `https://anime.unfettered.codes/api/anime/search?keyword=${parsedkeyword}`;
// Note This API Don't Returns The Link So The Above Code Is Important!
let url = `http://anime.unfettered.codes/api/anime/search?name=${search}`;
// Looking To API? Visit Page At https://www.zoroapi.ml/endpoints
let response = await axios.get(url);
console.log(response.data);
let anime = response.data?.results.length > 0 ? response.data.results[0] : null;
if (anime == null) {
return lib.discord.channels['@0.3.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `No Anime Found!`,
});
}
// Now Building Embed!
await lib.discord.channels['@0.1.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: '',
embeds: [
{
type: 'rich',
title: ``,
description: '',
color: 0x41d43c,
author: {
name: `Anime Search Query On Zoro.to`,
icon_url: `https://media.discordapp.net/attachments/928234875503398962/1011639174564163674/apple-touch-icon.png`,
},
fields: [
{
name: `You Searched For: ||${search}||`,
value: `Link- [Click here](${link})`,
},
{
name: 'Name',
value: `${anime.name}`,
inline: true,
},
{
name: `Episodes:`,
value: `${anime.episodes}`,
inline: false,
},
{
name: 'Time',
value: `${anime.duration}`,
inline: false,
},
{
name: 'Type',
value: `${anime.type}`,
inline: false,
},
{
name: 'Languages',
value: `${anime.languages}`,
inline: false,
},
],
footer: {
text: `Asked By ${context.params.event.member.user.username}`,
},
timestamp: `${new Date().toISOString()}`,
},
],
});
// Btw fidilen#1432 Helped Me In This Project!