From 6c3388d460435cdbd1588b083053bdd8a4db6b2e Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Thu, 11 May 2017 00:26:11 +0000 Subject: [PATCH] Better User Info Command --- commands/avataredit/steamcard.js | 3 +-- commands/userinfo/userinfo.js | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/commands/avataredit/steamcard.js b/commands/avataredit/steamcard.js index 6c440dde..c7ed532f 100644 --- a/commands/avataredit/steamcard.js +++ b/commands/avataredit/steamcard.js @@ -25,7 +25,7 @@ module.exports = class SteamCardCommand extends Command { if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return msg.say('This Command requires the `Attach Files` Permission.'); const { user } = args; - const username = msg.guild ? msg.guild.member(user).displayName : user.username; + let username = msg.guild ? (msg.guild.member(user) ? msg.guild.member(user).displayName : user.username) : user.username; const avatarURL = user.avatarURL('png', 2048); if (!avatarURL) return msg.say('This user has no avatar.'); try { @@ -41,7 +41,6 @@ module.exports = class SteamCardCommand extends Command { ctx.drawImage(avatar, 25, 25, 450, 450); ctx.drawImage(base, 0, 0); ctx.font = '30px Open Sans'; - ctx.fillStyle = 'white'; ctx.fillText(username, 35, 48); }; const cardImg = await request diff --git a/commands/userinfo/userinfo.js b/commands/userinfo/userinfo.js index e8f09963..b0f9052e 100644 --- a/commands/userinfo/userinfo.js +++ b/commands/userinfo/userinfo.js @@ -15,9 +15,9 @@ module.exports = class UserInfoCommand extends Command { guildOnly: true, args: [ { - key: 'user', + key: 'member', prompt: 'Which user would you like to get info on?', - type: 'user' + type: 'member' } ] }); @@ -27,11 +27,10 @@ module.exports = class UserInfoCommand extends Command { if (msg.channel.type !== 'dm') if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); - const { user } = args; - const member = msg.guild.member(user); + const { member } = args; let stat; let color; - switch(user.presence.status) { + switch(member.user.presence.status) { case 'online': stat = '<:vpOnline:212789758110334977> Online'; color = 0x00AE86; @@ -51,25 +50,25 @@ module.exports = class UserInfoCommand extends Command { } const embed = new RichEmbed() .setColor(color) - .setThumbnail(user.displayAvatarURL) + .setThumbnail(member.user.displayAvatarURL) .addField('**Name:**', - user.tag, true) + member.user.tag, true) .addField('**ID:**', - user.id, true) + member.id, true) .addField('**Joined Discord On:**', stripIndents` - ${user.createdAt} - ${moment.duration(Date.now() - user.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago. + ${moment(member.user.createdTimestamp).format('MMMM Do YYYY h:mm:ss a')} + ${moment.duration(Date.now() - member.user.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago. `, true) .addField('**Joined Server On:**', stripIndents` - ${member.joinedAt} + ${moment(member.joinedTimestamp).format('MMMM Do YYYY h:mm:ss a')} ${moment.duration(Date.now() - member.joinedTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago. `, true) .addField('**Status:**', stat, true) .addField('**Playing:**', - user.presence.game ? user.presence.game.name : 'None', true); + member.user.presence.game ? member.user.presence.game.name : 'None', true); return msg.embed(embed); } };