mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-04 07:46:43 +02:00
Fix user
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB |
@@ -1,55 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { list } = require('../../util/Util');
|
||||
const types = ['face', 'front', 'frontfull', 'head', 'bust', 'full', 'skin'];
|
||||
|
||||
module.exports = class MinecraftSkinCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'minecraft-skin',
|
||||
aliases: ['mc-skin'],
|
||||
group: 'edit-image',
|
||||
memberName: 'minecraft-skin',
|
||||
description: 'Sends the Minecraft skin for a user.',
|
||||
details: `**Types:** ${types.join(', ')}`,
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Mojang',
|
||||
url: 'https://www.mojang.com/',
|
||||
reason: 'API, Original "Minecraft" Game',
|
||||
reasonURL: 'https://wiki.vg/Mojang_API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'user',
|
||||
prompt: 'What user would you like to get the skin of?',
|
||||
type: 'string',
|
||||
parse: user => encodeURIComponent(user)
|
||||
},
|
||||
{
|
||||
key: 'type',
|
||||
prompt: `What type should the skin be rendered in? Either ${list(types, 'or')}.`,
|
||||
type: 'string',
|
||||
default: 'full',
|
||||
validate: type => {
|
||||
if (types.includes(type.toLowerCase())) return true;
|
||||
return `Invalid type, please enter either ${list(types, 'or')}.`;
|
||||
},
|
||||
parse: type => type.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { user, type }) {
|
||||
try {
|
||||
const search = await request.get(`https://api.mojang.com/users/profiles/minecraft/${user}`);
|
||||
if (search.status === 204) return msg.say('Could not find any results.');
|
||||
return msg.say({ files: [`https://visage.surgeplay.com/${type}/512/${search.body.id}.png`] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,55 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
const { centerImage } = require('../../util/Canvas');
|
||||
|
||||
module.exports = class SimpCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'simp',
|
||||
group: 'edit-image',
|
||||
memberName: 'simp',
|
||||
description: 'Draws a "simp" stamp over an image or a user\'s avatar.',
|
||||
throttling: {
|
||||
usages: 2,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'World of Tanks',
|
||||
url: 'https://worldoftanks.com/',
|
||||
reason: 'Image',
|
||||
reasonURL: 'https://worldoftanks.com/es-ar/content/silver-league/open-standings/'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image-or-avatar',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'simp.png'));
|
||||
const { body } = await request.get(image);
|
||||
const data = await loadImage(body);
|
||||
const canvas = createCanvas(data.width, data.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(data, 0, 0);
|
||||
const { x, y, width, height } = centerImage(base, data);
|
||||
ctx.drawImage(base, x, y, width, height);
|
||||
const attachment = canvas.toBuffer();
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'simp.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -37,12 +37,14 @@ module.exports = class SketchCommand extends Command {
|
||||
async run(msg, { image }) {
|
||||
try {
|
||||
const { body } = await request.get(image);
|
||||
await reactIfAble(msg, this.client.user, LOADING_EMOJI_ID, '💬');
|
||||
const magik = gm(body);
|
||||
magik.colorspace('gray');
|
||||
magik.out('-sketch');
|
||||
magik.out('0x20+120');
|
||||
magik.setFormat('png');
|
||||
const attachment = await magikToBuffer(magik);
|
||||
reactIfAble(res, res.author, SUCCESS_EMOJI_ID, '✅');
|
||||
if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.');
|
||||
return msg.say({ files: [{ attachment, name: 'sketch.png' }] });
|
||||
} catch (err) {
|
||||
|
||||
@@ -49,5 +49,5 @@ function memberFilterExact(search) {
|
||||
function memberFilterInexact(search) {
|
||||
return mem => mem.user.username.toLowerCase().includes(search)
|
||||
|| (mem.nickname && mem.nickname.toLowerCase().includes(search))
|
||||
|| mem.tag.toLowerCase().includes(search);
|
||||
|| mem.user.tag.toLowerCase().includes(search);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user