Added Steam Card Command

This commit is contained in:
dragonfire535
2017-03-12 18:45:15 -04:00
parent e287e788d3
commit a182d70ba7
5 changed files with 62 additions and 3 deletions
+57
View File
@@ -0,0 +1,57 @@
const commando = require('discord.js-commando');
const Jimp = require("jimp");
class SteamCardCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'steamcard',
group: 'avataredit',
memberName: 'steamcard',
description: "Put an avatar on a Steam Card. (;steamcard @User)",
examples: [';steamcard @user']
});
}
async run(message, args) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES')) return;
}
console.log("[Command] " + message.content);
if(message.channel.type !== 'dm') {
if (message.mentions.users.size !== 1) {
message.channel.sendMessage(':x: Either too many or no members, only mention one person!');
} else {
if(message.mentions.users.first().avatarURL === null) {
message.channel.sendMessage(":x: This person has no avatar!");
} else {
let userdisplayname = message.guild.member(message.mentions.users.first()).displayName;
let avatarurl = message.mentions.users.first().avatarURL;
avatarurl = avatarurl.replace(".jpg", ".png");
avatarurl = avatarurl.replace(".gif", ".png");
let images = [];
images.push(Jimp.read(avatarurl));
images.push(Jimp.read("./images/SteamCard.png"));
images.push(Jimp.read("./images/SteamCardBlank.png"));
Promise.all(images).then(([avatar, steamcard, nothing]) => {
Jimp.loadFont(Jimp.FONT_SANS_32_WHITE).then(function (font) {
avatar.resize(450, 450);
nothing.composite(avatar, 25, 25);
nothing.composite(steamcard, 0, 0);
nothing.print(font, 38, 20, userdisplayname);
nothing.getBuffer(Jimp.MIME_PNG, (err, buff) => {
if (err) throw err;
message.channel.sendFile(buff);
});
});
});
}
}
} else {
message.channel.sendMessage(':x: Error! This command does not work in DM!');
}
}
}
module.exports = SteamCardCommand;
Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

+3 -3
View File
@@ -190,8 +190,8 @@ client.once('ready', () => {
client.user.setGame(";help | dragonfire535");
});
process.on('unhandledRejection', function(reason, p){
console.log("A Possibly Unhandled Rejection has Occurred.");
});
//process.on('unhandledRejection', function(reason, p){
// console.log("A Possibly Unhandled Rejection has Occurred.");
//});
client.login(config.token);
+2
View File
@@ -19,6 +19,8 @@
"cleverbot-node": "^0.3.5",
"discord.js": "github:hydrabolt/discord.js",
"discord.js-commando": "^0.9.0",
"google": "^2.1.0",
"google-search-scraper-fake-user-agent": "0.0.5",
"google-translate-api": "^2.2.2",
"hepburn": "^1.0.0",
"imdb-api": "^2.2.1",