36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
const Revolt = require('revolt.js');
|
|
const { client, logger, config } = require('..');
|
|
const getUser = require('../util/get_user');
|
|
const { levels, levelups } = require('../util/levels');
|
|
|
|
module.exports.meta = {
|
|
name: 'whois',
|
|
aliases: [ 'userinfo', 'who' ],
|
|
description: 'Shows user info.'
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param { Revolt.Message } message
|
|
* @param { string[] } args
|
|
*/
|
|
module.exports.run = async (message, args) => new Promise(async (resolve, reject) => {
|
|
if (!args[0])
|
|
return client.channels.sendMessage(message.channel, ':x: Please specify the user\'s name or ID.');
|
|
|
|
let target = await getUser(args.join(' '));
|
|
if (!target)
|
|
return client.channels.sendMessage(message.channel, ':x: I can\'t find that user. Type their name or ID.');
|
|
|
|
const avatarURL = `https://api.revolt.chat/users/${target._id}/avatar`;
|
|
const { xp, level } = (levels.get(target._id) || {});
|
|
|
|
let msgContent = `> ## \u200b ${target.username}\n` +
|
|
`> \u200b\n` +
|
|
`> **ID**: \`${target._id}\`\n` +
|
|
`> **Online**: \`${target.online ?? 'Unknown'}\`\n` +
|
|
`> **XP**: \`${xp ? `${xp} XP, Level ${level}. Level up in ${levelups.find(l => l > xp) - xp} XP` : 'None'}\`\n` +
|
|
`> [\\[Avatar\\]](${avatarURL})\n`
|
|
|
|
await client.channels.sendMessage(message.channel, msgContent);
|
|
}); |