From b91e072e2fbc63692f42a1e9476e171ee37905bb Mon Sep 17 00:00:00 2001 From: cheqpat Date: Sat, 2 Oct 2021 02:14:47 -0500 Subject: implement @udany's fix --- src/commands/play.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/commands/play.ts b/src/commands/play.ts index a907a40..0dc1ce1 100644 --- a/src/commands/play.ts +++ b/src/commands/play.ts @@ -157,12 +157,16 @@ export default class implements Command { await res.stop(`u betcha, **${firstSong.title}** and ${newSongs.length - 1} other songs were added to the queue${extraMsg}`); } - if (queueOldSize === 0 && !wasPlayingSong) { - // Only auto-play if queue was empty before and nothing was playing - if (player.voiceConnection === null) { - await player.connect(targetVoiceChannel); + if (player.voiceConnection === null) { + await player.connect(targetVoiceChannel); + + if (player.status === STATUS.PAUSED && queueOldSize) { + await msg.channel.send('joined, but I\'m paused, use a lonely `-p` to resume playback'); } + } + if (queueOldSize === 0 && !wasPlayingSong) { + // Only auto-play if queue was empty before and nothing was playing await player.play(); } } -- cgit v1.2.3 From 3924c8007c08fa62b71303333d3563671e3c3db1 Mon Sep 17 00:00:00 2001 From: cheqpat Date: Sat, 2 Oct 2021 02:16:59 -0500 Subject: Always autoplay rather than alerting that it is paused --- src/commands/play.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/commands/play.ts b/src/commands/play.ts index 0dc1ce1..a0e5bb6 100644 --- a/src/commands/play.ts +++ b/src/commands/play.ts @@ -161,7 +161,8 @@ export default class implements Command { await player.connect(targetVoiceChannel); if (player.status === STATUS.PAUSED && queueOldSize) { - await msg.channel.send('joined, but I\'m paused, use a lonely `-p` to resume playback'); + // Resume playing from queue after being paused + await player.play(); } } -- cgit v1.2.3 From e4a8dde7762101d0bfe965f1ddc04ffdcd74574d Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sun, 12 Dec 2021 13:20:36 -0500 Subject: Always resume --- src/commands/play.ts | 37 ++++++++++++++++++++++--------------- src/services/player.ts | 4 ++++ 2 files changed, 26 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/commands/play.ts b/src/commands/play.ts index 8fb5775..856edec 100644 --- a/src/commands/play.ts +++ b/src/commands/play.ts @@ -46,7 +46,6 @@ export default class implements Command { const player = this.playerManager.get(msg.guild!.id); - const queueOldSize = player.queueSize(); const wasPlayingSong = player.getCurrent() !== null; if (args.length === 0) { @@ -147,6 +146,28 @@ export default class implements Command { const firstSong = newSongs[0]; + let statusMsg = ''; + + if (player.voiceConnection === null) { + await player.connect(targetVoiceChannel); + + // Resume / start playback + await player.play(); + + if (wasPlayingSong) { + statusMsg = 'resuming playback'; + } + } + + // Build response message + if (statusMsg !== '') { + if (extraMsg === '') { + extraMsg = statusMsg; + } else { + extraMsg = `${statusMsg}, ${extraMsg}`; + } + } + if (extraMsg !== '') { extraMsg = ` (${extraMsg})`; } @@ -156,19 +177,5 @@ export default class implements Command { } else { await res.stop(`u betcha, **${firstSong.title}** and ${newSongs.length - 1} other songs were added to the queue${extraMsg}`); } - - if (player.voiceConnection === null) { - await player.connect(targetVoiceChannel); - - if (player.status === STATUS.PAUSED && queueOldSize) { - // Resume playing from queue after being paused - await player.play(); - } - } - - if (queueOldSize === 0 && !wasPlayingSong) { - // Only auto-play if queue was empty before and nothing was playing - await player.play(); - } } } diff --git a/src/services/player.ts b/src/services/player.ts index 67b8b38..4a226c5 100644 --- a/src/services/player.ts +++ b/src/services/player.ts @@ -235,6 +235,10 @@ export default class { return null; } + /** + * Returns queue, not including the current song. + * @returns {QueuedSong[]} + */ getQueue(): QueuedSong[] { return this.queue.slice(this.queuePosition + 1); } -- cgit v1.2.3 From ffc8493ea3816402f142794cc7904244e9f6e2ac Mon Sep 17 00:00:00 2001 From: Max Isom Date: Mon, 13 Dec 2021 20:11:14 -0500 Subject: Add splash banner and spinner progress for initial connection --- src/bot.ts | 8 ++++++-- src/index.ts | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/bot.ts b/src/bot.ts index b49c1f6..5260ae0 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -1,5 +1,6 @@ import {Client, Message, Collection} from 'discord.js'; import {inject, injectable} from 'inversify'; +import ora from 'ora'; import {TYPES} from './types.js'; import {Settings, Shortcut} from './models/index.js'; import container from './inversify.config.js'; @@ -96,9 +97,12 @@ export default class { } }); - this.client.on('ready', async () => { + const spinner = ora('📡 connecting to Discord...').start(); + + this.client.on('ready', () => { debug(generateDependencyReport()); - console.log(`Ready! Invite the bot with https://discordapp.com/oauth2/authorize?client_id=${this.client.user?.id ?? ''}&scope=bot&permissions=36752448`); + + spinner.succeed(`Ready! Invite the bot with https://discordapp.com/oauth2/authorize?client_id=${this.client.user?.id ?? ''}&scope=bot&permissions=36752448`); }); this.client.on('error', console.error); diff --git a/src/index.ts b/src/index.ts index 383faef..a6b6d35 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,15 +1,28 @@ import makeDir from 'make-dir'; import path from 'path'; +import {makeLines} from 'nodesplash'; import container from './inversify.config.js'; import {TYPES} from './types.js'; import Bot from './bot.js'; import {sequelize} from './utils/db.js'; import Config from './services/config.js'; import FileCacheProvider from './services/file-cache.js'; +import metadata from '../package.json'; const bot = container.get(TYPES.Bot); (async () => { + // Banner + console.log(makeLines({ + user: 'codetheweb', + repository: 'muse', + version: metadata.version, + paypalUser: 'codetheweb', + githubSponsor: 'codetheweb', + madeByPrefix: 'Made with 🎶 by ', + }).join('\n')); + console.log('\n'); + // Create data directories if necessary const config = container.get(TYPES.Config); -- cgit v1.2.3