Utils fix

merge-requests/1/merge
Bsian 2019-10-15 15:42:42 +01:00
parent 91099b6942
commit a0294ae44b
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
2 changed files with 5 additions and 4 deletions

View File

@ -29,9 +29,9 @@ export default class Util {
this.client.guilds.get('446067825673633794').channels.get('595788220764127272').createMessage(`\`\`\`ts\n${error.stack}\`\`\``); this.client.guilds.get('446067825673633794').channels.get('595788220764127272').createMessage(`\`\`\`ts\n${error.stack}\`\`\``);
} }
public resolveCommand(client: Client, command: string): Command { public resolveCommand(command: string): Command {
if (client.commands.has(command)) return client.commands.get(command); if (this.client.commands.has(command)) return this.client.commands.get(command);
for (const cmd of client.commands.values()) { for (const cmd of this.client.commands.values()) {
if (!cmd.aliases) continue; if (!cmd.aliases) continue;
for (const alias of cmd.aliases) { for (const alias of cmd.aliases) {
if (command === alias.toLowerCase()) return cmd; if (command === alias.toLowerCase()) return cmd;

View File

@ -10,11 +10,12 @@ export default class {
constructor(client: Client) { constructor(client: Client) {
this.client = client; this.client = client;
} }
util: Util = new Util(this.client)
async run(message: Message) { async run(message: Message) {
const noPrefix: string[] = message.content.slice(prefix.length).trim().split(/ +/g); const noPrefix: string[] = message.content.slice(prefix.length).trim().split(/ +/g);
const command: string = noPrefix[0].toLowerCase(); const command: string = noPrefix[0].toLowerCase();
const resolved: Command = new Util().resolveCommand(this.client, command); const resolved: Command = this.util.resolveCommand(command);
if (!resolved) return; if (!resolved) return;
if (resolved.guildOnly && !(message.channel instanceof TextChannel)) return; if (resolved.guildOnly && !(message.channel instanceof TextChannel)) return;
const hasUserPerms: boolean = resolved.permissions.users.includes(message.author.id); const hasUserPerms: boolean = resolved.permissions.users.includes(message.author.id);