// import { Message } from 'eris'; import { Client, Command } from '.'; export default class Util { public client: Client; constructor(client: Client) { this.client = client; } get emojis() { return { SUCCESS: '<:modSuccess:578750988907970567>', LOADING: '', ERROR: '<:modError:578750737920688128>', }; } /** * Resolves a command * @param query Command input * @param message Only used to check for errors */ public resolveCommand(query: string | string[]): Promise<{cmd: Command, args: string[] }> { try { // let resolvedCommand: Command; // eslint-disable-next-line no-param-reassign if (typeof query === 'string') query = query.split(' '); const commands = this.client.commands.toArray(); const resolvedCommand = commands.find((c) => c.name === query[0].toLowerCase() || c.aliases.includes(query[0].toLowerCase())); if (!resolvedCommand) return Promise.resolve(null); query.shift(); return Promise.resolve({ cmd: resolvedCommand, args: query }); } catch (error) { return Promise.reject(error); } } }