From fb91c8e89cb34465315ac3c9f4f11e27ec577348 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Fri, 13 Mar 2020 20:36:42 -0500 Subject: Add better caching, seek command --- src/commands/seek.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/commands/seek.ts (limited to 'src/commands') 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 { + 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'); + } + } +} -- cgit v1.2.3