mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-14 08:08:34 +02:00
Fixes
This commit is contained in:
@@ -31,10 +31,12 @@ module.exports = class WhatAnimeCommand extends Command {
|
||||
const { body } = await request.get(screenshot);
|
||||
const result = await this.search(body, msg.channel.nsfw);
|
||||
if (result === 'size') return msg.reply('Please do not send an image larger than 1MB.');
|
||||
if (result === 'nsfw') return msg.reply('This is from a hentai, and this isn\'t an NSFW channel, pervert.');
|
||||
if (result.nsfw) return msg.reply('This is from a hentai, and this isn\'t an NSFW channel, pervert.');
|
||||
return msg.reply(
|
||||
`I'm ${result.probability}% sure this is from ${result.title} (${result.english}) episode #${result.episode}.`,
|
||||
result.preview ? { files: [{ attachment: result.preview, name: 'anime.mp4' }] } : {}
|
||||
`I'm ${result.prob}% sure this is from ${result.title}${result.episode
|
||||
? ` episode ${result.episode}`
|
||||
: ''}.`,
|
||||
result.preview ? { files: [{ attachment: result.preview, name: 'preview.mp4' }] } : {}
|
||||
);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
@@ -52,20 +54,17 @@ module.exports = class WhatAnimeCommand extends Command {
|
||||
}
|
||||
}
|
||||
|
||||
async search(file, nsfw) {
|
||||
async search(file) {
|
||||
if (Buffer.byteLength(file) > 1e+6) return 'size';
|
||||
const { body } = await request
|
||||
.post('https://whatanime.ga/api/search')
|
||||
.query({ token: WHATANIME_KEY })
|
||||
.attach('image', base64(file));
|
||||
const data = body.docs[0];
|
||||
if (data.is_adult && !nsfw) return 'nsfw';
|
||||
return {
|
||||
time: data.at * 1000,
|
||||
probability: Math.round(data.similarity * 100),
|
||||
prob: Math.round(data.similarity * 100),
|
||||
episode: data.episode,
|
||||
title: data.title_native,
|
||||
english: data.title_english,
|
||||
title: data.title_english,
|
||||
preview: await this.fetchPreview(data),
|
||||
nsfw: data.is_adult
|
||||
};
|
||||
|
||||
@@ -37,9 +37,9 @@ module.exports = class CurrencyCommand extends Command {
|
||||
async run(msg, { base, target, amount }) {
|
||||
try {
|
||||
if (!this.currencies) await this.fetchCurrencies();
|
||||
base = this.currencies[base] || this.currencies.find($ => $.currencyName.toLowerCase() === base);
|
||||
base = this.currencies[base];
|
||||
if (!base) return msg.say('Invalid base.');
|
||||
target = this.currencies[target] || this.currencies.find($ => $.currencyName.toLowerCase() === target);
|
||||
target = this.currencies[target];
|
||||
if (!target) return msg.say('Invalid target.');
|
||||
if (base.id === target.id) return msg.say(`Converting ${base.id} to ${target.id} is the same value, dummy.`);
|
||||
const rate = await this.fetchRate(base, target);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const sides = [NaN, 0, null, undefined, ''];
|
||||
const sides = ['NaN', '0', 'null', 'undefined', '\'\''];
|
||||
|
||||
module.exports = class QuantumCoinCommand extends Command {
|
||||
constructor(client) {
|
||||
|
||||
Reference in New Issue
Block a user