mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:26:21 +02:00
Remove more commands
This commit is contained in:
@@ -30,7 +30,6 @@ MEGA_EVOLVE_EMOJI_NAME=
|
||||
NAME_RATER_EMOJI_ID=
|
||||
|
||||
# API Keys, IDs, and Secrets
|
||||
ALPHA_VANTAGE_KEY=
|
||||
ANILIST_USERNAME=
|
||||
BITLY_KEY=
|
||||
CLEVERBOT_KEY=
|
||||
@@ -44,13 +43,10 @@ OPENWEATHERMAP_KEY=
|
||||
OSU_KEY=
|
||||
SPOTIFY_KEY=
|
||||
SPOTIFY_SECRET=
|
||||
TMDB_KEY=
|
||||
UNSPLASH_KEY=
|
||||
USPS_USERID=
|
||||
WEBSTER_KEY=
|
||||
XIAO_GITHUB_REPO_NAME=
|
||||
XIAO_GITHUB_REPO_USERNAME=
|
||||
|
||||
# Imgur album IDs
|
||||
POTATO_ALBUM_ID=
|
||||
XIAO_ALBUM_ID=
|
||||
|
||||
@@ -309,42 +309,6 @@ client.on('guildDelete', async guild => {
|
||||
}
|
||||
});
|
||||
|
||||
client.on('guildMemberRemove', async member => {
|
||||
if (member.id === client.user.id) return null;
|
||||
const channel = member.guild.systemChannel;
|
||||
if (!channel || !channel.permissionsFor(client.user).has('SEND_MESSAGES')) return null;
|
||||
if (member.guild.systemChannelFlags.has('SUPPRESS_JOIN_NOTIFICATIONS')) return null;
|
||||
if (channel.topic && channel.topic.includes('<xiao:disable-leave>')) return null;
|
||||
try {
|
||||
const leaveMessage = client.leaveMessages[Math.floor(Math.random() * client.leaveMessages.length)];
|
||||
await channel.send(leaveMessage.replaceAll('{{user}}', `**${member.user.tag}**`));
|
||||
return null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
client.on('voiceStateUpdate', async (oldState, newState) => {
|
||||
if (newState.channel || !oldState.channel) return;
|
||||
if (oldState.id === client.user.id) {
|
||||
const dispatcher = client.dispatchers.get(oldState.guild.id);
|
||||
if (!dispatcher) return;
|
||||
dispatcher.end();
|
||||
client.dispatchers.delete(oldState.guild.id);
|
||||
} else {
|
||||
const channel = await client.channels.fetch(oldState.channelID);
|
||||
if (!channel) return;
|
||||
if (channel.members.size === 1 && channel.members.has(client.user.id)) {
|
||||
const dispatcher = client.dispatchers.get(oldState.guild.id);
|
||||
if (dispatcher) {
|
||||
dispatcher.end();
|
||||
client.dispatchers.delete(oldState.guild.id);
|
||||
}
|
||||
channel.leave();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
client.on('disconnect', event => {
|
||||
client.logger.error(`[DISCONNECT] Disconnected with code ${event.code}.`);
|
||||
client.exportCommandLeaderboard();
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
[
|
||||
"{{user}} bailed on us...",
|
||||
"\"Look, what's that!\" said {{user}}, before dashing away.",
|
||||
"{{user}} ran away.",
|
||||
"{{user}} decided they didn't want to deal with you anymore and ran off.",
|
||||
"{{user}} jumped ship.",
|
||||
"{{user}} ate too much candy and was taken to a hospital in another server.",
|
||||
"{{user}} left to join a rival gang.",
|
||||
"{{user}} decided to take a break from your server. Possibly forever.",
|
||||
"{{user}} said \"See ya, suckers!\"",
|
||||
"According to all known laws of aviation, there is no way {{user}} should be able to fly. But they did, right out of your server.",
|
||||
"Goodbye, {{user}}!",
|
||||
"You forgot to feed {{user}}, so they ran away.",
|
||||
"{{user}} left to become a hermit in the mountains. I hear he has a goat now.",
|
||||
"{{user}} flew away. Wait, they have wings?!",
|
||||
"We'll miss you, {{user}}! I think.",
|
||||
"{{user}} left the nest. They grow up so fast...",
|
||||
"{{user}} is no longer a part of your family.",
|
||||
"And just like that, {{user}} said goodbye to your server and started a new adventure.",
|
||||
"In other news, local resident {{user}} leaves the server. Cites stupid bot \"Xiao\" as the reason. Wait, stupid?",
|
||||
"{{user}} left. How unfortunate.",
|
||||
"{{user}} was dumped into the bottomless sea.",
|
||||
"Arr, matey! {{user}} was sent to Davy Jones' Locker!",
|
||||
"{{user}} found a better server to play around in.",
|
||||
"{{user}} set off on their Pokémon journey!",
|
||||
"\"But {{user}}, you can't leave!\" cried Xiao. But it was too late. They had already left without even saying goodbye.",
|
||||
"{{user}} became a ghost, and left to haunt another server.",
|
||||
"Sayonara, {{user}}!",
|
||||
"{{user}} is thinking about leaving. Oh wait, they already did.",
|
||||
"{{user}} fled.",
|
||||
"In loving memory of the fun times you've had with {{user}}. Goodbye."
|
||||
]
|
||||
@@ -1,18 +0,0 @@
|
||||
[
|
||||
"memes",
|
||||
"wholesomememes",
|
||||
"tumblr",
|
||||
"meirl",
|
||||
"historymemes",
|
||||
"programmerhumor",
|
||||
"programmeranimemes",
|
||||
"bikinibottomtwitter",
|
||||
"prequelmemes",
|
||||
"otmemes",
|
||||
"mothmemes",
|
||||
"meme",
|
||||
"politicalhumor",
|
||||
"surrealmemes",
|
||||
"gamingcirclejerk",
|
||||
"animemes"
|
||||
]
|
||||
@@ -1,49 +0,0 @@
|
||||
[
|
||||
"news",
|
||||
"politics",
|
||||
"movies",
|
||||
"science",
|
||||
"worldnews",
|
||||
"entertainment",
|
||||
"futurology",
|
||||
"games",
|
||||
"technology",
|
||||
"technewstoday",
|
||||
"gadgets",
|
||||
"technews",
|
||||
"tech",
|
||||
"everythingscience",
|
||||
"esports",
|
||||
"television",
|
||||
"space",
|
||||
"baseball",
|
||||
"hockey",
|
||||
"apple",
|
||||
"environment",
|
||||
"spacex",
|
||||
"economics",
|
||||
"android",
|
||||
"collegebasketball",
|
||||
"medicine",
|
||||
"iphone",
|
||||
"privacy",
|
||||
"psychology",
|
||||
"economy",
|
||||
"climate",
|
||||
"business",
|
||||
"energy",
|
||||
"cryptomarkets",
|
||||
"mlb",
|
||||
"nature",
|
||||
"finance",
|
||||
"health",
|
||||
"security",
|
||||
"cfb",
|
||||
"cryptocurrency",
|
||||
"programming",
|
||||
"nba",
|
||||
"boxoffice",
|
||||
"comicbooks",
|
||||
"sports",
|
||||
"celebrities"
|
||||
]
|
||||
@@ -1,47 +0,0 @@
|
||||
[
|
||||
"I'm not Waldo, sorry (• ε •)",
|
||||
"I'm a coala ʕ•ᴥ•ʔ",
|
||||
"Who is Waldo? ◉_◉",
|
||||
"I don't know where he is or who is he? (▀̿Ĺ̯▀̿ ̿)",
|
||||
"I'm just walking with my dog | (• ◡•)| (❍ᴥ❍ʋ)",
|
||||
"I think he's over there (˚▽˚)☞",
|
||||
"I think he is over there ☜(˚▽˚)",
|
||||
"I don't know maam ¯\\(°_o)/¯",
|
||||
"I'm not Waldo 。◕‿◕。",
|
||||
"me dont kno, swowy ٩◔̯◔۶",
|
||||
"I'm not \"Wally\" ^̮^ fmrjnv (・.◤)",
|
||||
"help me i think the guy next me wants to kill me ≧☉_☉≦",
|
||||
"Don't mind me 〆(・∀・@)",
|
||||
"I'm a butterfly Ƹ̵̡Ӝ̵̨̄Ʒ",
|
||||
"I'm trying to find my dog... ಥ_ಥ",
|
||||
"DANCE ヾ(⌐■_■)ノ♪",
|
||||
"I know where he is, but i won't tell you (͡ ͡° ͜ つ ͡͡°)",
|
||||
"I'm just a cool guy (▀̿Ĺ̯▀̿ ̿)",
|
||||
"I'm not him \\ (•◡•) /",
|
||||
"I LOST MY SON CAN YOU FIND IT PLEASE (;´༎ຶД༎ຶ`)",
|
||||
"We are all friends (◕‿◕✿)",
|
||||
"Yes, i'm human, but no Waldo /╲/\\╭( ͡° ͡° ͜ʖ ͡° ͡°)╮/\\╱\\",
|
||||
"Waldo? Haven't heard that name in years (ì_í ò)",
|
||||
"I'm trying to find a Karen, can you find it? ̿ ̿ ̿'̿'\\̵͇̿̿\\з=(•_•)",
|
||||
"This copypasta was created by reddit user Guschuma ¯\\_(ツ)_/¯",
|
||||
"uhh, waldo? who is he ب_ب",
|
||||
"I'm Waldo, you finded me, can you find the easter eggs?(ʘ▽ʘ)",
|
||||
"I'M WALDO, jk (~˘▾˘)~",
|
||||
"I'm walking with my boys (▀̿Ĺ̯▀̿ ̿)(▀̿Ĺ̯▀̿ ̿)(▀̿Ĺ̯▀̿ ̿)",
|
||||
"Hi, i'm don't know what \"Wallo\" means ¯\\_(ツ)_/¯",
|
||||
"No (/) (°,,°) (/)",
|
||||
"Waldo?, WALDO?, WAAAALDO!! (ʘᗩʘ')",
|
||||
"*whistling happily* ♪~ ᕕ(ᐛ)ᕗ",
|
||||
"hug? ༼ つ ◕_◕ ༽つ",
|
||||
"I lost my mom, can you find it? ◉_◉",
|
||||
"Waldo? he's over there ˙ ͜ʟ˙",
|
||||
"waldodi, waldodo, waldodi wa waldodo ♪。◕‿◕♪。",
|
||||
"Can I speak to your manager?ლ,ᔑ•ﺪ͟͠•ᔐ.ლ",
|
||||
"I'm crying and i don't know why ಠ_ಥ",
|
||||
"Hi, i'm not Waldo, sorry ( ͡ᵔ ͜ʖ ͡ᵔ )",
|
||||
"Do you want some lemonade? ┬┴┬┴┤(・_├┬┴┬┴",
|
||||
"Where's my face? I'm dog! where's owner (ᵔᴥᵔ)",
|
||||
"hi \\ (•◡•) /",
|
||||
"Can you please find some flowers i can give to her? ( ♥‿♥)",
|
||||
"I'm not Waldo (◕‿◕✿)"
|
||||
]
|
||||
@@ -1,33 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { shuffle } = require('../../util/Util');
|
||||
const waldos = require('../../assets/json/waldo');
|
||||
|
||||
module.exports = class WaldoCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'waldo',
|
||||
aliases: ['wheres-waldo', 'where\'s-waldo', 'wally', 'wheres-wally', 'where\'s-wally'],
|
||||
group: 'games-sp',
|
||||
memberName: 'waldo',
|
||||
description: 'Try to find Waldo with spoiler tags!',
|
||||
credit: [
|
||||
{
|
||||
name: 'u/guschuma',
|
||||
url: 'https://www.reddit.com/user/guschuma/',
|
||||
reason: 'Concept',
|
||||
reasonURL: 'https://www.reddit.com/r/copypasta/comments/gkk7z1/wheres_waldo_game_created_by_me/'
|
||||
},
|
||||
{
|
||||
name: 'Martin Handford',
|
||||
url: 'https://www.candlewick.com/authill.asp?b=Author&m=bio&id=1497&pix=y',
|
||||
reason: 'Original "Where\'s Wally?" Book Series'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
const where = shuffle(waldos);
|
||||
return msg.say(where.map(waldo => `||${waldo}||`).join(' '));
|
||||
}
|
||||
};
|
||||
@@ -1,21 +0,0 @@
|
||||
const SubredditCommand = require('../../structures/commands/Subreddit');
|
||||
|
||||
module.exports = class AwwnimeCommand extends SubredditCommand {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'awwnime',
|
||||
aliases: ['aww-anime', 'moe'],
|
||||
group: 'random-img',
|
||||
memberName: 'awwnime',
|
||||
description: 'Responds with cute random anime art.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
postType: 'image',
|
||||
getIcon: true,
|
||||
subreddit: 'awwnime'
|
||||
});
|
||||
}
|
||||
|
||||
generateText(post, subreddit, icon) {
|
||||
return this.makeEmbed(post, subreddit, icon);
|
||||
}
|
||||
};
|
||||
@@ -1,33 +0,0 @@
|
||||
const SubredditCommand = require('../../structures/commands/Subreddit');
|
||||
const { list } = require('../../util/Util');
|
||||
const subreddits = ['interestingasfuck', 'mildlyinteresting', 'damnthatsinteresting'];
|
||||
|
||||
module.exports = class InterestingCommand extends SubredditCommand {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'interesting',
|
||||
aliases: ['interesting-as-fuck', 'mildly-interesting'],
|
||||
group: 'random-img',
|
||||
memberName: 'interesting',
|
||||
description: 'Responds with a random interesting image.',
|
||||
details: `**Subreddits:** ${subreddits.join(', ')}`,
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
postType: 'image',
|
||||
getIcon: true,
|
||||
args: [
|
||||
{
|
||||
key: 'subreddit',
|
||||
prompt: `What subreddit do you want to get memes from? Either ${list(subreddits, 'or')}.`,
|
||||
type: 'string',
|
||||
oneOf: subreddits,
|
||||
default: () => subreddits[Math.floor(Math.random() * subreddits.length)],
|
||||
parse: subreddit => subreddit.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
generateText(post, subreddit, icon) {
|
||||
return this.makeEmbed(post, subreddit, icon);
|
||||
}
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
const SubredditCommand = require('../../structures/commands/Subreddit');
|
||||
const { list } = require('../../util/Util');
|
||||
const subreddits = require('../../assets/json/meme');
|
||||
|
||||
module.exports = class MemeCommand extends SubredditCommand {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'meme',
|
||||
group: 'random-img',
|
||||
memberName: 'meme',
|
||||
description: 'Responds with a random meme.',
|
||||
details: `**Subreddits:** ${subreddits.join(', ')}`,
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
postType: 'image',
|
||||
getIcon: true,
|
||||
args: [
|
||||
{
|
||||
key: 'subreddit',
|
||||
prompt: `What subreddit do you want to get memes from? Either ${list(subreddits, 'or')}.`,
|
||||
type: 'string',
|
||||
oneOf: subreddits,
|
||||
default: () => subreddits[Math.floor(Math.random() * subreddits.length)],
|
||||
parse: subreddit => subreddit.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
generateText(post, subreddit, icon) {
|
||||
return this.makeEmbed(post, subreddit, icon);
|
||||
}
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
const ImgurAlbumCommand = require('../../structures/commands/ImgurAlbum');
|
||||
const { POTATO_ALBUM_ID } = process.env;
|
||||
|
||||
module.exports = class PotatoCommand extends ImgurAlbumCommand {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'potato',
|
||||
group: 'random-img',
|
||||
memberName: 'potato',
|
||||
description: 'Responds with a random potato image.',
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
albumID: POTATO_ALBUM_ID
|
||||
});
|
||||
}
|
||||
|
||||
generateText() {
|
||||
return 'I like potatoes.';
|
||||
}
|
||||
};
|
||||
@@ -1,30 +0,0 @@
|
||||
const SubredditCommand = require('../../structures/commands/Subreddit');
|
||||
const { list } = require('../../util/Util');
|
||||
const subreddits = require('../../assets/json/news');
|
||||
|
||||
module.exports = class NewsCommand extends SubredditCommand {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'news',
|
||||
group: 'random-res',
|
||||
memberName: 'news',
|
||||
description: 'Responds with a random news article.',
|
||||
details: `**Subreddits:** ${subreddits.join(', ')}`,
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
getIcon: true,
|
||||
args: [
|
||||
{
|
||||
key: 'subreddit',
|
||||
prompt: `What subreddit do you want to get news from? Either ${list(subreddits, 'or')}.`,
|
||||
type: 'string',
|
||||
oneOf: subreddits,
|
||||
parse: subreddit => subreddit.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
generateText(post, subreddit, icon) {
|
||||
return this.makeEmbed(post, subreddit, icon);
|
||||
}
|
||||
};
|
||||
@@ -1,18 +0,0 @@
|
||||
const SubredditCommand = require('../../structures/commands/Subreddit');
|
||||
|
||||
module.exports = class ShowerThoughtCommand extends SubredditCommand {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'shower-thought',
|
||||
aliases: ['shower-thoughts', 'shower', 's-thought', 'shower-t'],
|
||||
group: 'random-res',
|
||||
memberName: 'shower-thought',
|
||||
description: 'Responds with a random shower thought, directly from r/Showerthoughts.',
|
||||
subreddit: 'Showerthoughts'
|
||||
});
|
||||
}
|
||||
|
||||
generateText(post) {
|
||||
return post.title;
|
||||
}
|
||||
};
|
||||
@@ -1,27 +0,0 @@
|
||||
const SubredditCommandBase = require('../../structures/commands/Subreddit');
|
||||
|
||||
module.exports = class SubredditCommand extends SubredditCommandBase {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'subreddit',
|
||||
aliases: ['r/', 'sub'],
|
||||
group: 'random-res',
|
||||
memberName: 'subreddit',
|
||||
description: 'Responds with a random post from a subreddit.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
getIcon: true,
|
||||
args: [
|
||||
{
|
||||
key: 'subreddit',
|
||||
prompt: 'What subreddit would you like to get a post from?',
|
||||
type: 'string',
|
||||
parse: subreddit => encodeURIComponent(subreddit)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
generateText(post, subreddit, icon) {
|
||||
return this.makeEmbed(post, subreddit, icon);
|
||||
}
|
||||
};
|
||||
@@ -1,70 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { shorten, pickWhenMany } = require('../../util/Util');
|
||||
const { TMDB_KEY } = process.env;
|
||||
|
||||
module.exports = class MovieCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'movie',
|
||||
aliases: ['tmdb-movie', 'imdb'],
|
||||
group: 'search',
|
||||
memberName: 'movie',
|
||||
description: 'Searches TMDB for your query, getting movie results.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'The Movie Database',
|
||||
url: 'https://www.themoviedb.org/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://www.themoviedb.org/documentation/api'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What movie would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const search = await request
|
||||
.get('http://api.themoviedb.org/3/search/movie')
|
||||
.query({
|
||||
api_key: TMDB_KEY,
|
||||
include_adult: msg.channel.nsfw || false,
|
||||
query
|
||||
});
|
||||
if (!search.body.results.length) return msg.say('Could not find any results.');
|
||||
let find = search.body.results.find(m => m.title.toLowerCase() === query.toLowerCase())
|
||||
|| search.body.results[0];
|
||||
if (search.body.results.length > 1) {
|
||||
const resultListFunc = (movie, i) => `**${i + 1}.** ${movie.title} (${movie.release_date || 'TBA'})`;
|
||||
find = await pickWhenMany(msg, search.body.results, find, resultListFunc);
|
||||
}
|
||||
const { body } = await request
|
||||
.get(`https://api.themoviedb.org/3/movie/${find.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/3K3QMv9.png', 'https://www.themoviedb.org/')
|
||||
.setDescription(body.overview ? shorten(body.overview) : 'No description available.')
|
||||
.setThumbnail(body.poster_path ? `https://image.tmdb.org/t/p/w500${body.poster_path}` : null)
|
||||
.addField('❯ Runtime', body.runtime ? `${body.runtime} mins.` : '???', true)
|
||||
.addField('❯ Release Date', body.release_date || '???', true)
|
||||
.addField('❯ Genres', body.genres.length ? body.genres.map(genre => genre.name).join(', ') : '???')
|
||||
.addField('❯ Production Companies',
|
||||
body.production_companies.length ? body.production_companies.map(c => c.name).join(', ') : '???');
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,58 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const moment = require('moment');
|
||||
const { formatNumber } = require('../../util/Util');
|
||||
|
||||
module.exports = class RedditCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'reddit',
|
||||
aliases: ['u/'],
|
||||
group: 'search',
|
||||
memberName: 'reddit',
|
||||
description: 'Responds with information on a Reddit user.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Reddit',
|
||||
url: 'https://www.reddit.com/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://www.reddit.com/dev/api/'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'user',
|
||||
prompt: 'What user would you like to get information on?',
|
||||
type: 'string',
|
||||
parse: user => encodeURIComponent(user)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { user }) {
|
||||
try {
|
||||
const { body } = await request.get(`https://www.reddit.com/user/${user}/about.json`);
|
||||
const { data } = body;
|
||||
if (data.hide_from_robots) return msg.say('This user is hidden from bots.');
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xFF4500)
|
||||
.setAuthor('Reddit', 'https://i.imgur.com/DSBOK0P.png', 'https://www.reddit.com/')
|
||||
.setThumbnail(data.icon_img)
|
||||
.setURL(`https://www.reddit.com/user/${user}`)
|
||||
.setTitle(`/u/${data.name}`)
|
||||
.addField('❯ Username', data.name, true)
|
||||
.addField('❯ ID', data.id, true)
|
||||
.addField('❯ Karma', formatNumber(data.link_karma + data.comment_karma), true)
|
||||
.addField('❯ Creation Date', moment.utc(data.created_utc * 1000).format('MM/DD/YYYY h:mm A'), true)
|
||||
.addField('❯ Gold?', data.is_gold ? 'Yes' : 'No', true)
|
||||
.addField('❯ Verified?', data.verified ? 'Yes' : 'No', true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
if (err.status === 404) return msg.say('Could not find any results.');
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,64 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { shorten } = require('../../util/Util');
|
||||
const { UNSPLASH_KEY } = process.env;
|
||||
|
||||
module.exports = class StockPhotoCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'stock-photo',
|
||||
aliases: ['unsplash', 'stock-image', 'stock-img'],
|
||||
group: 'search',
|
||||
memberName: 'stock-photo',
|
||||
description: 'Searches for stock photos based on your query.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Unsplash',
|
||||
url: 'https://unsplash.com/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://unsplash.com/developers'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What image would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://api.unsplash.com/photos/random')
|
||||
.set({ Authorization: `Client-ID ${UNSPLASH_KEY}` })
|
||||
.query({
|
||||
query,
|
||||
content_filter: msg.channel.nsfw ? 'low' : 'high'
|
||||
});
|
||||
await this.triggerDownload(body);
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle(body.description ? shorten(body.description, 256) : 'Unnamed Image')
|
||||
.setURL(body.user.links.html)
|
||||
.setColor(body.color)
|
||||
.setAuthor(body.user.name || body.user.username, undefined, body.user.links.html)
|
||||
.setImage(body.urls.raw)
|
||||
.setFooter(`Photo by ${body.user.name || body.user.username} on Unsplash`)
|
||||
.setTimestamp(new Date(body.updated_at));
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
if (err.status === 404) return msg.say('Could not find any results.');
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
triggerDownload(body) {
|
||||
return request
|
||||
.get(body.links.download_location)
|
||||
.set({ Authorization: `Client-ID ${UNSPLASH_KEY}` });
|
||||
}
|
||||
};
|
||||
@@ -1,72 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { shorten, formatNumber, pickWhenMany } = require('../../util/Util');
|
||||
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'],
|
||||
credit: [
|
||||
{
|
||||
name: 'The Movie Database',
|
||||
url: 'https://www.themoviedb.org/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://www.themoviedb.org/documentation/api'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What TV show would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const search = await request
|
||||
.get('http://api.themoviedb.org/3/search/tv')
|
||||
.query({
|
||||
api_key: TMDB_KEY,
|
||||
include_adult: msg.channel.nsfw || false,
|
||||
query
|
||||
});
|
||||
if (!search.body.results.length) return msg.say('Could not find any results.');
|
||||
let find = search.body.results.find(m => m.name.toLowerCase() === query.toLowerCase())
|
||||
|| search.body.results[0];
|
||||
if (search.body.results.length > 1) {
|
||||
const resultListFunc = (show, i) => `**${i + 1}.** ${show.name} (${show.first_air_date || 'TBA'})`;
|
||||
find = await pickWhenMany(msg, search.body.results, find, resultListFunc);
|
||||
}
|
||||
const { body } = await request
|
||||
.get(`https://api.themoviedb.org/3/tv/${find.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/3K3QMv9.png', 'https://www.themoviedb.org/')
|
||||
.setDescription(body.overview ? shorten(body.overview) : 'No description available.')
|
||||
.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 ? formatNumber(body.number_of_seasons) : '???', true)
|
||||
.addField('❯ Episodes', body.number_of_episodes ? formatNumber(body.number_of_episodes) : '???', true)
|
||||
.addField('❯ Genres', body.genres.length ? body.genres.map(genre => genre.name).join(', ') : '???')
|
||||
.addField('❯ Production Companies',
|
||||
body.production_companies.length ? body.production_companies.map(c => c.name).join(', ') : '???');
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,78 +0,0 @@
|
||||
const request = require('node-superfetch');
|
||||
const Command = require('../../framework/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { formatNumberK, shorten } = require('../../util/Util');
|
||||
|
||||
module.exports = class SubredditCommand extends Command {
|
||||
constructor(client, info) {
|
||||
super(client, info);
|
||||
|
||||
this.subreddit = info.subreddit;
|
||||
this.postType = info.postType ? Array.isArray(info.postType) ? info.postType : [info.postType] : null;
|
||||
this.getIcon = info.getIcon || false;
|
||||
this.credit.push({
|
||||
name: 'Reddit',
|
||||
url: 'https://www.reddit.com/',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://www.reddit.com/dev/api/'
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { subreddit }) {
|
||||
if (!subreddit) subreddit = typeof this.subreddit === 'function' ? this.subreddit() : this.subreddit;
|
||||
try {
|
||||
const post = await this.random(subreddit, msg.channel.nsfw);
|
||||
if (!post) return msg.reply('Could not find any results.');
|
||||
return msg.embed(this.generateText(post.post, post.origin, post.icon));
|
||||
} catch (err) {
|
||||
if (err.status === 403) return msg.say('This subreddit is private.');
|
||||
if (err.status === 404) return msg.say('Could not find any results.');
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
|
||||
generateText() {
|
||||
throw new Error('The generateText method is required.');
|
||||
}
|
||||
|
||||
makeEmbed(post, subreddit, icon) {
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xFF4500)
|
||||
.setAuthor(`r/${subreddit}`, icon, `https://www.reddit.com/r/${subreddit}/`)
|
||||
.setTitle(shorten(post.title, 256))
|
||||
.setImage(post.post_hint === 'image' ? post.url : null)
|
||||
.setURL(`https://www.reddit.com${post.permalink}`)
|
||||
.setTimestamp(post.created_utc * 1000)
|
||||
.setFooter(`⬆ ${formatNumberK(post.ups)}`);
|
||||
if (post.thumbnail && post.thumbnail !== 'self' && post.thumbnail !== 'default' && post.post_hint !== 'image') {
|
||||
embed.setThumbnail(post.thumbnail);
|
||||
}
|
||||
return embed;
|
||||
}
|
||||
|
||||
async random(subreddit, nsfw) {
|
||||
let icon = null;
|
||||
const { body } = await request
|
||||
.get(`https://www.reddit.com/r/${subreddit}/hot.json`)
|
||||
.query({ limit: 100 });
|
||||
if (!body.data.children.length) return null;
|
||||
const posts = body.data.children.filter(post => {
|
||||
if (!post.data) return false;
|
||||
if (!nsfw && post.data.over_18) return false;
|
||||
return (this.postType ? this.postType.includes(post.data.post_hint) : true) && post.data.url && post.data.title;
|
||||
});
|
||||
if (!posts.length) return null;
|
||||
if (this.getIcon) icon = await this.fetchIcon(subreddit);
|
||||
return {
|
||||
origin: subreddit,
|
||||
post: posts[Math.floor(Math.random() * posts.length)].data,
|
||||
icon
|
||||
};
|
||||
}
|
||||
|
||||
async fetchIcon(subreddit) {
|
||||
const { body } = await request.get(`https://www.reddit.com/r/${subreddit}/about.json`);
|
||||
if (!body.data.icon_img && !body.data.community_icon) return 'https://i.imgur.com/DSBOK0P.png';
|
||||
return body.data.icon_img || body.data.community_icon.replace(/\?.+/, '');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user