Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.run = async (client, message, args) => { // eslint-disable-line no-unused-vars
const qrOutput = tempy.file({ extension: "png" });
message.channel.startTyping();
if (args.length > 0) {
qrcode.toFile(qrOutput, args.join(" "), { margin: 1 }, (error) => {
if (error) throw new Error(error);
message.channel.stopTyping();
message.channel.send({
files: [{
attachment: qrOutput,
name: "qr.png"
}]
});
});
} else {
message.channel.stopTyping();
message.reply("you need to provide some text to generate a QR code!");
}
};
if (authToken.ip === process.argv[2]) {
createToken = false;
}
} catch(e) {
createToken = true;
}
if (createToken) {
const token = crypto.randomBytes(24).toString('base64');
const auth = {
ip: process.argv[2],
ipExternal: process.argv[3],
token: token
};
const auth_str = JSON.stringify(auth);
proms.push(QRCode.toFile('certs/qrcode.png', auth_str, {}));
proms.push(new Promise((resolve, reject) => {
fs.writeFile('certs/container-mananager-auth.json', auth_str, function (err) {
if (err) reject(err);
else resolve();
});
}));
}
return Promise.all(proms);
})
.then(() => {
.then((address) => {
debug("going to show following address \n", address)
const tmpfile = path.join('/tmp', address + ".png")
QRCode.toFile(tmpfile, address, (err) => {
if (err) throw err;
bot.api.files.upload({
file: fs.createReadStream(tmpfile),
filename: "please_pay_to_this_address" + ".png",
title: address + ".png",
initial_comment: locale_message.deposit.file_comment,
channels: message.channel
}, (err, res) => {
if (err) bot.reply(err)
debug("result is ", res);
})
bot.reply(message, locale_message.deposit.msg_with_qrcode)
bot.reply(message, address)
})
const saveQrcode2Local = string => {
const filename = `arya-qrcode-${getDate()}.png`
qrcode.toFile(
filename,
string,
{
width: 300,
height: 300,
color: {
dark: '#000000ff',
light: '#0000'
}
},
err => {
if (err) throw err
print(`success`, '✓ Okay, Has successfully generate & save your qrcode.')
}
)
}