diff options
| author | Max Isom <[email protected]> | 2020-03-13 20:36:42 -0500 |
|---|---|---|
| committer | Max Isom <[email protected]> | 2020-03-13 20:36:42 -0500 |
| commit | fb91c8e89cb34465315ac3c9f4f11e27ec577348 (patch) | |
| tree | 66fef9fdceaee601d02f8f13eb91e47292c59546 /src/commands | |
| parent | c446e0fd57cec0ea2fb0211bd99841e5ddde0cf6 (diff) | |
| download | muse-fb91c8e89cb34465315ac3c9f4f11e27ec577348.tar.xz muse-fb91c8e89cb34465315ac3c9f4f11e27ec577348.zip | |
Add better caching, seek command
Diffstat (limited to 'src/commands')
| -rw-r--r-- | src/commands/seek.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/commands/seek.ts b/src/commands/seek.ts new file mode 100644 index 0000000..29c3972 --- /dev/null +++ b/src/commands/seek.ts @@ -0,0 +1,33 @@ +import {Message, TextChannel} from 'discord.js'; +import {TYPES} from '../types'; +import {inject, injectable} from 'inversify'; +import Player from '../services/player'; +import LoadingMessage from '../utils/loading-message'; +import Command from '.'; + +@injectable() +export default class implements Command { + public name = 'seek'; + public description = 'seeks position in currently playing song'; + private readonly player: Player; + + constructor(@inject(TYPES.Services.Player) player: Player) { + this.player = player; + } + + public async execute(msg: Message, args: string []): Promise<void> { + const seekTime = parseInt(args[0], 10); + + const loading = new LoadingMessage(msg.channel as TextChannel, 'hold on a sec'); + + await loading.start(); + + try { + await this.player.seek(msg.guild!.id, seekTime); + + await loading.stop('seeked'); + } catch (_) { + await loading.stop('error somewhere'); + } + } +} |
