community-relations/src/class/Command.ts

84 lines
2.2 KiB
TypeScript
Raw Normal View History

import { Member, Message, TextableChannel } from 'eris';
2020-04-14 13:15:33 -04:00
import { Client } from '.';
export default class Command {
public client: Client;
/**
* The name of the command
*/
public name: string;
/**
* The description for the command.
*/
public description: string;
2020-04-15 15:33:39 -04:00
/**
* Usage for the command.
*/
public usage: string;
2020-04-14 13:15:33 -04:00
/**
* The aliases for the command.
*/
public aliases: string[];
/**
* - **0:** Everyone
* - **1:** Associates Team+
* - **2:** Sheriff+
* - **3:** Faculty Marshals+
* - **4:** Marshal Generals of Engineering
*/
public permissions: number;
/**
* Determines if the command is only available in server.
*/
public guildOnly: boolean;
/**
* Determines if the command is enabled or not.
*/
public enabled: boolean;
public run(message: Message, args: string[]): Promise<any> { return Promise.resolve(); }
constructor(client: Client) {
this.client = client;
this.aliases = [];
2020-04-14 13:15:33 -04:00
}
public checkPermissions(member: Member): boolean {
if (member.id === '278620217221971968' || member.id === '253600545972027394') return true;
switch (this.permissions) {
case 0:
return true;
case 1:
return member.roles.some((r) => ['662163685439045632', '455972169449734144', '453689940140883988'].includes(r));
case 2:
return member.roles.some((r) => ['662163685439045632', '455972169449734144'].includes(r));
case 3:
return member.roles.some((r) => ['662163685439045632'].includes(r));
case 4:
return member.id === '278620217221971968' || member.id === '253600545972027394';
default:
return false;
}
}
public error(channel: TextableChannel, text: string): Promise<Message> {
return channel.createMessage(`***${this.client.util.emojis.ERROR} ${text}***`);
}
public success(channel: TextableChannel, text: string): Promise<Message> {
return channel.createMessage(`***${this.client.util.emojis.SUCCESS} ${text}***`);
}
public loading(channel: TextableChannel, text: string): Promise<Message> {
return channel.createMessage(`***${this.client.util.emojis.LOADING} ${text}***`);
}
2020-04-14 13:15:33 -04:00
}