commit 754b639db85928785312df94894c2a855f407abd
parent 81d583277c20e4cd96d4391c3135189222000a7c
Author: Bruno <b-coimbra@hotmail.com>
Date: Sun, 22 Mar 2020 10:14:09 -0300
Update pat.ts
Diffstat:
M | lib/commands/pat.ts | | | 78 | +++++++++++++++++++++++++++++++++++++++--------------------------------------- |
1 file changed, 39 insertions(+), 39 deletions(-)
diff --git a/lib/commands/pat.ts b/lib/commands/pat.ts
@@ -6,59 +6,59 @@ import Jimp from 'jimp';
const TEMPLATE = "./lib/resources/pat-template.png";
interface Scope {
- message: Message;
- args: any;
+ message: Message;
+ args: any;
}
export default (home_scope: Scope) => {
const { message, args } = home_scope;
- if (args.length == 0) {
- message.channel.send(
- "Pat someone!\n" + ".pat [@user-name]".format(FORMATS.block)
- );
- }
+ if (args.length == 0) {
+ message.channel.send(
+ "Pat someone!\n" + ".pat [@user-name]".format(FORMATS.block)
+ );
+ }
- const size = 200;
- const [x, y] = [200, 108];
- const filename = "patted.png";
+ const size = 200;
+ const [x, y] = [200, 108];
+ const filename = "patted.png";
- const description =
- `${message.mentions.users.first().username}`.format(FORMATS.bold)
- + ', you got a pat from '
- + `${message.author.username}`.format(FORMATS.bold)
- + ' :blush:';
+ const description =
+ `${message.mentions.users.first().username}`.format(FORMATS.bold)
+ + ', you got a pat from '
+ + `${message.author.username}`.format(FORMATS.bold)
+ + ' :blush:';
- const pat = async (image: string) => {
- const template = await Jimp.read(TEMPLATE);
- const img = await Jimp.read(image);
- const composed = template.composite(
- img.resize(Jimp.AUTO, size), x, y,
- {
- mode: Jimp.BLEND_DESTINATION_OVER,
- opacityDest: 1,
- opacitySource: 1
- });
+ const pat = async (image: string) => {
+ const template = await Jimp.read(TEMPLATE);
+ const img = await Jimp.read(image);
+ const composed = template.composite(
+ img.resize(Jimp.AUTO, size), x, y,
+ {
+ mode: Jimp.BLEND_DESTINATION_OVER,
+ opacityDest: 1,
+ opacitySource: 1
+ });
- composed.getBuffer(Jimp.MIME_PNG, (e : Error, buffer: Buffer) => {
- if (e?.message) {
- message.channel.send(
- `Unable to pat ${message.mentions.users.first().username} :(`
- );
- return;
- }
+ composed.getBuffer(Jimp.MIME_PNG, (e : Error, buffer: Buffer) => {
+ if (e?.message) {
+ message.channel.send(
+ `Unable to pat ${message.mentions.users.first().username} :(`
+ );
+ return;
+ }
- const attachment = new Attachment(buffer, filename);
+ const attachment = new Attachment(buffer, filename);
const embed = new RichEmbed()
.setColor('#b943e8')
- .setTitle("Incoming pat")
+ .setTitle("Incoming pat")
.setDescription(description)
- .attachFile(attachment)
+ .attachFile(attachment)
.setImage(`attachment://${filename}`);
- message.channel.send(embed);
- });
- };
+ message.channel.send(embed);
+ });
+ };
- pat(message.mentions.users.first().avatarURL);
+ pat(message.mentions.users.first().avatarURL);
};