Finished implementing the 'msearch' command

This commit is contained in:
ION606
2022-05-20 10:39:34 +03:00
parent 55c37f339f
commit 8a1246edac
2 changed files with 30 additions and 5 deletions
+1 -2
View File
@@ -14,7 +14,6 @@ module.exports = {
} }
scraper.getInfoFromName(name).then((data) => { scraper.getInfoFromName(name).then((data) => {
//If the user didn't specify, give a stat list
if (args[args.length - 1] == '~stats') { if (args[args.length - 1] == '~stats') {
const newEmbed = new Discord.MessageEmbed() const newEmbed = new Discord.MessageEmbed()
.setColor('#002eff') .setColor('#002eff')
@@ -30,7 +29,7 @@ module.exports = {
message.channel.send({ embeds: [newEmbed] }); message.channel.send({ embeds: [newEmbed] });
} else if (args[args.length - 1] == '~fancy') { } else if (args[args.length - 1] == '~fancy') {
let temp = `The ${data.genres.join(", ")} anime "${data.title}" first aired on ${data.premiered}`; let temp = `The ${data.genres.join(", ")} anime _${data.title}_ first aired on ${data.premiered}`;
if (data.aired) { temp += `. This anime ran for ${data.aired} for a total of ${data.episodes} episodes.`} if (data.aired) { temp += `. This anime ran for ${data.aired} for a total of ${data.episodes} episodes.`}
else { temp += ` and is still airing with ${data.episodes} so far!`} else { temp += ` and is still airing with ${data.episodes} so far!`}
+29 -3
View File
@@ -15,12 +15,38 @@ module.exports = {
} }
} }
let cmd = args[args.length - 1];
search.search(type, { search.search(type, {
maxResults: 1, maxResults: 1,
term: name term: name
}).then((data) => { }).then((data1) => {
console.log(data[0]); let data = data1[0];
message.reply("This command has not been implemented yet!"); if (cmd == "~stats") {
const newEmbed = new Discord.MessageEmbed()
.setColor('#ff9900')
.setTitle(data.title)
.setURL(data.url)
.setImage(data.thumbnail)
//.setDescription('My professional resume')
.addFields(
{name: 'Type:', value: data.type},
{name: 'Score:', value: data.score},
{name: 'Volumes:', value: data.vols}
);
message.channel.send({ embeds: [newEmbed] });
} else if (cmd == "~fancy") {
let temp = `The ${data.type} _${data.title}_ currently has ${data.vols} volumes with ${data.nbChapters} chapters, `;
temp += `running from _${data.startDate.replace(/-/g, "/")}_ to _${data.endDate.replace(/-/g, "/")}_, and has a score of ${data.score} on MyAnimeList!\n`;
temp += `You can read more about _${data.title}_ at ${data.url}`;
message.channel.send(temp);
} else if (cmd == "~summary") {
//Remove the "read more." at the end
let temp = data.shortDescription.slice(0, -10);
temp += ` _read more at_ ${data.url}`;
return message.channel.send(temp);
}
}); });
} }
} }