mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 06:42:50 +02:00
5 New Commands
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 166 KiB |
@@ -0,0 +1,50 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const { createCanvas, loadImage } = require('canvas');
|
||||||
|
const snekfetch = require('snekfetch');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
module.exports = class PhotographCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'photograph',
|
||||||
|
group: 'avatar-edit',
|
||||||
|
memberName: 'photograph',
|
||||||
|
description: 'Draws a user\'s avatar over a photograph.',
|
||||||
|
throttling: {
|
||||||
|
usages: 1,
|
||||||
|
duration: 15
|
||||||
|
},
|
||||||
|
clientPermissions: ['ATTACH_FILES'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'user',
|
||||||
|
prompt: 'Which user would you like to edit the avatar of?',
|
||||||
|
type: 'user',
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { user }) {
|
||||||
|
if (!user) user = msg.author;
|
||||||
|
const avatarURL = user.displayAvatarURL({
|
||||||
|
format: 'png',
|
||||||
|
size: 256
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
const canvas = createCanvas(625, 417);
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'photograph.png'));
|
||||||
|
const { body } = await snekfetch.get(avatarURL);
|
||||||
|
const avatar = await loadImage(body);
|
||||||
|
ctx.drawImage(base, 0, 0);
|
||||||
|
ctx.rotate(-8.21 * (Math.PI / 180));
|
||||||
|
ctx.drawImage(avatar, 96, 83, 175, 175);
|
||||||
|
ctx.rotate(8.21 * (Math.PI / 180));
|
||||||
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'photograph.png' }] });
|
||||||
|
} catch (err) {
|
||||||
|
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
|
||||||
|
module.exports = class RobohashCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'robohash',
|
||||||
|
group: 'image-edit',
|
||||||
|
memberName: 'robohash',
|
||||||
|
description: 'Creates a robot based on the text you provide.',
|
||||||
|
clientPermissions: ['ATTACH_FILES'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'text',
|
||||||
|
prompt: 'What text should be used for generation?',
|
||||||
|
type: 'string',
|
||||||
|
parse: text => encodeURIComponent(text)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
run(msg, { text }) {
|
||||||
|
return msg.say({ files: [`https://robohash.org/${text}`] });
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const snekfetch = require('snekfetch');
|
||||||
|
|
||||||
|
module.exports = class GenderCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'gender',
|
||||||
|
group: 'random',
|
||||||
|
memberName: 'gender',
|
||||||
|
description: 'Determines the gender of name.',
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'name',
|
||||||
|
prompt: 'What name do you want to determine the gender of?',
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { name }) {
|
||||||
|
try {
|
||||||
|
const { body } = await snekfetch
|
||||||
|
.get('https://api.genderize.io/')
|
||||||
|
.query({ name });
|
||||||
|
if (!body.gender) return msg.say(`I have no idea what gender ${body.name} is.`);
|
||||||
|
return msg.say(`I'm ${Math.round(body.probability * 100)}% sure ${body.name} is a ${body.gender} name.`);
|
||||||
|
} catch (err) {
|
||||||
|
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const snekfetch = require('snekfetch');
|
||||||
|
|
||||||
|
module.exports = class DerpibooruCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'derpibooru',
|
||||||
|
aliases: ['my-little-pony-image', 'mlp-image'],
|
||||||
|
group: 'search',
|
||||||
|
memberName: 'derpibooru',
|
||||||
|
description: 'Searches Derpibooru for your query.',
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'query',
|
||||||
|
prompt: 'What image would you like to search for?',
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { query }) {
|
||||||
|
try {
|
||||||
|
const search = await snekfetch
|
||||||
|
.get('https://derpibooru.org/search.json')
|
||||||
|
.query({
|
||||||
|
q: query,
|
||||||
|
random_image: 1
|
||||||
|
});
|
||||||
|
if (!search.body) return msg.say('Could not find any results.');
|
||||||
|
const { body } = await snekfetch
|
||||||
|
.get(`https://derpibooru.org/images/${search.body.id}.json`);
|
||||||
|
if (!msg.channel.nsfw && body.tags.includes('suggestive')) {
|
||||||
|
return msg.say('This image is only viewable in NSFW channels.');
|
||||||
|
}
|
||||||
|
return msg.say(`https:${body.representations.large}`);
|
||||||
|
} catch (err) {
|
||||||
|
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
const snekfetch = require('snekfetch');
|
||||||
|
|
||||||
|
module.exports = class JapaneseDictionaryCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'japanese-dictionary',
|
||||||
|
aliases: ['japanese-define', 'define-japanese', 'define-jpn', 'jpn-define', 'jisho'],
|
||||||
|
group: 'search',
|
||||||
|
memberName: 'define',
|
||||||
|
description: 'Defines a word, but with Japanese.',
|
||||||
|
clientPermissions: ['EMBED_LINKS'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'query',
|
||||||
|
prompt: 'What would you like to define?',
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { query }) {
|
||||||
|
try {
|
||||||
|
const { body } = await snekfetch
|
||||||
|
.get('http://jisho.org/api/v1/search/words')
|
||||||
|
.query({ keyword: query });
|
||||||
|
if (!body.data.length) return msg.say('Could not find any results.');
|
||||||
|
const data = body.data[0];
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setColor(0x9797FF)
|
||||||
|
.setTitle(data.japanese[0].word)
|
||||||
|
.setDescription(data.senses[0].english_definitions.join(', '));
|
||||||
|
return msg.embed(embed);
|
||||||
|
} catch (err) {
|
||||||
|
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "42.10.1",
|
"version": "42.11.0",
|
||||||
"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