Skip to content

Commit

Permalink
fix: remove yamusic plugin, fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
devianllert committed Aug 31, 2019
1 parent aad5b90 commit 03069d8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 86 deletions.
1 change: 1 addition & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ bot
.connect()
.then((): void => {
logger.debug('Bot Ready');

bot.listen();
})
.catch((err: Error): void => {
Expand Down
7 changes: 2 additions & 5 deletions src/core/Bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import { ParsedMessage, parse } from './BotCommandParser';

import logger from '../utils/logger';

// Plugins
import YamusicPlugin from '../plugins/yamusic';

// Commands
import help from '../api/help';
import play from '../api/play';
Expand Down Expand Up @@ -52,7 +49,7 @@ class YBot implements Bot {

public helptext: string;

public plugins!: BotPlugin[];
public plugins: BotPlugin[];

public constructor(config: BotConfig) {
this.helptext = 'Help hint!';
Expand Down Expand Up @@ -140,7 +137,7 @@ class YBot implements Bot {
this.status = new BotStatus(this.client);
this.player = new BotMediaPlayer(this.config, this.status);

this.plugins = [new YamusicPlugin()];
this.plugins = [];

this.plugins.forEach((plugin): void => {
plugin.preInitialize(this);
Expand Down
30 changes: 11 additions & 19 deletions src/core/BotMediaPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@ class MediaPlayer {
}

public addMedia(items: MediaItem[]): void {
items.forEach((item): void => {
const type = this.typeRegistry.get(item.type);

if (type) {
this.queue.enqueue(item);
} else if (this.channel) this.channel.send('❌ Error adding track: Unknown Media Type!');
});
items.forEach((item): void => this.queue.enqueue(item));

if (this.channel && items) {
if (items.length > 1) this.channel.send(embedMultipleTracksAdded(items));
Expand Down Expand Up @@ -135,20 +129,14 @@ class MediaPlayer {
const item = this.nowPlaying;

if (item && this.connection) {
const type = this.typeRegistry.get(item.type);

if (type) {
if (!this.playing) {
type.getStream(item).then((stream: string): void => {
this.dispatchStream(stream, item);
});
} else if (this.paused && this.dispatcher) {
this.dispatcher.resume();
if (!this.playing) {
this.dispatchStream(item.url, item);
} else if (this.paused && this.dispatcher) {
this.dispatcher.resume();

this.paused = false;
this.paused = false;

if (this.channel && this.nowPlaying) this.channel.send(`⏯ **${this.nowPlaying.name}** resumed`);
}
if (this.channel && this.nowPlaying) this.channel.send(`⏯ **${this.nowPlaying.name}** resumed`);
}
}
}
Expand Down Expand Up @@ -205,6 +193,10 @@ class MediaPlayer {
const to = Math.min(Math.max(targetIdx - 1, min), max);

this.queue.move(from, to);

if (this.channel) {
this.channel.send(`Track at ${from + 1} position **${this.at(to).name}** has been moved to ${to + 1}`);
}
}

public setVolume(volume: number): void {
Expand Down
62 changes: 0 additions & 62 deletions src/plugins/yamusic.ts

This file was deleted.

File renamed without changes.

0 comments on commit 03069d8

Please sign in to comment.