diff options
Diffstat (limited to 'src/commands')
| -rw-r--r-- | src/commands/config.ts | 10 | ||||
| -rw-r--r-- | src/commands/fseek.ts | 4 | ||||
| -rw-r--r-- | src/commands/play.ts | 3 | ||||
| -rw-r--r-- | src/commands/seek.ts | 4 | ||||
| -rw-r--r-- | src/commands/skip.ts | 2 |
5 files changed, 16 insertions, 7 deletions
diff --git a/src/commands/config.ts b/src/commands/config.ts index 273bbb8..17a401a 100644 --- a/src/commands/config.ts +++ b/src/commands/config.ts @@ -1,4 +1,4 @@ -import {TextChannel, Message} from 'discord.js'; +import {TextChannel, Message, GuildChannel} from 'discord.js'; import {injectable} from 'inversify'; import {Settings} from '../models'; import errorMsg from '../utils/error-msg'; @@ -50,7 +50,13 @@ export default class implements Command { } case 'channel': { - const channel = msg.guild!.channels.cache.find(c => c.name === args[1]); + let channel: GuildChannel | undefined; + + if (args[1].includes('<#') && args[1].includes('>')) { + channel = msg.guild!.channels.cache.find(c => c.id === args[1].slice(2, args[1].indexOf('>'))); + } else { + channel = msg.guild!.channels.cache.find(c => c.name === args[1]); + } if (channel && channel.type === 'text') { await Settings.update({channel: channel.id}, {where: {guildId: msg.guild!.id}}); diff --git a/src/commands/fseek.ts b/src/commands/fseek.ts index e20d025..bd3c858 100644 --- a/src/commands/fseek.ts +++ b/src/commands/fseek.ts @@ -25,12 +25,12 @@ export default class implements Command { public async execute(msg: Message, args: string []): Promise<void> { const queue = this.queueManager.get(msg.guild!.id); - if (queue.get().length === 0) { + if (!queue.getCurrent()) { await msg.channel.send(errorMsg('nothing is playing')); return; } - if (queue.get()[0].isLive) { + if (queue.getCurrent()?.isLive) { await msg.channel.send(errorMsg('can\'t seek in a livestream')); return; } diff --git a/src/commands/play.ts b/src/commands/play.ts index 9702b48..3eb8f0b 100644 --- a/src/commands/play.ts +++ b/src/commands/play.ts @@ -268,7 +268,10 @@ export default class implements Command { if (this.playerManager.get(msg.guild!.id).voiceConnection === null) { await this.playerManager.get(msg.guild!.id).connect(targetVoiceChannel); + } + if (this.queueManager.get(msg.guild!.id).size() === 0) { + // Only auto-play on first song added await this.playerManager.get(msg.guild!.id).play(); } } diff --git a/src/commands/seek.ts b/src/commands/seek.ts index 7022168..b6e7d9e 100644 --- a/src/commands/seek.ts +++ b/src/commands/seek.ts @@ -26,12 +26,12 @@ export default class implements Command { public async execute(msg: Message, args: string []): Promise<void> { const queue = this.queueManager.get(msg.guild!.id); - if (queue.get().length === 0) { + if (!queue.getCurrent()) { await msg.channel.send(errorMsg('nothing is playing')); return; } - if (queue.get()[0].isLive) { + if (queue.getCurrent()?.isLive) { await msg.channel.send(errorMsg('can\'t seek in a livestream')); return; } diff --git a/src/commands/skip.ts b/src/commands/skip.ts index 481ea44..9e5ec4b 100644 --- a/src/commands/skip.ts +++ b/src/commands/skip.ts @@ -26,7 +26,7 @@ export default class implements Command { try { queue.forward(); - if (queue.isEmpty()) { + if (queue.isEmpty() && !queue.getCurrent()) { this.playerManager.get(msg.guild!.id).disconnect(); } else { await this.playerManager.get(msg.guild!.id).play(); |
