1
0
Fork 0

rename me command and add optional user lookup

refactor/models
Matthew 2019-11-19 18:57:15 -05:00
parent 5cc441115e
commit b623654412
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
2 changed files with 10 additions and 7 deletions

View File

@ -4,7 +4,7 @@ import { Message } from 'eris';
import { Client } from '..'; import { Client } from '..';
import { Command, RichEmbed } from '../class'; import { Command, RichEmbed } from '../class';
import { dataConversion } from '../functions'; import { dataConversion } from '../functions';
import Me from './whois_me'; import User from './whois_user';
export default class Whois extends Command { export default class Whois extends Command {
constructor(client: Client) { constructor(client: Client) {
@ -14,7 +14,7 @@ export default class Whois extends Command {
this.aliases = ['account', 'user']; this.aliases = ['account', 'user'];
this.usage = `${this.client.config.prefix}account [User Name | User ID | Email Address]`; this.usage = `${this.client.config.prefix}account [User Name | User ID | Email Address]`;
this.permissions = { roles: ['446104438969466890'] }; this.permissions = { roles: ['446104438969466890'] };
this.subcmds = [Me]; this.subcmds = [User];
this.enabled = true; this.enabled = true;
} }

View File

@ -4,18 +4,21 @@ import { Message } from 'eris';
import { Client } from '..'; import { Client } from '..';
import { Command, RichEmbed } from '../class'; import { Command, RichEmbed } from '../class';
import { dataConversion } from '../functions'; 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) { constructor(client: Client) {
super(client); super(client);
this.name = 'me'; this.name = 'user';
this.description = 'Gets information about your account.'; this.description = 'Gets information about your account.';
this.usage = `${this.client.config.prefix}whois me`; this.usage = `${this.client.config.prefix}whois user <username | user ID>`;
this.enabled = true; this.enabled = true;
} }
public async run(message: Message) { public async run(message: Message, args: string[]) {
const account = await this.client.db.Account.findOne({ userID: message.author.id }); 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.***`); if (!account) return message.channel.createMessage(`***${this.client.stores.emojis.error} You don't have an account.***`);
const embed = new RichEmbed(); const embed = new RichEmbed();
embed.setTitle('Account Information'); embed.setTitle('Account Information');