Alert and Simp Commands

This commit is contained in:
Dragon Fire
2020-05-22 09:36:29 -04:00
parent 3ad5e2af13
commit 0d489a9006
7 changed files with 136 additions and 2 deletions
+11 -1
View File
@@ -224,7 +224,7 @@ in the appropriate channel's topic to use it.
## Commands
Total: 430
Total: 432
### Utility:
@@ -549,6 +549,7 @@ Total: 430
* **sepia:** Draws an image or a user's avatar in sepia.
* **shields-io-badge:** Creates a badge from shields.io.
* **silhouette:** Draws a silhouette of an image or a user's avatar.
* **simp:** Draws a "simp" stamp over an image or a user's avatar.
* **snapcode:** Responds with the Snapcode of a Snapchat user.
* **square:** Draws an image or a user's avatar as a square.
* **squish:** Draws an image or a user's avatar but squished across the X or Y axis.
@@ -578,6 +579,7 @@ Total: 430
### Meme Generators:
* **3000-years:** Draws an image or a user's avatar over Pokémon's "It's been 3000 years" meme.
* **alert:** Sends a Presidential Alert message with the text of your choice.
* **bart-chalkboard:** Sends a "Bart Chalkboard" meme with the text of your choice.
* **be-like-bill:** Sends a "Be Like Bill" meme with the name of your choice.
* **beautiful:** Draws a user's avatar over Gravity Falls' "Oh, this? This is beautiful." meme.
@@ -784,6 +786,7 @@ here.
- [Antonio Guillem](http://antonioguillem.com/)
* distracted-boyfriend ([Image](https://www.istockphoto.com/photo/gm493656728-77018851))
- [Apple](https://www.apple.com/)
* alert ([San Francisco Font](https://developer.apple.com/fonts/))
* apple-engraving (API)
* itunes ([iTunes Search API](https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/))
- [astrology.TV](https://astrology.tv/)
@@ -1158,6 +1161,9 @@ here.
* jeopardy-question ([Korinna Agency Font](https://fontmeme.com/fonts/korinna-agency-font/))
- [osu!](https://osu.ppy.sh/home)
* osu ([API](https://github.com/ppy/osu-api/wiki))
- [Overtime2005](https://github.com/Overtime2005)
* alert (Concept)
* simp (Concept)
- [PAC-MAN Party](http://pacman.com/en/pac-man-games/pac-man-party)
* balloon-pop (Concept)
- [PaladinsGuru](https://paladins.guru/)
@@ -1283,6 +1289,8 @@ here.
* chi-idea (Original "Teasing Master Takagi-san" Manga)
- [Tenor](https://tenor.com/)
* tenor ([API](https://tenor.com/gifapi/documentation))
- [The Hill](https://thehill.com/)
* alert ([Image](https://thehill.com/policy/technology/409737-this-is-a-test-us-officials-test-presidential-alert))
- [The Internet Chuck Norris Database](http://www.icndb.com/)
* chuck-norris ([API](http://www.icndb.com/api/))
- [The Melancholy of Haruhi Suzumiya](http://www.haruhi.tv/)
@@ -1353,6 +1361,8 @@ here.
* wikipedia ([API](https://en.wikipedia.org/w/api.php))
- [Will You Press The Button?](https://willyoupressthebutton.com/)
* will-you-press-the-button (Dilemma Data)
- [World of Tanks](https://worldoftanks.com/)
* simp ([Image](https://worldoftanks.com/es-ar/content/silver-league/open-standings/))
- [www.aljanh.net](http://www.aljanh.net/)
* frame ([Image](http://www.aljanh.net/frame-wallpapers/1508614706.html))
- [xertris](https://www.deviantart.com/xertris)
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

+60
View File
@@ -0,0 +1,60 @@
const Command = require('../../structures/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: 1,
duration: 10
},
clientPermissions: ['ATTACH_FILES'],
credit: [
{
name: 'Overtime2005',
url: 'https://github.com/Overtime2005',
reason: 'Concept'
},
{
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',
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!`);
}
}
};
+64
View File
@@ -0,0 +1,64 @@
const Command = require('../../structures/Command');
const { createCanvas, loadImage, registerFont } = require('canvas');
const path = require('path');
const { wrapText } = require('../../util/Canvas');
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'SF-Pro-Display-Medium.otf'), { family: 'SF Pro' });
module.exports = class AlertCommand extends Command {
constructor(client) {
super(client, {
name: 'alert',
aliases: ['presidential-alert'],
group: 'edit-meme',
memberName: 'alert',
description: 'Sends a Presidential Alert message with the text of your choice.',
throttling: {
usages: 1,
duration: 10
},
clientPermissions: ['ATTACH_FILES'],
credit: [
{
name: 'Overtime2005',
url: 'https://github.com/Overtime2005',
reason: 'Concept'
},
{
name: 'Apple',
url: 'https://www.apple.com/',
reason: 'San Francisco Font',
reasonURL: 'https://developer.apple.com/fonts/'
},
{
name: 'The Hill',
url: 'https://thehill.com/',
reason: 'Image',
// eslint-disable-next-line max-len
reasonURL: 'https://thehill.com/policy/technology/409737-this-is-a-test-us-officials-test-presidential-alert'
}
],
args: [
{
key: 'message',
prompt: 'What should the alert say?',
type: 'string',
max: 280
}
]
});
}
async run(msg, { message }) {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'alert.png'));
const canvas = createCanvas(base.width, base.height);
const ctx = canvas.getContext('2d');
ctx.drawImage(base, 0, 0);
ctx.font = '28px SF Pro';
ctx.fillStyle = 'black';
ctx.textBaseline = 'top';
let text = await wrapText(ctx, quote, 540);
text = text.length > 3 ? `${text.slice(0, 3).join('\n')}...` : text.join('\n');
ctx.fillText(text, 47, 186);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'alert.png' }] });
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "114.19.0",
"version": "114.20.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {