diff --git a/commands/avataredit/steamcard.js b/commands/avataredit/steamcard.js new file mode 100644 index 00000000..f4a2de9a --- /dev/null +++ b/commands/avataredit/steamcard.js @@ -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; \ No newline at end of file diff --git a/images/SteamCard.png b/images/SteamCard.png new file mode 100644 index 00000000..6b9437f8 Binary files /dev/null and b/images/SteamCard.png differ diff --git a/images/SteamCardBlank.png b/images/SteamCardBlank.png new file mode 100644 index 00000000..f916e29c Binary files /dev/null and b/images/SteamCardBlank.png differ diff --git a/index.js b/index.js index 0b6e48b7..24868fee 100644 --- a/index.js +++ b/index.js @@ -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); \ No newline at end of file diff --git a/package.json b/package.json index ddc08669..7c11910a 100644 --- a/package.json +++ b/package.json @@ -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",