Transitioned all Misc, audio, Selmer Specific, admin, anime/manga, and inventory commands to Slash Command format. The RSS and reactionrole commands are still broken and all game commands are still in message format due to compications

This commit is contained in:
ION606
2022-09-27 16:45:50 -04:00
parent a190a250a6
commit e1002d748d
45 changed files with 1951 additions and 1058 deletions
+38 -28
View File
@@ -1,24 +1,27 @@
const { Constants } = require('discord.js');
const scraper = require('mal-scraper');
module.exports = {
name: 'asearch',
description: 'Selmer bot gives you info on an anime',
async execute(message, args, Discord, Client, bot) {
if (args.length < 1) { return message.reply("Please specify an anime!"); }
let name = "";
if (args.length > 1) {
let i = 0;
while (i < args.length && args[i] != '~fancy' && args[i] != '~summary' && args[i] != '~stats') {
name += args[i] + " ";
i++;
}
} else { name = args[0]; }
async execute(interaction, Discord, Client, bot) {
if (args[args.length - 1] != '~fancy' && args[args.length - 1] != '~summary' && args[args.length - 1] != '~stats') { args.push('~stats'); }
const args = interaction.options.data;
const name = args.filter((arg) => { return (arg.name == 'anime'); })[0].value;
var style;
if (args.length > 1) {
style = args.filter((arg) => { return (arg.name == 'style'); })[0].value;
}
else { style = "stats"; }
//Maybe change it to "this anime movie" if there is only 1 episode?
//When set to true, getInfoFromName.getBestMatch did not, in fact, return the best results
scraper.getInfoFromName(name, false).then((data) => {
try {
if (args[args.length - 1] == '~stats') {
try { console.log(data);
if (style == 'stats') {
const newEmbed = new Discord.MessageEmbed()
.setColor('#002eff')
.setTitle(data.title)
@@ -28,40 +31,47 @@ module.exports = {
.addFields(
{name: 'Genres:', value: data.genres.join(", ")},
{name: 'Score:', value: data.score},
{name: 'Episode:', value: data.episodes}
{name: 'Episode:', value: data.episodes},
{name: "Date Aired/Premiered", value: data.premiered || data.aired}
).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}`;
interaction.reply({ embeds: [newEmbed] });
} else if (style == 'fancy') {
let temp = `The ${data.genres.join(", ")} anime _${data.title}_ first aired on ${data.premiered || data.aired}`;
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!\n`;
temp += `You can see a trailer for ${data.title} here: ${data.trailer}`;
temp += `\n\n(to see a summary of the anime, use '${bot.prefix}asearch <anime name> ~summary')`;
temp += `You can see a trailer for ${data.title} ***[here](${data.trailer})***`;
// 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') {
interaction.reply({ embeds: [new Discord.MessageEmbed().setImage(data.picture).setDescription(temp)] });
// message.channel.send(temp);
} else if (style == 'summary') {
let temp = data.synopsis;
message.channel.send(temp);
interaction.reply(temp);
} else {
message.reply(`Unknown command, try using the format '${bot.prefix}asearch <anime name> [~stats or ~fancy or ~summary]`);
interaction.reply(`Unknown command, try using the format '/asearch <anime name> [stats or fancy or summary]`);
}
} catch (err) {
if (err.message.indexOf('MessageEmbed field values must be non-empty strings') != -1) {
message.reply(`Insufficient information on website!\nThe page can be found here: ${data.url}`);
interaction.reply(`Insufficient information on website!\nThe page can be found here: ${data.url}`);
} else {
message.reply("Uh oh, an unknown error occured, click the ✅ to report this!");
const m = interaction.reply("Uh oh, an unknown error occured, click the ✅ to report this!");
const { addComplaintButton } = require('../dev only/submitcomplaint');
addComplaintButton(bot, message);
m.then((msg) => {
addComplaintButton(bot, msg);
});
}
console.log(err);
}
});
}
},
options: [
{name: 'anime', description: 'The name of the anime', type: Constants.ApplicationCommandOptionTypes.STRING, required: true},
{name: 'style', description: 'stats or fancy or summary (defaults to stats)', type: Constants.ApplicationCommandOptionTypes.STRING, required: false, choices: [ { name: 'stats', value: 'stats' }, { name: 'fancy', value: 'fancy' }, {name: 'summary', value: 'summary'} ] }
]
}
+27 -24
View File
@@ -1,23 +1,21 @@
const { Constants } = require('discord.js');
const scraper = require('mal-scraper');
const search = scraper.search;
const type = "manga";
module.exports = {
name: 'msearch',
description: 'Selmer bot gives you info on a manga',
async execute(message, args, Discord, Client, bot) {
if (args.length < 1) { return message.reply("Please specify a manga!"); }
if (args[args.length - 1] != '~fancy' && args[args.length - 1] != '~summary' && args[args.length - 1] != '~stats') { args.push('~stats'); }
let name = "";
if (args.length > 1) {
let i = 0;
while (i < args.length && args[i] != '~fancy' && args[i] != '~summary' && args[i] != '~stats') {
name += args[i] + " ";
i++;
}
}
async execute(interaction, Discord, Client, bot) {
const args = interaction.options.data;
const name = args.filter((arg) => { return (arg.name == 'manga'); })[0].value;
var style;
let cmd = args[args.length - 1];
if (args.length > 1) {
style = args.filter((arg) => { return (arg.name == 'style'); })[0].value;
}
else { style = "stats"; }
try {
search.search(type, {
@@ -25,7 +23,7 @@ module.exports = {
term: name
}).then((data1) => {
let data = data1[0];
if (cmd == "~stats") {
if (style == "stats") {
const newEmbed = new Discord.MessageEmbed()
.setColor('#ff9900')
.setTitle(data.title)
@@ -38,32 +36,37 @@ module.exports = {
{name: 'Volumes:', value: data.vols}
);
message.channel.send({ embeds: [newEmbed] });
} else if (cmd == "~fancy") {
interaction.reply({ embeds: [newEmbed] });
} else if (style == "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") {
interaction.reply(temp);
} else if (style == "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);
return interaction.reply(temp);
} else {
message.reply(`Unknown command, try using the format '${bot.prefix}msearch <manga name> [~stats or ~fancy or ~summary]`);
interaction.reply(`Unknown command, try using the format '${bot.prefix}msearch <manga name> [stats or fancy or summary]`);
}
});
} catch (err) {
if (err.message.indexOf('MessageEmbed field values must be non-empty strings') != -1) {
message.reply(`Insufficient information on website!\nThe page can be found here: ${data.url}`);
interaction.reply(`Insufficient information on website!\nThe page can be found here: ${data.url}`);
} else {
message.reply("Uh oh, an unknown error occured, click the ✅ to report this!");
const m = interaction.reply("Uh oh, an unknown error occured, click the ✅ to report this!");
const { addComplaintButton } = require('../dev only/submitcomplaint');
addComplaintButton(bot, message);
m.then((msg) => {
addComplaintButton(bot, msg);
});
}
console.log(err);
}
}
},
options: [{name: 'manga', description: 'The name of the manga', type: Constants.ApplicationCommandOptionTypes.STRING, required: true}, {name: 'style', description: 'stats or fancy or summary (defaults to stats)', type: Constants.ApplicationCommandOptionTypes.STRING, required: false, choices: [ { name: 'stats', value: 'stats' }, { name: 'fancy', value: 'fancy' }, {name: 'summary', value: 'summary'} ] }]
}