Change IMDB to Manual Request Beta

This commit is contained in:
Daniel Odendahl Jr
2017-04-02 03:02:52 +00:00
parent b74711c6bc
commit b3ff627c17
6 changed files with 29 additions and 26 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ module.exports = class ImageSearchCommand extends commando.Command {
let searchMsg = await message.say('Searching...');
try {
let response = await request
.get(`https://www.google.com/search?tbm=isch&gs_l=img&q=${encodeURI(thingToSearch)}`);
.get(`https://www.google.com/search?tbm=isch&gs_l=img&q=${thingToSearch}`);
const $ = cheerio.load(response.text);
const result = $('.images_table').find('img').first().attr('src');
return searchMsg.edit(result);
+24 -20
View File
@@ -1,6 +1,6 @@
const commando = require('discord.js-commando');
const Discord = require('discord.js');
const imdb = require('imdb-api');
const request = require('superagent');
module.exports = class IMDBCommand extends commando.Command {
constructor(Client) {
@@ -23,39 +23,43 @@ module.exports = class IMDBCommand extends commando.Command {
});
}
run(message, args) {
async run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
}
console.log(`[Command] ${message.content}`);
let queryMovie = args.movie;
let movie;
imdb.getReq({
name: queryMovie
}, (err, response) => {
movie = response;
if (!movie) return message.say(":x: Error! Movie not found!");
let queryMovie = encodeURI(args.movie);
try {
let response = await request
.get(`http://www.omdbapi.com/`)
.query({
t: queryMovie,
plot: 'full'
});
const embed = new Discord.RichEmbed()
.setColor(0xDBA628)
.setAuthor('IMDB', 'http://static.wixstatic.com/media/c65cbf_31901b544fe24f1890134553bf40c8be.png')
.setURL(movie.imdburl)
.setTitle(`${movie.title} (${movie.rating} Score)`)
.setDescription(`${movie.plot.substr(0, 1500)} [Read the Rest Here!](${movie.imdburl})`)
.setURL(`http://www.imdb.com/title/${response.body.imdbID}`)
.setTitle(`${response.body.Title} (${response.body.imdbRating} Score)`)
.setDescription(`${response.body.Plot.substr(0, 1500)} [Read the Rest Here!](http://www.imdb.com/title/${response.body.imdbID})`)
.addField('**Genres:**',
movie.genres)
response.body.Genre)
.addField('**Year:**',
movie.year, true)
response.body.Year, true)
.addField('**Rated:**',
movie.rated, true)
response.body.Rated, true)
.addField('**Runtime:**',
movie.runtime, true)
response.body.Runtime, true)
.addField('**Directors:**',
movie.director)
response.body.Director)
.addField('**Writers:**',
movie.writer)
response.body.Writer)
.addField('**Actors:**',
movie.actors);
response.body.Actors);
return message.embed(embed);
});
}
catch (err) {
return message.say(':x: Error! Movie not found!');
}
}
};
+1 -1
View File
@@ -29,7 +29,7 @@ module.exports = class OsuCommand extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
}
console.log(`[Command] ${message.content}`);
let usernameToSearch = args.username;
let usernameToSearch = encodeURI(args.username);
try {
let response = await request
.get('https://osu.ppy.sh/api/get_user')
+1 -1
View File
@@ -24,7 +24,7 @@ module.exports = class WattpadCommand extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
}
console.log(`[Command] ${message.content}`);
let queryBook = args.book;
let queryBook = encodeURI(args.book);
try {
let response = await request
.get('https://api.wattpad.com:443/v4/stories')
+2 -2
View File
@@ -23,7 +23,7 @@ module.exports = class YodaCommand extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log(`[Command] ${message.content}`);
let turnToYoda = args.text;
let turnToYoda = encodeURI(args.text);
try {
let response = await request
.get('https://yoda.p.mashape.com/yoda')
@@ -32,7 +32,7 @@ module.exports = class YodaCommand extends commando.Command {
'Accept': 'text/plain'
})
.query({
sentence: encodeURI(turnToYoda)
sentence: turnToYoda
});
if (!response.text) return message.say(':x: Error! Something went wrong! Keep it simple to avoid this error.');
return message.say(response.text);
-1
View File
@@ -23,7 +23,6 @@
"discord.js-commando": "gawdl3y/discord.js-commando",
"google-translate-api": "^2.2.2",
"hepburn": "^1.0.0",
"imdb-api": "^2.2.1",
"jimp": "^0.2.27",
"mathjs": "^3.10.0",
"moment": "^2.17.1",