Compare commits

..

No commits in common. "9dda474fd6eb820dc100085ab9d177a830fd49ec" and "af0bcd70589fa1186311bce9be4e8ef57b6440e7" have entirely different histories.

16 changed files with 19 additions and 107 deletions

View file

@ -6,15 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [2.5.0] - 2024-01-16
### Added
- Added `/loop-queue`
## [2.4.4] - 2023-12-21
- Optimized Docker container to run JS code directly with node instead of yarn, npm and tsx. Reduces memory usage.
## [2.4.3] - 2023-09-10 ## [2.4.3] - 2023-09-10
### Fixed ### Fixed
@ -280,9 +271,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Initial release - Initial release
[unreleased]: https://github.com/codetheweb/muse/compare/v2.5.0...HEAD [unreleased]: https://github.com/codetheweb/muse/compare/v2.4.3...HEAD
[2.5.0]: https://github.com/codetheweb/muse/compare/v2.4.4...v2.5.0
[2.4.4]: https://github.com/codetheweb/muse/compare/v2.4.3...v2.4.4
[2.4.3]: https://github.com/codetheweb/muse/compare/v2.4.2...v2.4.3 [2.4.3]: https://github.com/codetheweb/muse/compare/v2.4.2...v2.4.3
[2.4.2]: https://github.com/codetheweb/muse/compare/v2.4.1...v2.4.2 [2.4.2]: https://github.com/codetheweb/muse/compare/v2.4.1...v2.4.2
[2.4.1]: https://github.com/codetheweb/muse/compare/v2.4.0...v2.4.1 [2.4.1]: https://github.com/codetheweb/muse/compare/v2.4.0...v2.4.1

View file

@ -14,29 +14,18 @@ COPY package.json .
COPY yarn.lock . COPY yarn.lock .
RUN yarn install --prod RUN yarn install --prod
RUN cp -R node_modules /usr/app/prod_node_modules
RUN yarn install
FROM dependencies AS builder
COPY . .
# Run tsc build
RUN yarn prisma generate
RUN yarn build
# Only keep what's necessary to run # Only keep what's necessary to run
FROM base AS runner FROM base AS runner
WORKDIR /usr/app WORKDIR /usr/app
COPY --from=builder /usr/app/dist ./dist COPY --from=dependencies /usr/app/node_modules node_modules
COPY --from=dependencies /usr/app/prod_node_modules node_modules
COPY --from=builder /usr/app/node_modules/.prisma/client ./node_modules/.prisma/client
COPY . . COPY . .
RUN yarn prisma generate
ARG COMMIT_HASH=unknown ARG COMMIT_HASH=unknown
ARG BUILD_DATE=unknown ARG BUILD_DATE=unknown
@ -45,4 +34,4 @@ ENV NODE_ENV production
ENV COMMIT_HASH $COMMIT_HASH ENV COMMIT_HASH $COMMIT_HASH
ENV BUILD_DATE $BUILD_DATE ENV BUILD_DATE $BUILD_DATE
CMD ["tini", "--", "node", "--enable-source-maps", "dist/scripts/migrate-and-start.js"] CMD ["tini", "--", "yarn", "start"]

View file

@ -31,9 +31,6 @@ Muse is written in TypeScript. You can either run Muse with Docker (recommended)
- `SPOTIFY_CLIENT_ID` and `SPOTIFY_CLIENT_SECRET` can be acquired [here](https://developer.spotify.com/dashboard/applications) with 'Create a Client ID'. - `SPOTIFY_CLIENT_ID` and `SPOTIFY_CLIENT_SECRET` can be acquired [here](https://developer.spotify.com/dashboard/applications) with 'Create a Client ID'.
- `YOUTUBE_API_KEY` can be acquired by [creating a new project](https://console.developers.google.com) in Google's Developer Console, enabling the YouTube API, and creating an API key under credentials. - `YOUTUBE_API_KEY` can be acquired by [creating a new project](https://console.developers.google.com) in Google's Developer Console, enabling the YouTube API, and creating an API key under credentials.
> [!WARNING]
> Even if you don't plan on using Spotify, you must still provide the client ID and secret; otherwise Muse will not function.
Muse will log a URL when run. Open this URL in a browser to invite Muse to your server. Muse will DM the server owner after it's added with setup instructions. Muse will log a URL when run. Open this URL in a browser to invite Muse to your server. Muse will DM the server owner after it's added with setup instructions.
A 64-bit OS is required to run Muse. A 64-bit OS is required to run Muse.

View file

@ -1,6 +1,6 @@
{ {
"name": "muse", "name": "muse",
"version": "2.5.0", "version": "2.4.3",
"description": "🎧 a self-hosted Discord music bot that doesn't suck ", "description": "🎧 a self-hosted Discord music bot that doesn't suck ",
"repository": "git@github.com:codetheweb/muse.git", "repository": "git@github.com:codetheweb/muse.git",
"author": "Max Isom <hi@maxisom.me>", "author": "Max Isom <hi@maxisom.me>",
@ -26,8 +26,7 @@
"migrations:run": "npm run prisma:with-env migrate deploy", "migrations:run": "npm run prisma:with-env migrate deploy",
"prisma:with-env": "npm run env:set-database-url prisma", "prisma:with-env": "npm run env:set-database-url prisma",
"env:set-database-url": "tsx src/scripts/run-with-database-url.ts", "env:set-database-url": "tsx src/scripts/run-with-database-url.ts",
"release": "release-it", "release": "release-it"
"build": "tsc"
}, },
"devDependencies": { "devDependencies": {
"@release-it/keep-a-changelog": "^2.3.0", "@release-it/keep-a-changelog": "^2.3.0",

View file

@ -3,7 +3,7 @@ import {ChatInputCommandInteraction, EmbedBuilder, PermissionFlagsBits} from 'di
import {injectable} from 'inversify'; import {injectable} from 'inversify';
import {prisma} from '../utils/db.js'; import {prisma} from '../utils/db.js';
import Command from './index.js'; import Command from './index.js';
import {getGuildSettings} from '../utils/get-guild-settings.js'; import {getGuildSettings} from '../utils/get-guild-settings';
@injectable() @injectable()
export default class implements Command { export default class implements Command {

View file

@ -1,42 +0,0 @@
import {ChatInputCommandInteraction} from 'discord.js';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js';
import Command from '.';
import {SlashCommandBuilder} from '@discordjs/builders';
import {STATUS} from '../services/player.js';
@injectable()
export default class implements Command {
public readonly slashCommand = new SlashCommandBuilder()
.setName('loop-queue')
.setDescription('toggle looping the entire queue');
public requiresVC = true;
private readonly playerManager: PlayerManager;
constructor(@inject(TYPES.Managers.Player) playerManager: PlayerManager) {
this.playerManager = playerManager;
}
public async execute(interaction: ChatInputCommandInteraction): Promise<void> {
const player = this.playerManager.get(interaction.guild!.id);
if (player.status === STATUS.IDLE) {
throw new Error('no songs to loop!');
}
if (player.queueSize() < 2) {
throw new Error('not enough songs to loop a queue!');
}
if (player.loopCurrentSong) {
player.loopCurrentSong = false;
}
player.loopCurrentQueue = !player.loopCurrentQueue;
await interaction.reply((player.loopCurrentQueue ? 'looped queue :)' : 'stopped looping queue :('));
}
}

View file

@ -4,7 +4,7 @@ import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js'; import PlayerManager from '../managers/player.js';
import Command from '.'; import Command from '.';
import {SlashCommandBuilder} from '@discordjs/builders'; import {SlashCommandBuilder} from '@discordjs/builders';
import {STATUS} from '../services/player.js'; import {STATUS} from '../services/player';
@injectable() @injectable()
export default class implements Command { export default class implements Command {
@ -27,10 +27,6 @@ export default class implements Command {
throw new Error('no song to loop!'); throw new Error('no song to loop!');
} }
if (player.loopCurrentQueue) {
player.loopCurrentQueue = false;
}
player.loopCurrentSong = !player.loopCurrentSong; player.loopCurrentSong = !player.loopCurrentSong;
await interaction.reply((player.loopCurrentSong ? 'looped :)' : 'stopped looping :(')); await interaction.reply((player.loopCurrentSong ? 'looped :)' : 'stopped looping :('));

View file

@ -3,7 +3,7 @@ import container from '../inversify.config.js';
import {TYPES} from '../types.js'; import {TYPES} from '../types.js';
import PlayerManager from '../managers/player.js'; import PlayerManager from '../managers/player.js';
import {getSizeWithoutBots} from '../utils/channels.js'; import {getSizeWithoutBots} from '../utils/channels.js';
import {getGuildSettings} from '../utils/get-guild-settings.js'; import {getGuildSettings} from '../utils/get-guild-settings';
export default async (oldState: VoiceState, _: VoiceState): Promise<void> => { export default async (oldState: VoiceState, _: VoiceState): Promise<void> => {
const playerManager = container.get<PlayerManager>(TYPES.Managers.Player); const playerManager = container.get<PlayerManager>(TYPES.Managers.Player);

View file

@ -21,8 +21,7 @@ import Config from './commands/config.js';
import Disconnect from './commands/disconnect.js'; import Disconnect from './commands/disconnect.js';
import Favorites from './commands/favorites.js'; import Favorites from './commands/favorites.js';
import ForwardSeek from './commands/fseek.js'; import ForwardSeek from './commands/fseek.js';
import LoopQueue from './commands/loop-queue.js'; import Loop from './commands/loop';
import Loop from './commands/loop.js';
import Move from './commands/move.js'; import Move from './commands/move.js';
import Next from './commands/next.js'; import Next from './commands/next.js';
import NowPlaying from './commands/now-playing.js'; import NowPlaying from './commands/now-playing.js';
@ -69,7 +68,6 @@ container.bind<SpotifyAPI>(TYPES.Services.SpotifyAPI).to(SpotifyAPI).inSingleton
Disconnect, Disconnect,
Favorites, Favorites,
ForwardSeek, ForwardSeek,
LoopQueue,
Loop, Loop,
Move, Move,
Next, Next,

View file

@ -9,13 +9,11 @@ import Prisma from '@prisma/client';
import ora from 'ora'; import ora from 'ora';
import {startBot} from '../index.js'; import {startBot} from '../index.js';
import logBanner from '../utils/log-banner.js'; import logBanner from '../utils/log-banner.js';
import createDatabaseUrl, {createDatabasePath} from '../utils/create-database-url.js'; import {createDatabasePath} from '../utils/create-database-url.js';
import {DATA_DIR} from '../services/config.js'; import {DATA_DIR} from '../services/config.js';
const client = new Prisma.PrismaClient(); const client = new Prisma.PrismaClient();
process.env.DATABASE_URL = process.env.DATABASE_URL ?? createDatabaseUrl(DATA_DIR);
const migrateFromSequelizeToPrisma = async () => { const migrateFromSequelizeToPrisma = async () => {
await execa('prisma', ['migrate', 'resolve', '--applied', '20220101155430_migrate_from_sequelize'], {preferLocal: true}); await execa('prisma', ['migrate', 'resolve', '--applied', '20220101155430_migrate_from_sequelize'], {preferLocal: true});
}; };

View file

@ -9,7 +9,7 @@ import {SongMetadata, STATUS} from './player.js';
import PlayerManager from '../managers/player.js'; import PlayerManager from '../managers/player.js';
import {buildPlayingMessageEmbed} from '../utils/build-embed.js'; import {buildPlayingMessageEmbed} from '../utils/build-embed.js';
import {getMemberVoiceChannel, getMostPopularVoiceChannel} from '../utils/channels.js'; import {getMemberVoiceChannel, getMostPopularVoiceChannel} from '../utils/channels.js';
import {getGuildSettings} from '../utils/get-guild-settings.js'; import {getGuildSettings} from '../utils/get-guild-settings';
@injectable() @injectable()
export default class AddQueryToQueue { export default class AddQueryToQueue {

View file

@ -1,6 +1,6 @@
import {inject, injectable} from 'inversify'; import {inject, injectable} from 'inversify';
import * as spotifyURI from 'spotify-uri'; import * as spotifyURI from 'spotify-uri';
import {SongMetadata, QueuedPlaylist, MediaSource} from './player.js'; import {SongMetadata, QueuedPlaylist, MediaSource} from './player';
import {TYPES} from '../types.js'; import {TYPES} from '../types.js';
import ffmpeg from 'fluent-ffmpeg'; import ffmpeg from 'fluent-ffmpeg';
import YoutubeAPI from './youtube-api.js'; import YoutubeAPI from './youtube-api.js';

View file

@ -18,7 +18,7 @@ import {
} from '@discordjs/voice'; } from '@discordjs/voice';
import FileCacheProvider from './file-cache.js'; import FileCacheProvider from './file-cache.js';
import debug from '../utils/debug.js'; import debug from '../utils/debug.js';
import {getGuildSettings} from '../utils/get-guild-settings.js'; import {getGuildSettings} from '../utils/get-guild-settings';
export enum MediaSource { export enum MediaSource {
Youtube, Youtube,
@ -63,7 +63,6 @@ export default class {
public status = STATUS.PAUSED; public status = STATUS.PAUSED;
public guildId: string; public guildId: string;
public loopCurrentSong = false; public loopCurrentSong = false;
public loopCurrentQueue = false;
private queue: QueuedSong[] = []; private queue: QueuedSong[] = [];
private queuePosition = 0; private queuePosition = 0;
@ -546,17 +545,6 @@ export default class {
return; return;
} }
// Automatically re-add current song to queue
if (this.loopCurrentQueue && newState.status === AudioPlayerStatus.Idle && this.status === STATUS.PLAYING) {
const currentSong = this.getCurrent();
if (currentSong) {
this.add(currentSong);
} else {
throw new Error('No song currently playing.');
}
}
if (newState.status === AudioPlayerStatus.Idle && this.status === STATUS.PLAYING) { if (newState.status === AudioPlayerStatus.Idle && this.status === STATUS.PLAYING) {
await this.forward(1); await this.forward(1);
} }

View file

@ -46,7 +46,7 @@ const getPlayerUI = (player: Player) => {
const button = player.status === STATUS.PLAYING ? '⏹️' : '▶️'; const button = player.status === STATUS.PLAYING ? '⏹️' : '▶️';
const progressBar = getProgressBar(15, position / song.length); const progressBar = getProgressBar(15, position / song.length);
const elapsedTime = song.isLive ? 'live' : `${prettyTime(position)}/${prettyTime(song.length)}`; const elapsedTime = song.isLive ? 'live' : `${prettyTime(position)}/${prettyTime(song.length)}`;
const loop = player.loopCurrentSong ? '🔂' : player.loopCurrentQueue ? '🔁' : ''; const loop = player.loopCurrentSong ? '🔁' : '';
return `${button} ${progressBar} \`[${elapsedTime}]\` 🔉 ${loop}`; return `${button} ${progressBar} \`[${elapsedTime}]\` 🔉 ${loop}`;
}; };

View file

@ -1,6 +1,6 @@
import {Setting} from '@prisma/client'; import {Setting} from '@prisma/client';
import {prisma} from './db.js'; import {prisma} from './db';
import {createGuildSettings} from '../events/guild-create.js'; import {createGuildSettings} from '../events/guild-create';
export async function getGuildSettings(guildId: string): Promise<Setting> { export async function getGuildSettings(guildId: string): Promise<Setting> {
const config = await prisma.setting.findUnique({where: {guildId}}); const config = await prisma.setting.findUnique({where: {guildId}});

View file

@ -9,7 +9,7 @@
"esModuleInterop": true, "esModuleInterop": true,
"sourceMap": true, "sourceMap": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"outDir": "dist" "noEmit": true
}, },
"include": ["src"], "include": ["src"],
"exclude": ["node_modules"] "exclude": ["node_modules"]