Command Context class declaration and index restructure
parent
ca6e20fa0b
commit
af72a4d6d2
|
@ -0,0 +1,24 @@
|
|||
import { Message, MessageContent, FileContent } from 'eris';
|
||||
import { Client } from '.';
|
||||
|
||||
export default class CmdContext {
|
||||
public client: Client;
|
||||
|
||||
public message: Message;
|
||||
|
||||
public args?: string[];
|
||||
|
||||
constructor(message: Message, args?: string[]) {
|
||||
this.message = message;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public async uniCreateMessage(content: MessageContent, file?: FileContent | FileContent[]) {
|
||||
if ([2, 3].includes(this.message.channel.type)) {
|
||||
const channel = await this.client.getDMChannel(this.message.author.id);
|
||||
if (!channel) throw new Error(`Unable to fetch DM channel for '${this.message.author.id}'.`);
|
||||
return channel.createMessage(content, file);
|
||||
}
|
||||
return this.message.channel.createMessage(content, file);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import { Member, Message, TextableChannel } from 'eris';
|
||||
import { Client, Collection } from '.';
|
||||
import { Client, CmdContext, Collection } from '.';
|
||||
|
||||
export default class Command {
|
||||
public client: Client;
|
||||
|
@ -52,7 +52,7 @@ export default class Command {
|
|||
|
||||
public enabled: boolean;
|
||||
|
||||
public run(message: Message, args: string[]): Promise<any> { return Promise.resolve(); }
|
||||
public run(ctx: CmdContext): Promise<any> { return Promise.resolve(); }
|
||||
|
||||
constructor(client: Client) {
|
||||
this.client = client;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
export { default as Client } from './Client';
|
||||
export { default as CmdContext } from './CmdContext';
|
||||
export { default as Collection } from './Collection';
|
||||
export { default as Command } from './Command';
|
||||
export { default as Event } from './Event';
|
||||
|
|
Loading…
Reference in New Issue