mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Add loading to fire
This commit is contained in:
@@ -7,6 +7,7 @@ const path = require('path');
|
||||
const { streamToArray } = require('../../util/Util');
|
||||
const { drawImageWithTint } = require('../../util/Canvas');
|
||||
const frameCount = 46;
|
||||
const { LOADING_EMOJI_ID, SUCCESS_EMOJI_ID } = process.env;
|
||||
|
||||
module.exports = class FireCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -41,6 +42,7 @@ module.exports = class FireCommand extends Command {
|
||||
|
||||
async run(msg, { user }) {
|
||||
const avatarURL = user.displayAvatarURL({ extension: 'png', size: 256 });
|
||||
await reactIfAble(msg, msg.author, LOADING_EMOJI_ID, '💬');
|
||||
const { body } = await request.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const encoder = new GIFEncoder(avatar.width, avatar.height);
|
||||
@@ -61,6 +63,7 @@ module.exports = class FireCommand extends Command {
|
||||
}
|
||||
encoder.finish();
|
||||
const buffer = await streamToArray(stream);
|
||||
reactIfAble(msg, msg.author, SUCCESS_EMOJI_ID, '✅');
|
||||
return msg.say({ files: [{ attachment: Buffer.concat(buffer), name: 'fire.gif' }] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ const GIFEncoder = require('gifencoder');
|
||||
const request = require('node-superfetch');
|
||||
const path = require('path');
|
||||
const { streamToArray, reactIfAble } = require('../../util/Util');
|
||||
const { distort, drawImageWithTint } = require('../../util/Canvas');
|
||||
const { distort } = require('../../util/Canvas');
|
||||
const { LOADING_EMOJI_ID, SUCCESS_EMOJI_ID } = process.env;
|
||||
const frameCount = 249;
|
||||
|
||||
@@ -61,7 +61,7 @@ module.exports = class MatrixCommand extends Command {
|
||||
encoder.setQuality(10);
|
||||
const distortedCanvas = createCanvas(avatar.width, avatar.height);
|
||||
const distortedCtx = distortedCanvas.getContext('2d');
|
||||
drawImageWithTint(distortedCtx, avatar, 'black', 0, 0, avatar.width, avatar.height);
|
||||
ctx.drawImage(avatar, 0, 0);
|
||||
distort(distortedCtx, 20, 0, 0, avatar.width, avatar.height, 5);
|
||||
for (let i = 0; i < frameCount; i++) {
|
||||
const frame = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'matrix', `frame-${i}.gif`));
|
||||
|
||||
Reference in New Issue
Block a user