aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Isom <[email protected]>2020-03-15 16:55:44 -0500
committerMax Isom <[email protected]>2020-03-15 16:55:44 -0500
commite55acbb718c5b36315010b5d093b1554712aca4b (patch)
treed8842aecec9555e9d89267032a8fa82d56986757 /src
parent3c169d113c21fc4f067400cf837b71abfc2f161d (diff)
downloadmuse-e55acbb718c5b36315010b5d093b1554712aca4b.tar.xz
muse-e55acbb718c5b36315010b5d093b1554712aca4b.zip
Add skip/unskip
Diffstat (limited to 'src')
-rw-r--r--src/commands/skip.ts33
-rw-r--r--src/commands/unskip.ts33
-rw-r--r--src/inversify.config.ts4
3 files changed, 70 insertions, 0 deletions
diff --git a/src/commands/skip.ts b/src/commands/skip.ts
new file mode 100644
index 0000000..87fb94d
--- /dev/null
+++ b/src/commands/skip.ts
@@ -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');
+ }
+ }
+}
diff --git a/src/commands/unskip.ts b/src/commands/unskip.ts
new file mode 100644
index 0000000..01fef7a
--- /dev/null
+++ b/src/commands/unskip.ts
@@ -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');
+ }
+ }
+}
diff --git a/src/inversify.config.ts b/src/inversify.config.ts
index 9b91743..759a27ac 100644
--- a/src/inversify.config.ts
+++ b/src/inversify.config.ts
@@ -28,6 +28,8 @@ import Play from './commands/play';
import QueueCommad from './commands/queue';
import Seek from './commands/seek';
import Shuffle from './commands/shuffle';
+import Skip from './commands/skip';
+import Unskip from './commands/unskip';
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(Seek).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
container.bind<string>(TYPES.Config.DISCORD_TOKEN).toConstantValue(DISCORD_TOKEN);