Haha-Yes/commands/fun/print.js

34 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-11-21 01:33:53 +01:00
const { Command } = require('discord.js-commando');
const printer = require('printer');
module.exports = class printCommand extends Command {
constructor(client) {
super(client, {
name: 'print',
2018-11-21 01:56:40 +01:00
group: 'fun',
2018-11-21 01:33:53 +01:00
memberName: 'print',
2018-11-21 01:56:40 +01:00
description: 'print whatever you want using the dev printer ! ( yea really, send a feedback requesting the image and i\'il send it to you.',
throttling: {
usages: 1,
duration: 86400,
},
2018-11-21 01:33:53 +01:00
args: [
{
key: 'text',
2018-11-21 01:56:40 +01:00
prompt: 'What do you want to print? ( text only )',
2018-11-21 01:33:53 +01:00
type: 'string',
}
]
});
}
async run(message, { text }) {
2018-11-21 19:33:37 +01:00
printer.printDirect({data:`Printed by: ${message.author.username}\n\n${text}`
2018-11-21 01:33:53 +01:00
, type: 'TEXT' // type: RAW, TEXT, PDF, JPEG, .. depends on platform
, success:function(jobID){
2018-11-21 02:21:19 +01:00
console.log("sent to printer with ID: "+jobID);
2018-11-21 15:58:04 +01:00
message.say("Printing now!")
2018-11-21 01:33:53 +01:00
}
2018-11-21 16:54:15 +01:00
, error:function(err){console.log(err); message.say("An error has occured, the printer is most likely disconnected, try again later")}
2018-11-21 01:33:53 +01:00
});
}
};