Haha-Yes/commands/fun/print.js

43 lines
1.8 KiB
JavaScript
Raw Normal View History

2018-11-21 01:33:53 +01:00
const { Command } = require('discord.js-commando');
const printer = require('printer');
2018-11-28 00:10:14 +01:00
const { printChannel } = require('../../config.json');
2018-11-28 01:35:26 +01:00
const SelfReloadJSON = require('self-reload-json');
2018-12-05 00:52:21 +01:00
module.exports = class printCommand extends Command {
2018-11-21 01:33:53 +01:00
constructor(client) {
super(client, {
name: 'print',
2018-11-22 20:52:20 +01:00
aliases: ['dundermifflin', 'wastedevinkandmoney'],
2018-11-21 01:56:40 +01:00
group: 'fun',
2018-11-21 01:33:53 +01:00
memberName: 'print',
2018-11-22 20:35:57 +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. )',
2018-11-21 01:56:40 +01:00
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-12-05 00:57:44 +01:00
let blacklistJson = new SelfReloadJSON('DiscordBot/json/blacklist.json');
2018-11-28 01:35:26 +01:00
if(blacklistJson[message.author.id])
return blacklist(blacklistJson[message.author.id] , message)
2018-11-28 00:10:14 +01:00
2018-11-22 20:35:57 +01:00
const channel = this.client.channels.get(printChannel);
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-22 20:28:27 +01:00
message.say("Printing now! ( You will receive your print shortly ( if the dev isint sleeping that is ))");
2018-11-22 20:44:20 +01:00
channel.send(`${message.author.username} (${message.author.id}) Asked for a print with the following text: ${text}`);
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
});
}
};