glass-shatter, ghost, tax Commands + Bug Fixes

This commit is contained in:
Dragon Fire
2020-04-19 16:23:43 -04:00
parent d24a413785
commit 0a3f632b7a
10 changed files with 147 additions and 7 deletions
+6 -1
View File
@@ -132,7 +132,7 @@ in the appropriate channel's topic to use it.
## Commands ## Commands
Total: 387 Total: 390
### Utility: ### Utility:
@@ -417,6 +417,8 @@ Total: 387
* **distort:** Draws an image or a user's avatar but distorted. * **distort:** Draws an image or a user's avatar but distorted.
* **fire:** Draws a fiery border over an image or a user's avatar. * **fire:** Draws a fiery border over an image or a user's avatar.
* **frame:** Draws a frame around an image or a user's avatar. * **frame:** Draws a frame around an image or a user's avatar.
* **ghost:** Draws an image or a user's avatar but with a ghost-like transparency.
* **glass-shatter:** Draws an image or a user's avatar with a glass shatter in front of it.
* **glitch:** Draws an image or a user's avatar but glitched. * **glitch:** Draws an image or a user's avatar but glitched.
* **greyscale:** Draws an image or a user's avatar in greyscale. * **greyscale:** Draws an image or a user's avatar in greyscale.
* **ifunny:** Draws an image with the iFunny logo. * **ifunny:** Draws an image with the iFunny logo.
@@ -542,6 +544,7 @@ Total: 387
* **prime:** Determines if a number is a prime number. * **prime:** Determines if a number is a prime number.
* **roman:** Converts a number to roman numerals. * **roman:** Converts a number to roman numerals.
* **scientific-notation:** Converts a number to scientific notation. * **scientific-notation:** Converts a number to scientific notation.
* **tax:** Determines the total cost of something plus tax.
* **units:** Converts units to/from other units. * **units:** Converts units to/from other units.
### Other: ### Other:
@@ -961,6 +964,8 @@ here.
* toxicity (API) * toxicity (API)
- [pngimg.com](https://pngimg.com/) - [pngimg.com](https://pngimg.com/)
* thug-life ([Image](http://pngimg.com/download/58231)) * thug-life ([Image](http://pngimg.com/download/58231))
- [Platinum Designz](http://store.platinumdesignz.com/)
* glass-shatter ([Image]('https://www.jing.fm/iclipt/u2q8u2a9o0t4i1q8/))
- [Pokemon Fusion](https://pokemon.alexonsager.net/) - [Pokemon Fusion](https://pokemon.alexonsager.net/)
* pokemon-fusion (Images) * pokemon-fusion (Images)
- [PokéAPI](https://pokeapi.co/) - [PokéAPI](https://pokeapi.co/)
Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

+2 -1
View File
@@ -51,5 +51,6 @@
"The `give-flower` command was the first command added to Xiao.", "The `give-flower` command was the first command added to Xiao.",
"Xiao is the best bot ever.", "Xiao is the best bot ever.",
"Xiao began development in February 2017, and was most likely active sometime in 2016 under a different name.", "Xiao began development in February 2017, and was most likely active sometime in 2016 under a different name.",
"The command with the most lines of code is, oddly enough, `anime`, at 189." "The command with the most lines of code is, oddly enough, `anime`, at 189.",
"The `ship` command gives a special response if the compatability is 69."
] ]
+45
View File
@@ -0,0 +1,45 @@
const Command = require('../../structures/Command');
const { createCanvas, loadImage } = require('canvas');
const request = require('node-superfetch');
module.exports = class GhostCommand extends Command {
constructor(client) {
super(client, {
name: 'ghost',
group: 'edit-image',
memberName: 'ghost',
description: 'Draws an image or a user\'s avatar but with a ghost-like transparency.',
throttling: {
usages: 1,
duration: 10
},
clientPermissions: ['ATTACH_FILES'],
args: [
{
key: 'image',
prompt: 'What image would you like to edit?',
type: 'image',
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
}
]
});
}
async run(msg, { image }) {
try {
const { body } = await request.get(image);
const data = await loadImage(body);
const canvas = createCanvas(data.width, data.height);
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, data.width, data.height);
ctx.globalAlpha = 0.5;
ctx.drawImage(data, 0, 0);
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: 'ghost.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+54
View File
@@ -0,0 +1,54 @@
const Command = require('../../structures/Command');
const { createCanvas, loadImage } = require('canvas');
const request = require('node-superfetch');
const path = require('path');
module.exports = class GlassShatterCommand extends Command {
constructor(client) {
super(client, {
name: 'glass-shatter',
aliases: ['shatter', 'glass'],
group: 'edit-image',
memberName: 'glass-shatter',
description: 'Draws an image or a user\'s avatar with a glass shatter in front of it.',
throttling: {
usages: 1,
duration: 10
},
clientPermissions: ['ATTACH_FILES'],
credit: [
{
name: 'Platinum Designz',
url: 'http://store.platinumdesignz.com/',
reason: 'Image',
reasonURL: 'https://www.jing.fm/iclipt/u2q8u2a9o0t4i1q8/'
}
],
args: [
{
key: 'image',
prompt: 'What image would you like to edit?',
type: 'image',
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
}
]
});
}
async run(msg, { image }) {
try {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'glass-shatter.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);
ctx.drawImage(base, 0, 0, data.width, data.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: 'glass-shatter.png' }] });
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+32
View File
@@ -0,0 +1,32 @@
const Command = require('../../structures/Command');
const { formatNumber } = require('../../util/Util');
module.exports = class TaxCommand extends Command {
constructor(client) {
super(client, {
name: 'tax',
group: 'edit-number',
memberName: 'tax',
description: 'Determines the total cost of something plus tax.',
args: [
{
key: 'rate',
prompt: 'What is the tax rate (in %)?',
type: 'integer',
max: 100,
min: 0
},
{
key: 'amount',
prompt: 'How much money should be converted?',
type: 'float'
},
]
});
}
run(msg, { rate, amount }) {
const result = amount + ((rate / 100) * amount);
return msg.reply(`$${formatNumber(result, 2)}`);
}
};
+1 -1
View File
@@ -44,7 +44,7 @@ module.exports = class AnimeAiringCommand extends Command {
try { try {
const anime = await this.getList(); const anime = await this.getList();
if (!anime) return msg.say('No anime air today...'); if (!anime) return msg.say('No anime air today...');
const mapped = anime.map(ani => { const mapped = anime.sort((a, b) => a.airingAt - b.airingAt).map(ani => {
const title = ani.media.title.english || ani.media.title.romaji; const title = ani.media.title.english || ani.media.title.romaji;
const airingAt = moment(ani.airingAt * 1000).tz('Asia/Tokyo').format('h:mm A'); const airingAt = moment(ani.airingAt * 1000).tz('Asia/Tokyo').format('h:mm A');
return `${title} (@${airingAt} JST)`; return `${title} (@${airingAt} JST)`;
+1 -1
View File
@@ -5,7 +5,7 @@ module.exports = class XiaoFactCommand extends Command {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: 'xiao-fact', name: 'xiao-fact',
aliases: ['iao-fact', 'bot-fact'], aliases: ['iao-fact', 'bot-fact', 'easter-egg'],
group: 'random-res', group: 'random-res',
memberName: 'xiao-fact', memberName: 'xiao-fact',
description: 'Responds with a random fact about Xiao.' description: 'Responds with a random fact about Xiao.'
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xiao", "name": "xiao",
"version": "113.3.0", "version": "113.4.0",
"description": "Your personal server companion.", "description": "Your personal server companion.",
"main": "Xiao.js", "main": "Xiao.js",
"scripts": { "scripts": {
+5 -2
View File
@@ -63,8 +63,11 @@ module.exports = class Util {
return text.split(split).map(word => `${word.charAt(0).toUpperCase()}${word.slice(1)}`).join(' '); return text.split(split).map(word => `${word.charAt(0).toUpperCase()}${word.slice(1)}`).join(' ');
} }
static formatNumber(number) { static formatNumber(number, minimumFractionDigits = 0) {
return Number.parseFloat(number).toLocaleString(undefined, { maximumFractionDigits: 2 }); return Number.parseFloat(number).toLocaleString(undefined, {
minimumFractionDigits,
maximumFractionDigits: 2
});
} }
static base64(text, mode = 'encode') { static base64(text, mode = 'encode') {