Added the 'asearch' command and changed the prefix because it works better with discord desktop

This commit is contained in:
ION606
2022-05-18 21:34:58 +03:00
parent a69d50ce9f
commit ae07f645fa
2 changed files with 47 additions and 12 deletions
+44 -11
View File
@@ -1,18 +1,51 @@
const scraper = require('mal-scraper'); const scraper = require('mal-scraper');
module.exports = { module.exports = {
name: 'search', name: 'asearch',
description: 'Selmer bot gives you either an explanation or a list of stats', description: 'Selmer bot gives you either an explanation or a list of stats',
async execute() { async execute(message, args, Discord, Client, bot) {
scraper.getInfoFromName('Fullmetal Alchemist').then((data) => { if (args.length < 1) { return message.reply("Please specify an anime!"); }
//If the user didn't specify, give a stat list let name = "";
if (args.length < 1) { if (args.length > 1) {
let s = `Title: ${s.title}\n`; let i = 0;
s += `` while (i < args.length && args[i] != '~fancy' && args[i] != '~summary' && args[i] != '~stats') {
} else if (args[0] != 'full') { name += args[i] + " ";
i++;
} else {
} }
}
scraper.getInfoFromName(name).then((data) => {
//If the user didn't specify, give a stat list
if (args[args.length - 1] == 'stats') {
const newEmbed = new Discord.MessageEmbed()
.setColor('#002eff')
.setTitle(data.title)
//.setURL('https://discordjs.guide/popular-topics/embeds.html#embed-preview')
//.setDescription('My professional resume')
.setImage(data.picture)
.addFields(
{name: 'Genres:', value: data.genres.join(", ")},
{name: 'Score:', value: data.score},
{name: 'Episode:', value: data.episodes}
).setURL(data.trailer);
message.channel.send({ embeds: [newEmbed] });
} else if (args[args.length - 1] == '~fancy') {
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.`}
else { temp += ` and is still airing with ${data.episodes} so far!`}
temp += ` This anime has a score of ${data.score} and is ${data.popularity} on MyAnimeList!`;
temp += `\n\n(to see a summary of the anime, use '${bot.prefix}asearch <anime name> ~summary')`;
message.channel.send({ embeds: [new Discord.MessageEmbed().setImage(data.picture)]});
message.channel.send(temp);
} else if (args[args.length - 1] == '~summary') {
let temp = data.synopsis;
message.channel.send(temp);
} else {
message.reply(`Unknown command, try using the format '${bot.prefix}asearch <anime name> [~stats or ~fancy or ~summary]`);
}
}); });
} }
} }
+3 -1
View File
@@ -19,7 +19,9 @@ const bot = new Client({
], ],
}); });
const prefix = '/'; const prefix = '!';
bot.prefix = new String;
bot.prefix = prefix;
//MongoDB integration //MongoDB integration