mirror of
https://github.com/BluemediaDev/muse.git
synced 2025-05-10 12:11:35 +02:00
Add better caching, seek command
This commit is contained in:
parent
c446e0fd57
commit
fb91c8e89c
6 changed files with 280 additions and 91 deletions
33
src/commands/seek.ts
Normal file
33
src/commands/seek.ts
Normal file
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue