mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Movie, TV Show, Yoda Commands
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { TMDB_KEY } = process.env;
|
||||
|
||||
module.exports = class MovieCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'movie',
|
||||
aliases: ['tmdb-movie'],
|
||||
group: 'search',
|
||||
memberName: 'movie',
|
||||
description: 'Searches TMDB for your query, getting movie results.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
const search = await snekfetch
|
||||
.get('http://api.themoviedb.org/3/search/movie')
|
||||
.query({
|
||||
api_key: TMDB_KEY,
|
||||
include_adult: msg.channel.nsfw ? true : false,
|
||||
query
|
||||
});
|
||||
if (!search.body.results.length) return msg.say('No Results.');
|
||||
const { body } = await snekfetch
|
||||
.get(`https://api.themoviedb.org/3/movie/${search.body.results[0].id}`)
|
||||
.query({ api_key: TMDB_KEY });
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x00D474)
|
||||
.setTitle(body.title)
|
||||
.setURL(`https://www.themoviedb.org/movie/${body.id}`)
|
||||
.setAuthor('TMDB', 'https://i.imgur.com/G9q4DF1.png')
|
||||
.setDescription(body.overview.substr(0, 2048))
|
||||
.setThumbnail(body.poster_path ? `https://image.tmdb.org/t/p/w500${body.poster_path}` : null)
|
||||
.addField('❯ Runtime',
|
||||
`${body.runtime} mins.`, true)
|
||||
.addField('❯ Release Date',
|
||||
body.release_date, true)
|
||||
.addField('❯ Genres',
|
||||
body.genres.map(genre => genre.name).join(', '))
|
||||
.addField('❯ Production Companies',
|
||||
body.production_companies.length ? body.production_companies.map(company => company.name).join(', ') : 'N/A');
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { TMDB_KEY } = process.env;
|
||||
|
||||
module.exports = class TVShowCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'tv-show',
|
||||
aliases: ['tmdb-tv-show', 'tv', 'tmdb-tv'],
|
||||
group: 'search',
|
||||
memberName: 'tv-show',
|
||||
description: 'Searches TMDB for your query, getting TV show results.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
const { query } = args;
|
||||
const search = await snekfetch
|
||||
.get('http://api.themoviedb.org/3/search/tv')
|
||||
.query({
|
||||
api_key: TMDB_KEY,
|
||||
include_adult: msg.channel.nsfw ? true : false,
|
||||
query
|
||||
});
|
||||
if (!search.body.results.length) return msg.say('No Results.');
|
||||
const { body } = await snekfetch
|
||||
.get(`https://api.themoviedb.org/3/tv/${search.body.results[0].id}`)
|
||||
.query({ api_key: TMDB_KEY });
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x00D474)
|
||||
.setTitle(body.name)
|
||||
.setURL(`https://www.themoviedb.org/tv/${body.id}`)
|
||||
.setAuthor('TMDB', 'https://i.imgur.com/G9q4DF1.png')
|
||||
.setDescription(body.overview.substr(0, 2048))
|
||||
.setThumbnail(body.poster_path ? `https://image.tmdb.org/t/p/w500${body.poster_path}` : null)
|
||||
.addField('❯ First Air Date',
|
||||
body.first_air_date, true)
|
||||
.addField('❯ Last Air Date',
|
||||
body.last_air_date, true)
|
||||
.addField('❯ Seasons',
|
||||
body.number_of_seasons, true)
|
||||
.addField('❯ Episodes',
|
||||
body.number_of_episodes, true)
|
||||
.addField('❯ Genres',
|
||||
body.genres.map(genre => genre.name).join(', '))
|
||||
.addField('❯ Production Companies',
|
||||
body.production_companies.length ? body.production_companies.map(company => company.name).join(', ') : 'N/A');
|
||||
return msg.embed(embed);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { MASHAPE_KEY } = process.env;
|
||||
|
||||
module.exports = class YodaCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'yoda',
|
||||
aliases: ['yoda-speak'],
|
||||
group: 'text-edit',
|
||||
memberName: 'yoda',
|
||||
description: 'Converts text to Yoda speak.',
|
||||
args: [
|
||||
{
|
||||
key: 'sentence',
|
||||
prompt: 'What text would you like to convert to Yoda speak?',
|
||||
type: 'string',
|
||||
validate: sentence => {
|
||||
if (sentence.length < 500) return true;
|
||||
return 'Text must be under 500 characters.';
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
const { sentence } = args;
|
||||
const { text } = await snekfetch
|
||||
.get('https://yoda.p.mashape.com/yoda')
|
||||
.query({ sentence })
|
||||
.set({ 'X-Mashape-Key': MASHAPE_KEY });
|
||||
return msg.say(text);
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "30.6.1",
|
||||
"version": "30.7.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Shard.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user