Various Fixes

This commit is contained in:
Dragon Fire
2021-01-12 21:51:38 -05:00
parent af8cf9858c
commit fc34b306bc
10 changed files with 1710 additions and 20 deletions
+2 -2
View File
@@ -12,7 +12,7 @@ module.exports = class AiFursonaCommand extends Command {
credit: [
{
name: 'This Fursona Does Not Exist',
url: 'https://thisfursonadoesnotexist.com/',
url: 'http://thisfursonadoesnotexist.com/',
reason: 'API'
}
]
@@ -22,7 +22,7 @@ module.exports = class AiFursonaCommand extends Command {
run(msg) {
const num = Math.floor(Math.random() * 100000);
return msg.say(`AI-Generated Fursona #${num}`, {
files: [`https://thisfursonadoesnotexist.com/v2/jpgs/seed${num.toString().padStart(5, '0')}.jpg`]
files: [`http://thisfursonadoesnotexist.com/v2/jpgs/seed${num.toString().padStart(5, '0')}.jpg`]
});
}
};
+7 -10
View File
@@ -1,5 +1,6 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const { safe, nsfw } = require('../../assets/json/never-have-i-ever');
const all = [...safe, ...nsfw];
module.exports = class NeverHaveIEverCommand extends Command {
constructor(client) {
@@ -11,21 +12,17 @@ module.exports = class NeverHaveIEverCommand extends Command {
description: 'Responds with a random "Never Have I Ever..." statement.',
credit: [
{
name: 'Gerhard Jordan',
url: 'http://www.gerhardjordan.com/',
name: 'PsyCat Games',
url: 'https://psycatgames.com/',
reason: 'Statement Data',
reasonURL: 'http://www.neverhaveiever.org/'
reasonURL: 'https://psycatgames.com/app/never-have-i-ever/'
}
]
});
}
async run(msg) {
try {
const { text } = await request.get('http://www.neverhaveiever.org/randomtext.php');
return msg.say(text.match(/<h1>(.+)<\/h1>/i)[1].replaceAll('</br>', ''));
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
if (msg.channel.nsfw) return msg.say(all[Math.floor(Math.random() * all.length)]);
return msg.say(safe[Math.floor(Math.random() * safe.length)]);
}
};
+60
View File
@@ -0,0 +1,60 @@
const Command = require('../../structures/Command');
const searchGraphQL = stripIndents`
query ($name: String) {
users: Page (perPage: 1) {
results: users (name: $name) {
id
name
}
}
}
`;
module.exports = class AnilistCommand extends Command {
constructor(client) {
super(client, {
name: 'anilist',
aliases: ['anilist-user'],
group: 'search',
memberName: 'anilist',
description: 'Responds with user information for an Anilist user.',
clientPermissions: ['EMBED_LINKS'],
credit: [
{
name: 'AniList',
url: 'https://anilist.co/',
reason: 'API',
reasonURL: 'https://anilist.gitbook.io/anilist-apiv2-docs/'
}
],
args: [
{
key: 'query',
prompt: 'What user would you like to get the information of?',
type: 'string'
}
]
});
}
async run(msg, { query }) {
try {
const data = await this.search(query);
if (!data || !data.id || !data.name) return msg.say('Could not find any results.');
return msg.say(`https://anilist.co/user/${data.name}`, { files: [`https://img.anili.st/user/${data.id}`] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
async search(query) {
const { body } = await request
.post('https://graphql.anilist.co/')
.send({
variables: { search: query },
query: searchGraphQL
});
if (!body.data.users.results.length) return null;
return body.data.users.results[0];
}
};
+1 -1
View File
@@ -79,7 +79,7 @@ module.exports = class AnimeCommand extends Command {
constructor(client) {
super(client, {
name: 'anime',
aliases: ['anilist-anime', 'anilist', 'ani', 'myanimelist', 'mal', 'mal-score'],
aliases: ['anilist-anime', 'ani', 'myanimelist', 'mal', 'mal-score'],
group: 'search',
memberName: 'anime',
description: 'Searches AniList for your query, getting anime results.',
+2 -1
View File
@@ -2,6 +2,7 @@ const Command = require('../../structures/Command');
const moment = require('moment');
const { MessageEmbed } = require('discord.js');
const request = require('node-superfetch');
const { decode: decodeHTML } = require('html-entities');
const { formatNumber, embedURL } = require('../../util/Util');
const { STACKOVERFLOW_KEY } = process.env;
@@ -51,7 +52,7 @@ module.exports = class StackOverflowCommand extends Command {
.setColor(0xF48023)
.setAuthor('Stack Overflow', 'https://i.imgur.com/P2jAgE3.png', 'https://stackoverflow.com/')
.setURL(data.link)
.setTitle(data.title)
.setTitle(decodeHTML(data.title))
.addField(' ID', data.question_id, true)
.addField(' Asker', embedURL(data.owner.display_name, data.owner.link), true)
.addField(' Views', formatNumber(data.view_count), true)
+1
View File
@@ -66,6 +66,7 @@ module.exports = class TwitterCommand extends Command {
return msg.embed(embed);
} catch (err) {
if (err.status === 401) await this.fetchToken();
if (err.status === 403) return msg.say('This user is either private or suspended.');
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!`);
}