From b6236544127db42a2021a8d1989e518e2708e8b0 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Tue, 19 Nov 2019 18:57:15 -0500 Subject: [PATCH] rename me command and add optional user lookup --- src/commands/whois.ts | 4 ++-- src/commands/{whois_me.ts => whois_user.ts} | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) rename src/commands/{whois_me.ts => whois_user.ts} (83%) diff --git a/src/commands/whois.ts b/src/commands/whois.ts index 3e1ec1a..e54ad1f 100644 --- a/src/commands/whois.ts +++ b/src/commands/whois.ts @@ -4,7 +4,7 @@ import { Message } from 'eris'; import { Client } from '..'; import { Command, RichEmbed } from '../class'; import { dataConversion } from '../functions'; -import Me from './whois_me'; +import User from './whois_user'; export default class Whois extends Command { constructor(client: Client) { @@ -14,7 +14,7 @@ export default class Whois extends Command { this.aliases = ['account', 'user']; this.usage = `${this.client.config.prefix}account [User Name | User ID | Email Address]`; this.permissions = { roles: ['446104438969466890'] }; - this.subcmds = [Me]; + this.subcmds = [User]; this.enabled = true; } diff --git a/src/commands/whois_me.ts b/src/commands/whois_user.ts similarity index 83% rename from src/commands/whois_me.ts rename to src/commands/whois_user.ts index 235d5d4..525d419 100644 --- a/src/commands/whois_me.ts +++ b/src/commands/whois_user.ts @@ -4,18 +4,21 @@ import { Message } from 'eris'; import { Client } from '..'; import { Command, RichEmbed } from '../class'; import { dataConversion } from '../functions'; +import { AccountInterface } from '../models'; -export default class Whois_Me extends Command { +export default class Whois_User extends Command { constructor(client: Client) { super(client); - this.name = 'me'; + this.name = 'user'; this.description = 'Gets information about your account.'; - this.usage = `${this.client.config.prefix}whois me`; + this.usage = `${this.client.config.prefix}whois user `; this.enabled = true; } - public async run(message: Message) { - const account = await this.client.db.Account.findOne({ userID: message.author.id }); + public async run(message: Message, args: string[]) { + let account: AccountInterface; + if (!args[0]) account = await this.client.db.Account.findOne({ userID: message.author.id }); + else account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0] }] }); if (!account) return message.channel.createMessage(`***${this.client.stores.emojis.error} You don't have an account.***`); const embed = new RichEmbed(); embed.setTitle('Account Information');