mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
5 New Commands
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class PixelizeCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'pixelize',
|
||||
group: 'avatar-edit',
|
||||
memberName: 'pixelize',
|
||||
description: 'Draws a user\'s avatar pixelized.',
|
||||
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: 64
|
||||
});
|
||||
try {
|
||||
const canvas = createCanvas(256, 256);
|
||||
const ctx = canvas.getContext('2d');
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
ctx.imageSmoothingEnabled = false;
|
||||
ctx.drawImage(avatar, 0, 0, 256, 256);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'pixelize.png' }] });
|
||||
} catch (err) {
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const crypto = require('crypto');
|
||||
|
||||
module.exports = class SecurityKeyCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'security-key',
|
||||
group: 'random-res',
|
||||
memberName: 'security-key',
|
||||
description: 'Generates a random security key.'
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
return msg.say(crypto.randomBytes(15).toString('hex'));
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const gifs = [
|
||||
'https://i.imgur.com/wXShFlF.gif',
|
||||
'https://i.imgur.com/bpBz27N.gif',
|
||||
'https://i.imgur.com/61vX6F6.gif',
|
||||
'https://i.imgur.com/6zv7HP5.gif',
|
||||
'https://i.imgur.com/ExYfGm8.gif'
|
||||
];
|
||||
|
||||
module.exports = class TackleCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'tackle',
|
||||
aliases: ['glomp', 'tackle-hug'],
|
||||
group: 'roleplay',
|
||||
memberName: 'tackle',
|
||||
description: 'Tackles a user.',
|
||||
args: [
|
||||
{
|
||||
key: 'user',
|
||||
prompt: 'What user do you want to roleplay with?',
|
||||
type: 'user'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, { user }) {
|
||||
return msg.say(stripIndents`
|
||||
**${msg.author.username}** *tackles* **${user.username}**
|
||||
${gifs[Math.floor(Math.random() * gifs.length)]}
|
||||
`);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
|
||||
module.exports = class IPInfoCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'ip-info',
|
||||
group: 'search',
|
||||
memberName: 'ip-info',
|
||||
description: 'Gets data for an IP address.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'ip',
|
||||
prompt: 'Which IP would you like to get information on?',
|
||||
type: 'string',
|
||||
parse: ip => encodeURIComponent(ip)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { ip }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`https://ipinfo.io/${ip}/json`);
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setURL(`https://ipinfo.io/${ip}`)
|
||||
.setTitle(body.ip)
|
||||
.addField('❯ Hostname',
|
||||
body.hostname, true)
|
||||
.addField('❯ Location',
|
||||
body.loc, true)
|
||||
.addField('❯ Organization',
|
||||
body.org, true)
|
||||
.addField('❯ City',
|
||||
`${body.city} (${body.postal})`, true)
|
||||
.addField('❯ Region',
|
||||
body.region, true)
|
||||
.addField('❯ Country',
|
||||
body.country, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
if (err.status === 404) return msg.say('Could not find any results.');
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { xml2json } = require('xml-js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class SafebooruCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'safebooru',
|
||||
group: 'search',
|
||||
memberName: 'safebooru',
|
||||
description: 'Searches Safebooru for your query.',
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What image would you like to search for?',
|
||||
type: 'string',
|
||||
default: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { text } = await snekfetch
|
||||
.get('https://safebooru.org/index.php')
|
||||
.query({
|
||||
page: 'dapi',
|
||||
s: 'post',
|
||||
q: 'index',
|
||||
tags: query
|
||||
});
|
||||
const parsed = xml2json(text, { compact: true });
|
||||
if (parsed.posts.count === '0' || !parsed.posts.post.length) return msg.say('Could not find any results.');
|
||||
const posts = msg.channel.nsfw ? parsed.posts.post : parsed.posts.post.filter(post => post.rating === 's');
|
||||
return msg.say(stripIndents`
|
||||
${query ? `Results for ${query}:` : 'Random Image:'}
|
||||
https:${posts[Math.floor(Math.random() * posts.length)].file_url}
|
||||
`);
|
||||
} catch (err) {
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "42.5.1",
|
||||
"version": "42.6.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Shard.js",
|
||||
"scripts": {
|
||||
@@ -44,6 +44,7 @@
|
||||
"sequelize": "^4.10.2",
|
||||
"snekfetch": "^3.3.1",
|
||||
"uws": "^8.14.1",
|
||||
"xml-js": "^1.4.2",
|
||||
"zalgolize": "^1.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
Reference in New Issue
Block a user