mirror of
https://github.com/BluemediaDev/muse.git
synced 2025-05-10 04:01:37 +02:00
Merge branch 'master' into mutex
This commit is contained in:
commit
d07dc5baf4
14 changed files with 481 additions and 153 deletions
|
@ -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);
|
||||
|
|
|
@ -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,14 +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 (queueOldSize === 0 && !wasPlayingSong) {
|
||||
// Only auto-play if queue was empty before and nothing was playing
|
||||
if (player.voiceConnection === null) {
|
||||
await player.connect(targetVoiceChannel);
|
||||
}
|
||||
|
||||
await player.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
13
src/index.ts
13
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<Bot>(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<Config>(TYPES.Config);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue