mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 10:25:11 +02:00
Stuff
This commit is contained in:
@@ -23,5 +23,6 @@
|
|||||||
"https://i.imgur.com/kG6Qp9U.jpg",
|
"https://i.imgur.com/kG6Qp9U.jpg",
|
||||||
"https://i.imgur.com/JK66QjX.jpg",
|
"https://i.imgur.com/JK66QjX.jpg",
|
||||||
"https://i.imgur.com/fFsF6m7.jpg",
|
"https://i.imgur.com/fFsF6m7.jpg",
|
||||||
"https://i.imgur.com/YqZmeyA.jpg"
|
"https://i.imgur.com/YqZmeyA.jpg",
|
||||||
|
"https://i.imgur.com/StoIQzc.jpg"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
const snekfetch = require('snekfetch');
|
const snekfetch = require('snekfetch');
|
||||||
const { list } = require('../../structures/Util');
|
|
||||||
const { IMGFLIP_USER, IMGFLIP_PASS } = process.env;
|
|
||||||
|
|
||||||
module.exports = class MemeCommand extends Command {
|
module.exports = class MemeCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -16,27 +14,27 @@ module.exports = class MemeCommand extends Command {
|
|||||||
key: 'type',
|
key: 'type',
|
||||||
prompt: 'What meme type do you want to use?',
|
prompt: 'What meme type do you want to use?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
parse: type => type.toLowerCase()
|
parse: type => encodeURIComponent(type)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'top',
|
key: 'top',
|
||||||
prompt: 'What should the top row of the meme to be?',
|
prompt: 'What should the top row of the meme to be?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: ' ',
|
|
||||||
validate: top => {
|
validate: top => {
|
||||||
if (top.length < 200) return true;
|
if (top.length < 200) return true;
|
||||||
return 'Invalid top text, please keep the top text under 200 characters.';
|
return 'Invalid top text, please keep the top text under 200 characters.';
|
||||||
}
|
},
|
||||||
|
parse: top => encodeURIComponent(top)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'bottom',
|
key: 'bottom',
|
||||||
prompt: 'What should the bottom row of the meme to be?',
|
prompt: 'What should the bottom row of the meme to be?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: ' ',
|
|
||||||
validate: bottom => {
|
validate: bottom => {
|
||||||
if (bottom.length < 200) return true;
|
if (bottom.length < 200) return true;
|
||||||
return 'Invalid bottom text, please keep the bottom text under 200 characters.';
|
return 'Invalid bottom text, please keep the bottom text under 200 characters.';
|
||||||
}
|
},
|
||||||
|
parse: bottom => encodeURIComponent(bottom)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -44,22 +42,10 @@ module.exports = class MemeCommand extends Command {
|
|||||||
|
|
||||||
async run(msg, { type, top, bottom }) {
|
async run(msg, { type, top, bottom }) {
|
||||||
try {
|
try {
|
||||||
const memes = await snekfetch.get('https://api.imgflip.com/get_memes');
|
const search = await snekfetch.get(`https://memegen.link/api/search/${type}`);
|
||||||
const memeList = memes.body.data.memes;
|
if (!search.body.length) return msg.say('Could not find any results.');
|
||||||
if (type === 'list') return msg.say(list(memeList.map(meme => meme.name), 'or'), { split: { char: ' ' } });
|
const { body } = await snekfetch.get(search.body[0].template.blank.replace(/\/_/, `/${top}/${bottom}`));
|
||||||
if (!memeList.some(meme => meme.name.toLowerCase() === type)) {
|
return msg.say({ files: [{ attachment: body, name: 'meme.jpg' }] });
|
||||||
return msg.say(`Invalid type, please use ${msg.usage('list')}.`);
|
|
||||||
}
|
|
||||||
const { body } = await snekfetch
|
|
||||||
.post('https://api.imgflip.com/caption_image')
|
|
||||||
.query({
|
|
||||||
template_id: memeList.find(meme => meme.name.toLowerCase() === type).id,
|
|
||||||
username: IMGFLIP_USER,
|
|
||||||
password: IMGFLIP_PASS,
|
|
||||||
text0: top,
|
|
||||||
text1: bottom
|
|
||||||
});
|
|
||||||
return msg.say({ files: [body.data.url] });
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "46.1.2",
|
"version": "46.1.3",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Shard.js",
|
"main": "Shard.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user