Utils fix
parent
91099b6942
commit
a0294ae44b
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue