1
0
Fork 0

Util class is binded to client, no need to make another class for each command

refactor/models
Matthew R 2019-10-17 15:43:32 -04:00
parent 83452d5184
commit ba27e52e0c
No known key found for this signature in database
GPG Key ID: 97CA005641E9054C
3 changed files with 3 additions and 8 deletions

View File

@ -2,11 +2,8 @@ import fs from 'fs-extra';
import { Message } from 'eris'; import { Message } from 'eris';
import Client from '../Client'; import Client from '../Client';
import Command from '../class/Command'; import Command from '../class/Command';
import Util from '../Util';
export default class Lock extends Command { export default class Lock extends Command {
util: Util = new Util(this.client)
constructor(client: Client) { constructor(client: Client) {
super(client); super(client);
this.name = 'lock'; this.name = 'lock';
@ -21,7 +18,7 @@ export default class Lock extends Command {
if (!account) return message.channel.createMessage(`***${this.client.stores.emojis.error} Cannot find user.***`); if (!account) return message.channel.createMessage(`***${this.client.stores.emojis.error} Cannot find user.***`);
const edit = await message.channel.createMessage(`***${this.client.stores.emojis.loading} Locking account...***`); const edit = await message.channel.createMessage(`***${this.client.stores.emojis.loading} Locking account...***`);
} catch (error) { } catch (error) {
return this.util.handleError(error, message, this); return this.client.util.handleError(error, message, this);
} }
} }
} }

View File

@ -1,4 +1,5 @@
import { Message } from 'eris'; import { Message } from 'eris';
// eslint-disable-next-line import/no-unresolved
import { createPaginationEmbed } from 'eris-pagination'; import { createPaginationEmbed } from 'eris-pagination';
import Client from '../Client'; import Client from '../Client';
import Command from '../class/Command'; import Command from '../class/Command';

View File

@ -1,11 +1,8 @@
import { Message } from 'eris'; import { Message } from 'eris';
import Client from '../Client'; import Client from '../Client';
import Command from '../class/Command'; import Command from '../class/Command';
import Util from '../Util';
export default class Ping extends Command { export default class Ping extends Command {
util: Util = new Util(this.client)
constructor(client: Client) { constructor(client: Client) {
super(client); super(client);
this.name = 'ping'; this.name = 'ping';
@ -19,7 +16,7 @@ export default class Ping extends Command {
const msg: Message = await message.channel.createMessage('🏓 Pong!'); const msg: Message = await message.channel.createMessage('🏓 Pong!');
msg.edit(`🏓 Pong!\nClient: \`${Date.now() - clientStart}ms\`\nResponse: \`${msg.createdAt - message.createdAt}ms\``); msg.edit(`🏓 Pong!\nClient: \`${Date.now() - clientStart}ms\`\nResponse: \`${msg.createdAt - message.createdAt}ms\``);
} catch (error) { } catch (error) {
this.util.handleError(error, message, this); this.client.util.handleError(error, message, this);
} }
} }
} }