-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Anime command, Jikan MAL API #33
base: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
const { Command } = require('@dyno.gg/dyno-core'); | ||
const superagent = require('superagent'); | ||
|
||
|
||
class Anime extends Command { | ||
constructor(...args) { | ||
super(...args); | ||
|
||
this.name = 'anime'; | ||
this.aliases = ['animu']; | ||
this.module = 'Fun'; | ||
this.description = 'Get info about an anime'; | ||
this.usage = 'anime <anime>'; | ||
this.example = 'anime acchi kocchi'; | ||
this.cooldown = 5000; | ||
this.expectedArgs = 1; | ||
} | ||
|
||
async execute({ message, args }) { | ||
let msg = await this.sendMessage(message.channel, { | ||
embed: { | ||
color: 0x337fd5, | ||
thumbnail: { | ||
url: 'https://cdn.discordapp.com/emojis/397911964988342282.gif', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discord CDNs can't be trusted, as the content may dissapear without further notice, or someone may delete the emoji. |
||
}, | ||
title: 'Looking for an anime...', | ||
}, | ||
}); | ||
let res; | ||
let anime; | ||
|
||
try { | ||
res = await superagent.get(`https://api.jikan.me/search/anime/${args.slice(1).join(' ')}/1`); | ||
anime = res.body.result[0]; | ||
} catch (err) { | ||
return msg.edit({ | ||
content: `${this.utils.emoji.error} I couldn't find any.`, | ||
embed: {}, | ||
}); | ||
} | ||
return msg.edit({ | ||
embed: { | ||
author: { | ||
name: `${anime.title}`, | ||
url: `${anime.url}`, | ||
icon_url: 'https://myanimelist.cdn-dena.com/img/sp/icon/apple-touch-icon-256.png', | ||
}, | ||
color: 0x337fd5, | ||
thumbnail: { | ||
url: anime.image_url, | ||
}, | ||
timestamp: new Date(), | ||
fields: [{ | ||
name: 'Episodes', | ||
value: `${anime.episodes}`, | ||
inline: true, | ||
}, | ||
{ | ||
name: 'Type', | ||
value: `${anime.type}`, | ||
inline: true, | ||
}, | ||
{ | ||
name: 'Score', | ||
value: `${anime.score}`, | ||
inline: true, | ||
}, | ||
{ | ||
name: 'Members', | ||
value: `${anime.members}`, | ||
inline: true, | ||
}, | ||
{ | ||
name: 'Description', | ||
value: `${anime.description}`, | ||
inline: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is the last field and the biggest, I think it makes sense for it to not be inline and take up a whole row |
||
}, | ||
], | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
module.exports = Anime; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msg is not reassigned, in that case it's better to use
const
instead oflet