Skip to content

Commit

Permalink
[Update] updated all commands in the anime category as planned in #2
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Oct 5, 2021
1 parent 9df75a7 commit e95687c
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 4 deletions.
26 changes: 25 additions & 1 deletion commands/Anime/highfive.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,33 @@ const { SlashCommandBuilder } = require("@discordjs/builders");
const { requestAPI } = require("../../modules/requestAPI");

module.exports = {
name: "highfive",
aliases: ["hf"],
description: "Sends a highfive gif",
usage: "hf || highfive",
async run(message, args, client) {
try {
const highFive = await requestAPI("https://api.waifu.pics/sfw/highfive");
const highFiveEmbed = {
color: "#9dcc37",
image: {
url: `${highFive.url}`,
},
timestamp: new Date(),
footer: {
text: `Requested by ${message.member.user.username}`,
icon_url: `${message.member.user.avatarURL()}`,
},
};
await message.channel.send({ embeds: [highFiveEmbed] });
} catch (error) {
client.logger(error.message, "error");
await message.channel.send(`Couldn't retrieve a hug gif, Sorry!`);
}
},
data: new SlashCommandBuilder()
.setName("highfive")
.setDescription("sends a highfive gif"),
.setDescription("Sends a highfive gif"),
async execute(interaction, client) {
await interaction.deferReply();
try {
Expand Down
26 changes: 25 additions & 1 deletion commands/Anime/hug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,33 @@ const { SlashCommandBuilder } = require("@discordjs/builders");
const { requestAPI } = require("../../modules/requestAPI");

module.exports = {
name: "hug",
args: false,
description: "Sends a hug gif",
usage: "hug",
async run(message, args, client) {
try {
const hug = await requestAPI("https://api.waifu.pics/sfw/hug");
const hugEmbed = {
color: "#9dcc37",
image: {
url: `${hug.url}`,
},
timestamp: new Date(),
footer: {
text: `Requested by ${message.member.user.username}`,
icon_url: `${message.member.user.avatarURL()}`,
},
};
await message.channel.send({ embeds: [hugEmbed] });
} catch (error) {
client.logger(error.message, "error");
await message.channel.send(`Couldn't retrieve a hug gif, Sorry!`);
}
},
data: new SlashCommandBuilder()
.setName("hug")
.setDescription("sends a hug gif"),
.setDescription("Sends a hug gif"),
async execute(interaction, client) {
await interaction.deferReply();
try {
Expand Down
26 changes: 25 additions & 1 deletion commands/Anime/waifu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,33 @@ const { SlashCommandBuilder } = require("@discordjs/builders");
const { requestAPI } = require("../../modules/requestAPI");

module.exports = {
name: "waifu",
args: false,
description: "Gets a waifu pic :P",
usage: "waifu",
async run(message, args, client) {
try {
const waifu = await requestAPI("https://api.waifu.pics/sfw/waifu");
const waifuEmbed = {
color: "#9dcc37",
image: {
url: `${waifu.url}`,
},
timestamp: new Date(),
footer: {
text: `Requested by ${message.member.user.username}`,
icon_url: `${message.member.user.avatarURL()}`,
},
};
await message.channel.send({ embeds: [waifuEmbed] });
} catch (error) {
client.logger(error.message, "error");
await message.channel.send(`Couldn't retrieve a waifu pic, Sorry!`);
}
},
data: new SlashCommandBuilder()
.setName("waifu")
.setDescription("gets waifu pic :P"),
.setDescription("Gets a waifu pic :P"),
async execute(interaction, client) {
await interaction.deferReply();
try {
Expand Down
52 changes: 51 additions & 1 deletion commands/Anime/whatAnime.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,60 @@
const { SlashCommandBuilder } = require("@discordjs/builders");
const { embedMessage } = require("../../modules/embedSimple");
const { getAnimeByImage } = require("../../modules/getAnimeByImage");

module.exports = {
name: "whatanime",
aliases: ["wa"],
args: true,
description: "Scans an Image to get the anime name!",
usage: "wa || whatanime <link>",
async run(message, args, client) {
if (!args[0])
return await message.channel.send({
embeds: [embedMessage("#9dcc37", `You have to provide an image link!`)],
});

try {
const res = await getAnimeByImage(args[0]);
const resultArray = res.result.slice(0, 3).map((info, index) => {
return (
`${index + 1}: ` +
"`" +
`${
info.anilist.title.english
? info.anilist.title.english
: `Not Available`
}` +
"`" +
" **AKA** " +
"`" +
`${info.anilist.title.romaji}` +
"`" +
" **Similarity** " +
`${info.similarity.toFixed(2) * 100}%`
);
});
const infoEmbed = {
color: "#9dcc37",
title: "Search Result",
description: `${resultArray.join("\n")}`,
timestamp: new Date(),
footer: {
text: `Requested by ${message.member.user.username}`,
icon_url: `${message.member.user.avatarURL()}`,
},
};
await message.channel.send({ embeds: [infoEmbed] });
} catch (error) {
client.logger(error.message, "error");
await message.channel.send(
`${interaction.user.toString()}, There was an error processing this image!`
);
}
},
data: new SlashCommandBuilder()
.setName("whatanime")
.setDescription("Scans an Image to get the anime name! <whatanime 'link'>")
.setDescription("Scans an Image to get the anime name!")
.addStringOption((option) =>
option.setName("image").setDescription("Image Link").setRequired(true)
),
Expand Down

0 comments on commit e95687c

Please sign in to comment.