2019-09-13 20:02:41 +00:00
|
|
|
const qrcode = require("qrcode");
|
|
|
|
const stream = require("stream");
|
|
|
|
|
2020-01-13 16:31:01 +00:00
|
|
|
exports.run = async (message, args, content) => {
|
2019-09-13 20:02:41 +00:00
|
|
|
if (args.length === 0) return `${message.author.mention}, you need to provide some text to generate a QR code!`;
|
|
|
|
message.channel.sendTyping();
|
|
|
|
const writable = new stream.PassThrough();
|
2020-01-13 16:31:01 +00:00
|
|
|
qrcode.toFileStream(writable, content, { margin: 1 });
|
2019-09-13 20:02:41 +00:00
|
|
|
const chunks = [];
|
|
|
|
writable.on("data", (chunk) => {
|
|
|
|
chunks.push(chunk);
|
|
|
|
});
|
|
|
|
writable.once("error", (error) => {
|
2019-12-10 15:53:43 +00:00
|
|
|
if (error) throw error;
|
2019-09-13 20:02:41 +00:00
|
|
|
});
|
|
|
|
writable.once("end", () => {
|
2020-04-12 19:51:48 +00:00
|
|
|
return {
|
2020-02-13 20:31:40 +00:00
|
|
|
file: Buffer.concat(chunks),
|
2019-09-13 20:02:41 +00:00
|
|
|
name: "qr.png"
|
2020-04-12 19:51:48 +00:00
|
|
|
};
|
2019-09-13 20:02:41 +00:00
|
|
|
});
|
2019-12-02 20:47:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.category = 1;
|
2019-12-05 16:58:46 +00:00
|
|
|
exports.help = "Generates a QR code";
|
|
|
|
exports.params = "[text]";
|