mirror of
https://github.com/BluemediaGER/muse.git
synced 2024-11-23 09:15:29 +01:00
Add skip/unskip
This commit is contained in:
parent
3c169d113c
commit
e55acbb718
33
src/commands/skip.ts
Normal file
33
src/commands/skip.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import {Message} from 'discord.js';
|
||||||
|
import {TYPES} from '../types';
|
||||||
|
import {inject, injectable} from 'inversify';
|
||||||
|
import PlayerManager from '../managers/player';
|
||||||
|
import QueueManager from '../managers/queue';
|
||||||
|
import Command from '.';
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export default class implements Command {
|
||||||
|
public name = 'skip';
|
||||||
|
public description = 'skips current song';
|
||||||
|
private readonly queueManager: QueueManager;
|
||||||
|
private readonly playerManager: PlayerManager;
|
||||||
|
|
||||||
|
constructor(@inject(TYPES.Managers.Queue) queueManager: QueueManager, @inject(TYPES.Managers.Player) playerManager: PlayerManager) {
|
||||||
|
this.queueManager = queueManager;
|
||||||
|
this.playerManager = playerManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async execute(msg: Message, _: string []): Promise<void> {
|
||||||
|
const queue = this.queueManager.get(msg.guild!.id);
|
||||||
|
|
||||||
|
try {
|
||||||
|
queue.forward();
|
||||||
|
|
||||||
|
await this.playerManager.get(msg.guild!.id).play();
|
||||||
|
|
||||||
|
await msg.channel.send('keepin\' \'er movin\'');
|
||||||
|
} catch (_) {
|
||||||
|
await msg.channel.send('no song to skip to');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
src/commands/unskip.ts
Normal file
33
src/commands/unskip.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import {Message} from 'discord.js';
|
||||||
|
import {TYPES} from '../types';
|
||||||
|
import {inject, injectable} from 'inversify';
|
||||||
|
import PlayerManager from '../managers/player';
|
||||||
|
import QueueManager from '../managers/queue';
|
||||||
|
import Command from '.';
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export default class implements Command {
|
||||||
|
public name = 'unskip';
|
||||||
|
public description = 'go back in the queue';
|
||||||
|
private readonly queueManager: QueueManager;
|
||||||
|
private readonly playerManager: PlayerManager;
|
||||||
|
|
||||||
|
constructor(@inject(TYPES.Managers.Queue) queueManager: QueueManager, @inject(TYPES.Managers.Player) playerManager: PlayerManager) {
|
||||||
|
this.queueManager = queueManager;
|
||||||
|
this.playerManager = playerManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async execute(msg: Message, _: string []): Promise<void> {
|
||||||
|
const queue = this.queueManager.get(msg.guild!.id);
|
||||||
|
|
||||||
|
try {
|
||||||
|
queue.back();
|
||||||
|
|
||||||
|
await this.playerManager.get(msg.guild!.id).play();
|
||||||
|
|
||||||
|
await msg.channel.send('back \'er up\'');
|
||||||
|
} catch (_) {
|
||||||
|
await msg.channel.send('no song to go back to');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,6 +28,8 @@ import Play from './commands/play';
|
||||||
import QueueCommad from './commands/queue';
|
import QueueCommad from './commands/queue';
|
||||||
import Seek from './commands/seek';
|
import Seek from './commands/seek';
|
||||||
import Shuffle from './commands/shuffle';
|
import Shuffle from './commands/shuffle';
|
||||||
|
import Skip from './commands/skip';
|
||||||
|
import Unskip from './commands/unskip';
|
||||||
|
|
||||||
let container = new Container();
|
let container = new Container();
|
||||||
|
|
||||||
|
@ -47,6 +49,8 @@ container.bind<Command>(TYPES.Command).to(Play).inSingletonScope();
|
||||||
container.bind<Command>(TYPES.Command).to(QueueCommad).inSingletonScope();
|
container.bind<Command>(TYPES.Command).to(QueueCommad).inSingletonScope();
|
||||||
container.bind<Command>(TYPES.Command).to(Seek).inSingletonScope();
|
container.bind<Command>(TYPES.Command).to(Seek).inSingletonScope();
|
||||||
container.bind<Command>(TYPES.Command).to(Shuffle).inSingletonScope();
|
container.bind<Command>(TYPES.Command).to(Shuffle).inSingletonScope();
|
||||||
|
container.bind<Command>(TYPES.Command).to(Skip).inSingletonScope();
|
||||||
|
container.bind<Command>(TYPES.Command).to(Unskip).inSingletonScope();
|
||||||
|
|
||||||
// Config values
|
// Config values
|
||||||
container.bind<string>(TYPES.Config.DISCORD_TOKEN).toConstantValue(DISCORD_TOKEN);
|
container.bind<string>(TYPES.Config.DISCORD_TOKEN).toConstantValue(DISCORD_TOKEN);
|
||||||
|
|
Loading…
Reference in a new issue