Add aliases

This commit is contained in:
Max Isom 2020-03-18 18:57:21 -05:00
parent 8340f9b95a
commit de1e761623
15 changed files with 23 additions and 1 deletions

View file

@ -28,7 +28,9 @@ export default class {
public async listen(): Promise<string> {
// Load in commands
container.getAll<Command>(TYPES.Command).forEach(command => {
this.commands.set(command.name, command);
const commandNames = [command.name, ...command.aliases];
commandNames.forEach(commandName => this.commands.set(commandName, command));
});
this.client.on('message', async (msg: Message) => {

View file

@ -7,6 +7,7 @@ import Command from '.';
@injectable()
export default class implements Command {
public name = 'clear';
public aliases = ['c'];
public examples = [
['clear', 'clears all songs in queue except currently playing']
];

View file

@ -7,6 +7,7 @@ import Command from '.';
@injectable()
export default class implements Command {
public name = 'config';
public aliases = [];
public examples = [
['config prefix !', 'set the prefix to !'],
['config channel music-commands', 'bind the bot to the music-commands channel']

View file

@ -2,11 +2,13 @@ import {Message} from 'discord.js';
import {TYPES} from '../types';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player';
import errorMsg from '../utils/error-msg';
import Command from '.';
@injectable()
export default class implements Command {
public name = 'disconnect';
public aliases = ['dc'];
public examples = [
['disconnect', 'pauses and disconnects player']
];
@ -20,6 +22,11 @@ export default class implements Command {
public async execute(msg: Message, _: string []): Promise<void> {
const player = this.playerManager.get(msg.guild!.id);
if (!player.voiceConnection) {
await msg.channel.send(errorMsg('not connected'));
return;
}
player.disconnect();
await msg.channel.send('u betcha');

View file

@ -10,6 +10,7 @@ import Command from '.';
@injectable()
export default class implements Command {
public name = 'fseek';
public aliases = [];
public examples = [
['fseek 10', 'skips forward in current song by 10 seconds']
];

View file

@ -8,6 +8,7 @@ import container from '../inversify.config';
@injectable()
export default class implements Command {
public name = 'help';
public aliases = ['h'];
public examples = [
['help', 'you don\'t need a description']
];

View file

@ -2,6 +2,7 @@ import {Message} from 'discord.js';
export default interface Command {
name: string;
aliases: string[];
examples: string[][];
execute: (msg: Message, args: string[]) => Promise<void>;
}

View file

@ -9,6 +9,7 @@ import Command from '.';
@injectable()
export default class implements Command {
public name = 'pause';
public aliases = [];
public examples = [
['pause', 'pauses currently playing song']
];

View file

@ -15,6 +15,7 @@ import GetSongs from '../services/get-songs';
@injectable()
export default class implements Command {
public name = 'play';
public aliases = ['p'];
public examples = [
['play', 'resume paused playback'],
['play https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'plays a YouTube video'],

View file

@ -7,6 +7,7 @@ import Command from '.';
@injectable()
export default class implements Command {
public name = 'queue';
public aliases = ['q'];
public examples = [
['queue', 'shows current queue']
];

View file

@ -10,6 +10,7 @@ import Command from '.';
@injectable()
export default class implements Command {
public name = 'seek';
public aliases = [];
public examples = [
['seek 10', 'seeks to 10 seconds from beginning of song'],
['seek 1:30', 'seeks to 1 minute and 30 seconds from beginning of song'],

View file

@ -7,6 +7,7 @@ import Command from '.';
@injectable()
export default class implements Command {
public name = 'shortcuts';
public aliases = [];
public examples = [
['shortcuts', 'show all shortcuts'],
['shortcuts set s skip', 'aliases `s` to `skip`'],

View file

@ -8,6 +8,7 @@ import Command from '.';
@injectable()
export default class implements Command {
public name = 'shuffle';
public aliases = [];
public examples = [
['shuffle', 'shuffles the current queue']
];

View file

@ -8,6 +8,7 @@ import Command from '.';
@injectable()
export default class implements Command {
public name = 'skip';
public aliases = ['s'];
public examples = [
['skip', 'skips the current song']
];

View file

@ -9,6 +9,7 @@ import Command from '.';
@injectable()
export default class implements Command {
public name = 'unskip';
public aliases = ['back'];
public examples = [
['unskip', 'goes back in the queue by one song']
];