diff options
| author | Max Isom <[email protected]> | 2020-03-18 18:29:32 -0500 |
|---|---|---|
| committer | Max Isom <[email protected]> | 2020-03-18 18:29:32 -0500 |
| commit | 8340f9b95a377580871d6e73bf87eb29ed69e6c7 (patch) | |
| tree | 40242bb31007ae75be6e3e3dae9e06469e96689c /src/commands | |
| parent | 6a02088b04392fad5bbdd43f222265c64317bfc1 (diff) | |
| download | muse-8340f9b95a377580871d6e73bf87eb29ed69e6c7.tar.xz muse-8340f9b95a377580871d6e73bf87eb29ed69e6c7.zip | |
Add disconnect command
Diffstat (limited to 'src/commands')
| -rw-r--r-- | src/commands/disconnect.ts | 27 | ||||
| -rw-r--r-- | src/commands/play.ts | 2 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/commands/disconnect.ts b/src/commands/disconnect.ts new file mode 100644 index 0000000..ecf41ab --- /dev/null +++ b/src/commands/disconnect.ts @@ -0,0 +1,27 @@ +import {Message} from 'discord.js'; +import {TYPES} from '../types'; +import {inject, injectable} from 'inversify'; +import PlayerManager from '../managers/player'; +import Command from '.'; + +@injectable() +export default class implements Command { + public name = 'disconnect'; + public examples = [ + ['disconnect', 'pauses and disconnects player'] + ]; + + private readonly playerManager: PlayerManager; + + constructor(@inject(TYPES.Managers.Player) playerManager: PlayerManager) { + this.playerManager = playerManager; + } + + public async execute(msg: Message, _: string []): Promise<void> { + const player = this.playerManager.get(msg.guild!.id); + + player.disconnect(); + + await msg.channel.send('u betcha'); + } +} diff --git a/src/commands/play.ts b/src/commands/play.ts index b155eae..bee2b4c 100644 --- a/src/commands/play.ts +++ b/src/commands/play.ts @@ -57,7 +57,7 @@ export default class implements Command { } // Must be resuming play - if (queue.get().length === 0) { + if (queue.get().length === 0 && !queue.getCurrent()) { await res.stop(errorMsg('nothing to play')); return; } |
