Better User Info Command

This commit is contained in:
Daniel Odendahl Jr
2017-05-11 00:26:11 +00:00
parent c929babc5f
commit 6c3388d460
2 changed files with 12 additions and 14 deletions
+1 -2
View File
@@ -25,7 +25,7 @@ module.exports = class SteamCardCommand extends Command {
if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES'))
return msg.say('This Command requires the `Attach Files` Permission.'); return msg.say('This Command requires the `Attach Files` Permission.');
const { user } = args; 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); const avatarURL = user.avatarURL('png', 2048);
if (!avatarURL) return msg.say('This user has no avatar.'); if (!avatarURL) return msg.say('This user has no avatar.');
try { try {
@@ -41,7 +41,6 @@ module.exports = class SteamCardCommand extends Command {
ctx.drawImage(avatar, 25, 25, 450, 450); ctx.drawImage(avatar, 25, 25, 450, 450);
ctx.drawImage(base, 0, 0); ctx.drawImage(base, 0, 0);
ctx.font = '30px Open Sans'; ctx.font = '30px Open Sans';
ctx.fillStyle = 'white';
ctx.fillText(username, 35, 48); ctx.fillText(username, 35, 48);
}; };
const cardImg = await request const cardImg = await request
+11 -12
View File
@@ -15,9 +15,9 @@ module.exports = class UserInfoCommand extends Command {
guildOnly: true, guildOnly: true,
args: [ args: [
{ {
key: 'user', key: 'member',
prompt: 'Which user would you like to get info on?', 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.type !== 'dm')
if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `Embed Links` Permission.'); return msg.say('This Command requires the `Embed Links` Permission.');
const { user } = args; const { member } = args;
const member = msg.guild.member(user);
let stat; let stat;
let color; let color;
switch(user.presence.status) { switch(member.user.presence.status) {
case 'online': case 'online':
stat = '<:vpOnline:212789758110334977> Online'; stat = '<:vpOnline:212789758110334977> Online';
color = 0x00AE86; color = 0x00AE86;
@@ -51,25 +50,25 @@ module.exports = class UserInfoCommand extends Command {
} }
const embed = new RichEmbed() const embed = new RichEmbed()
.setColor(color) .setColor(color)
.setThumbnail(user.displayAvatarURL) .setThumbnail(member.user.displayAvatarURL)
.addField('**Name:**', .addField('**Name:**',
user.tag, true) member.user.tag, true)
.addField('**ID:**', .addField('**ID:**',
user.id, true) member.id, true)
.addField('**Joined Discord On:**', .addField('**Joined Discord On:**',
stripIndents` stripIndents`
${user.createdAt} ${moment(member.user.createdTimestamp).format('MMMM Do YYYY h:mm:ss a')}
${moment.duration(Date.now() - user.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago. ${moment.duration(Date.now() - member.user.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago.
`, true) `, true)
.addField('**Joined Server On:**', .addField('**Joined Server On:**',
stripIndents` 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. ${moment.duration(Date.now() - member.joinedTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago.
`, true) `, true)
.addField('**Status:**', .addField('**Status:**',
stat, true) stat, true)
.addField('**Playing:**', .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); return msg.embed(embed);
} }
}; };