You've already forked discord-bot
mirror of
https://github.com/t2linux/discord-bot.git
synced 2026-04-30 13:49:21 -07:00
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
import { GuildMember, Message } from 'discord.js';
|
|
import { commands } from '..';
|
|
import { Argument } from '../argument';
|
|
import { Command } from '../command';
|
|
|
|
export class HelpCommand extends Command {
|
|
|
|
public name(): string {
|
|
return 'help';
|
|
}
|
|
|
|
public description(): string {
|
|
return 'Help about a command';
|
|
}
|
|
|
|
public arguments(): Array<Argument> {
|
|
return [
|
|
{ name: 'command', type: 'string', description: 'The command to get help about' }
|
|
];
|
|
}
|
|
|
|
public async permitted(member: GuildMember): Promise<boolean> {
|
|
return true;
|
|
}
|
|
|
|
public async handle(message: Message, args: Array<string>): Promise<void> {
|
|
const [ commandName ] = args;
|
|
|
|
if (!commandName) {
|
|
message.channel.send(this.help());
|
|
|
|
return;
|
|
}
|
|
|
|
for (const command of commands) {
|
|
if (command.name().toLowerCase() === commandName.toLowerCase()) {
|
|
message.channel.send(command.help());
|
|
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
} |